Skip to content

bug: Changing FluentBit labels causes immutable selector error #1944

@ruben-chainalysis

Description

@ruben-chainalysis

Describe the issue

When labels are added or modified in the FluentBit spec.labels field after the DaemonSet has been created, the operator attempts to update the DaemonSet's immutable spec.selector field, causing continuous reconciliation failures.

ERROR Reconciler error {"controller": "FluentBit", "error": "DaemonSet.apps \"fluent-bit\" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{\"app\":\"fluentbit\", \"fluentbit.fluent.io/enabled\":\"true\"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable"}

To Reproduce

  1. Deploy fluent-operator with a FluentBit CR in DaemonSet mode with initial labels:
apiVersion: fluentbit.fluent.io/v1alpha2
kind: FluentBit
metadata:
  name: fluent-bit
spec:
  labels:
    app: fluentbit
  1. Wait for DaemonSet to be created and running
  2. Add a new label to the FluentBit CR:
spec:
  labels:
    app: fluentbit
    fluentbit.fluent.io/enabled: "true"  # New label added
  1. Apply the updated CR: kubectl apply -f fluentbit.yaml

  2. Observe continuous reconciliation failures in operator logs:

ERROR Reconciler error {"controller": "FluentBit", "error": "DaemonSet.apps \"fluent-bit\" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{\"app\":\"fluentbit\", \"fluentbit.fluent.io/enabled\":\"true\"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable"}

Expected behavior

When labels are changed in the FluentBit CR, the operator handles the change without causing continuous reconciliation failures. The user's intended label changes should be applied to the DaemonSet (or the operator should provide clear guidance on how to proceed).

Your Environment

- Fluent Operator version: v3.4.0
- Container Runtime: containerd
- Operating system: Amazon Linux 2023
- Kernel version: 6.12.x

How did you install fluent operator?

Installed via Helm chart with FluxCD

Additional context

Current workaround: Manually delete the DaemonSet to force recreation:

kubectl delete daemonset fluent-bit -n <namespace>

The operator immediately recreates it with the updated selector.

Related: Issue #1424 discusses inconsistent label/annotation behavior in FluentBit CR. Both issues involve how labels in the FluentBit CR affect the DaemonSet.

Impact:

  • Reconciliation fails continuously
  • Adding/removing labels in FluentBit CR requires manual intervention
  • Other legitimate DaemonSet updates are also blocked when selector mismatch exists

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions