fluent / fluent-operator

Operate Fluent Bit and Fluentd in the Kubernetes way - Previously known as FluentBit Operator
Apache License 2.0
581 stars 247 forks source link

bug: Failed to set flush #984

Open aonoa opened 11 months ago

aonoa commented 11 months ago

Describe the issue

image image

The request is invalid: patch: Invalid value: "{"apiVersion":"fluentbit.fluent.io/v1alpha2","kind":"ClusterFluentBitConfig","metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{"apiVersion":"fluentbit.fluent.io/v1alpha2","kind":"ClusterFluentBitConfig","metadata":{"annotations":{},"labels":{"app.kubernetes.io/name":"fluent-bit"},"name":"fluent-bit-config"},"spec":{"filterSelector":{"matchLabels":{"fluentbit.fluent.io/enabled":"true","fluentbit.fluent.io/mode":"k8s"}},"inputSelector":{"matchLabels":{"fluentbit.fluent.io/enabled":"true","fluentbit.fluent.io/mode":"k8s"}},"outputSelector":{"matchLabels":{"fluentbit.fluent.io/enabled":"true","fluentbit.fluent.io/mode":"k8s"}},"service":{"flush":1,"parsersFile":"parsers.conf"}}}\n"},"creationTimestamp":"2023-11-06T17:08:24Z","generation":3,"labels":{"app.kubernetes.io/name":"fluent-bit"},"managedFields":[{"apiVersion":"fluentbit.fluent.io/v1alpha2","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{".":{},"f:kubectl.kubernetes.io/last-applied-configuration":{}},"f:labels":{".":{},"f:app.kubernetes.io/name":{}}},"f:spec":{".":{},"f:filterSelector":{},"f:inputSelector":{},"f:outputSelector":{},"f:service":{".":{},"f:daemon":{},"f:logLevel":{},"f:parsersFile":{}}}},"manager":"kubectl-client-side-apply","operation":"Update","time":"2023-11-09T11:27:08Z"}],"name":"fluent-bit-config","resourceVersion":"126540","uid":"70c6d802-cded-4a0f-85f5-6a529dabb726"},"spec":{"filterSelector":{"matchLabels":{"fluentbit.fluent.io/enabled":"true","fluentbit.fluent.io/mode":"k8s"}},"inputSelector":{"matchLabels":{"fluentbit.fluent.io/enabled":"true","fluentbit.fluent.io/mode":"k8s"}},"outputSelector":{"matchLabels":{"fluentbit.fluent.io/enabled":"true","fluentbit.fluent.io/mode":"k8s"}},"service":{"flush":1,"parsersFile":"parsers.conf"}}}": strict decoding error: unknown field "spec.service.flush"

{
    "apiVersion": "fluentbit.fluent.io/v1alpha2",
    "kind": "ClusterFluentBitConfig",
    "metadata": {
        "annotations": {
            "kubectl.kubernetes.io/last-applied-configuration": "{"
            apiVersion ":"
            fluentbit.fluent.io / v1alpha2 ","
            kind ":"
            ClusterFluentBitConfig ","
            metadata ":{"
            annotations ":{},"
            labels ":{"
            app.kubernetes.io / name ":"
            fluent - bit "},"
            name ":"
            fluent - bit - config "},"
            spec ":{"
            filterSelector ":{"
            matchLabels ":{"
            fluentbit.fluent.io / enabled ":"
            true ","
            fluentbit.fluent.io / mode ":"
            k8s "}},"
            inputSelector ":{"
            matchLabels ":{"
            fluentbit.fluent.io / enabled ":"
            true ","
            fluentbit.fluent.io / mode ":"
            k8s "}},"
            outputSelector ":{"
            matchLabels ":{"
            fluentbit.fluent.io / enabled ":"
            true ","
            fluentbit.fluent.io / mode ":"
            k8s "}},"
            service ":{"
            flush ":1,"
            parsersFile ":"
            parsers.conf "}}}\n"
        },
        "creationTimestamp": "2023-11-06T17:08:24Z",
        "generation": 3,
        "labels": {
            "app.kubernetes.io/name": "fluent-bit"
        },
        "managedFields": [{
            "apiVersion": "fluentbit.fluent.io/v1alpha2",
            "fieldsType": "FieldsV1",
            "fieldsV1": {
                "f:metadata": {
                    "f:annotations": {
                        ".": {},
                        "f:kubectl.kubernetes.io/last-applied-configuration": {}
                    },
                    "f:labels": {
                        ".": {},
                        "f:app.kubernetes.io/name": {}
                    }
                },
                "f:spec": {
                    ".": {},
                    "f:filterSelector": {},
                    "f:inputSelector": {},
                    "f:outputSelector": {},
                    "f:service": {
                        ".": {},
                        "f:daemon": {},
                        "f:logLevel": {},
                        "f:parsersFile": {}
                    }
                }
            },
            "manager": "kubectl-client-side-apply",
            "operation": "Update",
            "time": "2023-11-09T11:27:08Z"
        }],
        "name": "fluent-bit-config",
        "resourceVersion": "126540",
        "uid": "70c6d802-cded-4a0f-85f5-6a529dabb726"
    },
    "spec": {
        "filterSelector": {
            "matchLabels": {
                "fluentbit.fluent.io/enabled": "true",
                "fluentbit.fluent.io/mode": "k8s"
            }
        },
        "inputSelector": {
            "matchLabels": {
                "fluentbit.fluent.io/enabled": "true",
                "fluentbit.fluent.io/mode": "k8s"
            }
        },
        "outputSelector": {
            "matchLabels": {
                "fluentbit.fluent.io/enabled": "true",
                "fluentbit.fluent.io/mode": "k8s"
            }
        },
        "service": {
            "flush": 1,
            "parsersFile": "parsers.conf"
        }
    }
}

To Reproduce

refer to config/samples/fluentbit_v1alpha2_fluentbitconfig.yaml

apiVersion: fluentbit.fluent.io/v1alpha2
  kind: ClusterFluentBitConfig
  metadata:
    name: fluent-bit-config
    labels:
      app.kubernetes.io/name: fluent-bit
  spec:
    service:
      flush: 1
      parsersFile: parsers.conf
    inputSelector:
      matchLabels:
        fluentbit.fluent.io/enabled: "true"
        fluentbit.fluent.io/mode: "k8s"
    filterSelector:
      matchLabels:
        fluentbit.fluent.io/enabled: "true"
        fluentbit.fluent.io/mode: "k8s"
    outputSelector:
      matchLabels:
        fluentbit.fluent.io/enabled: "true"
        fluentbit.fluent.io/mode: "k8s"

Expected behavior

Set flush time

[SERVICE]
    flush              1

Your Environment

- Fluent Operator version: kubesphere/fluent-operator:v2.5.0
- Container Runtime: docker 24.0.5
- Operating system: Ubuntu 22.04.3 LTS (Jammy Jellyfish)
- Kernel version: 6.2.0-36-generic

How did you install fluent operator?

kubectl apply -f https://raw.githubusercontent.com/fluent/fluent-operator/release-2.5/manifests/setup/setup.yaml

Additional context

No response

aonoa commented 11 months ago

https://github.com/fluent/fluent-operator/blob/be4da37b5ae28851512ab20be7527665be13ae0b/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go#L74

Why flushSeconds?

wenchajun commented 11 months ago

This can indeed be misleading, and it is a legacy error.

SvenThies commented 3 months ago

@wenchajun what would be the plan here? Otherwise, when using flushSeconds, the behaviour is as expected and the issue can be closed.