From bf38de5c9b67efcf7bcfe6c54c49cc97cb8aa517 Mon Sep 17 00:00:00 2001 From: Jedrzej Kotkowski Date: Fri, 8 Nov 2024 22:28:37 +0100 Subject: [PATCH 1/2] change fluentbit flushSeconds type to float64 Signed-off-by: Jedrzej Kotkowski --- Makefile | 2 +- apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go | 2 +- .../v1alpha2/clusterfluentbitconfig_types_test.go | 8 ++++++-- .../v1alpha2/plugins/custom/zz_generated.deepcopy.go | 1 + .../v1alpha2/plugins/filter/zz_generated.deepcopy.go | 1 + .../v1alpha2/plugins/input/zz_generated.deepcopy.go | 1 + .../plugins/multilineparser/zz_generated.deepcopy.go | 1 + .../v1alpha2/plugins/output/zz_generated.deepcopy.go | 1 + .../v1alpha2/plugins/parser/zz_generated.deepcopy.go | 1 + apis/fluentbit/v1alpha2/plugins/zz_generated.deepcopy.go | 1 + apis/fluentbit/v1alpha2/zz_generated.deepcopy.go | 3 ++- .../v1alpha1/plugins/common/zz_generated.deepcopy.go | 1 + apis/fluentd/v1alpha1/zz_generated.deepcopy.go | 1 + .../crds/fluentbit.fluent.io_clusterfluentbitconfigs.yaml | 3 +-- .../crds/fluentbit.fluent.io_fluentbitconfigs.yaml | 3 +-- .../fluentbit.fluent.io_clusterfluentbitconfigs.yaml | 3 +-- .../crd/bases/fluentbit.fluent.io_fluentbitconfigs.yaml | 3 +-- docs/fluentbit.md | 2 +- go.mod | 4 ++++ go.sum | 6 ++++++ manifests/setup/fluent-operator-crd.yaml | 6 ++---- manifests/setup/setup.yaml | 6 ++---- 22 files changed, 38 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 148e80925..cbedd5247 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ FD_IMG_BASE ?= ghcr.io/fluent/fluent-operator/fluentd:v1.17.0-arm64-base ARCH ?= arm64 # Produce CRDs that work back to Kubernetes 1.11 (no version conversion) -CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true" +CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true,allowDangerousTypes=true" # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) diff --git a/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go b/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go index 06661f557..17751a919 100644 --- a/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go +++ b/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go @@ -81,7 +81,7 @@ type Service struct { // If true go to background on start Daemon *bool `json:"daemon,omitempty"` // Interval to flush output - FlushSeconds *int64 `json:"flushSeconds,omitempty"` + FlushSeconds *float64 `json:"flushSeconds,omitempty"` // Wait time on exit GraceSeconds *int64 `json:"graceSeconds,omitempty"` // the error count to meet the unhealthy requirement, this is a sum for all output plugins in a defined HC_Period, example for output error: [2022/02/16 10:44:10] [ warn] [engine] failed to flush chunk '1-1645008245.491540684.flb', retry in 7 seconds: task_id=0, input=forward.1 > output=cloudwatch_logs.3 (out_id=3) diff --git a/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types_test.go b/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types_test.go index a40002bbd..673a8736e 100644 --- a/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types_test.go +++ b/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types_test.go @@ -377,7 +377,7 @@ var cfg = ClusterFluentBitConfig{ Spec: FluentBitConfigSpec{ Service: &Service{ Daemon: ptrBool(false), - FlushSeconds: ptrInt64(1), + FlushSeconds: ptrFloat64(1), GraceSeconds: ptrInt64(30), HttpServer: ptrBool(true), LogLevel: "info", @@ -1168,7 +1168,7 @@ func TestClusterFluentBitConfig_RenderMainConfig_WithParsersFiles(t *testing.T) Spec: FluentBitConfigSpec{ Service: &Service{ Daemon: ptrBool(false), - FlushSeconds: ptrInt64(1), + FlushSeconds: ptrFloat64(1), GraceSeconds: ptrInt64(30), HttpServer: ptrBool(true), LogLevel: "info", @@ -1372,3 +1372,7 @@ func ptrInt64(v int64) *int64 { func ptrInt32(v int32) *int32 { return &v } + +func ptrFloat64(v float64) *float64 { + return &v +} diff --git a/apis/fluentbit/v1alpha2/plugins/custom/zz_generated.deepcopy.go b/apis/fluentbit/v1alpha2/plugins/custom/zz_generated.deepcopy.go index 92f05b349..c2ecb123f 100644 --- a/apis/fluentbit/v1alpha2/plugins/custom/zz_generated.deepcopy.go +++ b/apis/fluentbit/v1alpha2/plugins/custom/zz_generated.deepcopy.go @@ -1,4 +1,5 @@ //go:build !ignore_autogenerated +// +build !ignore_autogenerated /* Copyright 2022. diff --git a/apis/fluentbit/v1alpha2/plugins/filter/zz_generated.deepcopy.go b/apis/fluentbit/v1alpha2/plugins/filter/zz_generated.deepcopy.go index 10a8e1c82..2248f3a96 100644 --- a/apis/fluentbit/v1alpha2/plugins/filter/zz_generated.deepcopy.go +++ b/apis/fluentbit/v1alpha2/plugins/filter/zz_generated.deepcopy.go @@ -1,4 +1,5 @@ //go:build !ignore_autogenerated +// +build !ignore_autogenerated /* Copyright 2022. diff --git a/apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go b/apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go index 9be65078e..0f22b93ca 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go +++ b/apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go @@ -1,4 +1,5 @@ //go:build !ignore_autogenerated +// +build !ignore_autogenerated /* Copyright 2022. diff --git a/apis/fluentbit/v1alpha2/plugins/multilineparser/zz_generated.deepcopy.go b/apis/fluentbit/v1alpha2/plugins/multilineparser/zz_generated.deepcopy.go index 5d0bb0840..9590dd2bc 100644 --- a/apis/fluentbit/v1alpha2/plugins/multilineparser/zz_generated.deepcopy.go +++ b/apis/fluentbit/v1alpha2/plugins/multilineparser/zz_generated.deepcopy.go @@ -1,4 +1,5 @@ //go:build !ignore_autogenerated +// +build !ignore_autogenerated /* Copyright 2022. diff --git a/apis/fluentbit/v1alpha2/plugins/output/zz_generated.deepcopy.go b/apis/fluentbit/v1alpha2/plugins/output/zz_generated.deepcopy.go index bd36e928e..463987678 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/zz_generated.deepcopy.go +++ b/apis/fluentbit/v1alpha2/plugins/output/zz_generated.deepcopy.go @@ -1,4 +1,5 @@ //go:build !ignore_autogenerated +// +build !ignore_autogenerated /* Copyright 2022. diff --git a/apis/fluentbit/v1alpha2/plugins/parser/zz_generated.deepcopy.go b/apis/fluentbit/v1alpha2/plugins/parser/zz_generated.deepcopy.go index 3ed98ba55..34b14fa72 100644 --- a/apis/fluentbit/v1alpha2/plugins/parser/zz_generated.deepcopy.go +++ b/apis/fluentbit/v1alpha2/plugins/parser/zz_generated.deepcopy.go @@ -1,4 +1,5 @@ //go:build !ignore_autogenerated +// +build !ignore_autogenerated /* Copyright 2022. diff --git a/apis/fluentbit/v1alpha2/plugins/zz_generated.deepcopy.go b/apis/fluentbit/v1alpha2/plugins/zz_generated.deepcopy.go index 2fe9b68ba..b68555c24 100644 --- a/apis/fluentbit/v1alpha2/plugins/zz_generated.deepcopy.go +++ b/apis/fluentbit/v1alpha2/plugins/zz_generated.deepcopy.go @@ -1,4 +1,5 @@ //go:build !ignore_autogenerated +// +build !ignore_autogenerated /* Copyright 2022. diff --git a/apis/fluentbit/v1alpha2/zz_generated.deepcopy.go b/apis/fluentbit/v1alpha2/zz_generated.deepcopy.go index 2e1bf58ae..ebbd1c3cc 100644 --- a/apis/fluentbit/v1alpha2/zz_generated.deepcopy.go +++ b/apis/fluentbit/v1alpha2/zz_generated.deepcopy.go @@ -1,4 +1,5 @@ //go:build !ignore_autogenerated +// +build !ignore_autogenerated /* Copyright 2022. @@ -1710,7 +1711,7 @@ func (in *Service) DeepCopyInto(out *Service) { } if in.FlushSeconds != nil { in, out := &in.FlushSeconds, &out.FlushSeconds - *out = new(int64) + *out = new(float64) **out = **in } if in.GraceSeconds != nil { diff --git a/apis/fluentd/v1alpha1/plugins/common/zz_generated.deepcopy.go b/apis/fluentd/v1alpha1/plugins/common/zz_generated.deepcopy.go index 49ff87b81..839ede891 100644 --- a/apis/fluentd/v1alpha1/plugins/common/zz_generated.deepcopy.go +++ b/apis/fluentd/v1alpha1/plugins/common/zz_generated.deepcopy.go @@ -1,4 +1,5 @@ //go:build !ignore_autogenerated +// +build !ignore_autogenerated /* Copyright 2022. diff --git a/apis/fluentd/v1alpha1/zz_generated.deepcopy.go b/apis/fluentd/v1alpha1/zz_generated.deepcopy.go index 8433e9545..af4064acd 100644 --- a/apis/fluentd/v1alpha1/zz_generated.deepcopy.go +++ b/apis/fluentd/v1alpha1/zz_generated.deepcopy.go @@ -1,4 +1,5 @@ //go:build !ignore_autogenerated +// +build !ignore_autogenerated /* Copyright 2022. diff --git a/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterfluentbitconfigs.yaml b/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterfluentbitconfigs.yaml index 37c33dfe3..a7b192c81 100644 --- a/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterfluentbitconfigs.yaml +++ b/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterfluentbitconfigs.yaml @@ -301,8 +301,7 @@ spec: type: string flushSeconds: description: Interval to flush output - format: int64 - type: integer + type: number graceSeconds: description: Wait time on exit format: int64 diff --git a/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_fluentbitconfigs.yaml b/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_fluentbitconfigs.yaml index 9cee4fdf8..44b1fb299 100644 --- a/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_fluentbitconfigs.yaml +++ b/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_fluentbitconfigs.yaml @@ -333,8 +333,7 @@ spec: type: string flushSeconds: description: Interval to flush output - format: int64 - type: integer + type: number graceSeconds: description: Wait time on exit format: int64 diff --git a/config/crd/bases/fluentbit.fluent.io_clusterfluentbitconfigs.yaml b/config/crd/bases/fluentbit.fluent.io_clusterfluentbitconfigs.yaml index 37c33dfe3..a7b192c81 100644 --- a/config/crd/bases/fluentbit.fluent.io_clusterfluentbitconfigs.yaml +++ b/config/crd/bases/fluentbit.fluent.io_clusterfluentbitconfigs.yaml @@ -301,8 +301,7 @@ spec: type: string flushSeconds: description: Interval to flush output - format: int64 - type: integer + type: number graceSeconds: description: Wait time on exit format: int64 diff --git a/config/crd/bases/fluentbit.fluent.io_fluentbitconfigs.yaml b/config/crd/bases/fluentbit.fluent.io_fluentbitconfigs.yaml index 9cee4fdf8..44b1fb299 100644 --- a/config/crd/bases/fluentbit.fluent.io_fluentbitconfigs.yaml +++ b/config/crd/bases/fluentbit.fluent.io_fluentbitconfigs.yaml @@ -333,8 +333,7 @@ spec: type: string flushSeconds: description: Interval to flush output - format: int64 - type: integer + type: number graceSeconds: description: Wait time on exit format: int64 diff --git a/docs/fluentbit.md b/docs/fluentbit.md index 450dc7fc9..11d6a4670 100644 --- a/docs/fluentbit.md +++ b/docs/fluentbit.md @@ -621,7 +621,7 @@ ParserSpec defines the desired state of ClusterParser | Field | Description | Scheme | | ----- | ----------- | ------ | | daemon | If true go to background on start | *bool | -| flushSeconds | Interval to flush output | *int64 | +| flushSeconds | Interval to flush output | *float64 | | graceSeconds | Wait time on exit | *int64 | | hcErrorsCount | the error count to meet the unhealthy requirement, this is a sum for all output plugins in a defined HC_Period, example for output error: [2022/02/16 10:44:10] [ warn] [engine] failed to flush chunk '1-1645008245.491540684.flb', retry in 7 seconds: task_id=0, input=forward.1 > output=cloudwatch_logs.3 (out_id=3) | *int64 | | hcRetryFailureCount | the retry failure count to meet the unhealthy requirement, this is a sum for all output plugins in a defined HC_Period, example for retry failure: [2022/02/16 20:11:36] [ warn] [engine] chunk '1-1645042288.260516436.flb' cannot be retried: task_id=0, input=tcp.3 > output=cloudwatch_logs.1 | *int64 | diff --git a/go.mod b/go.mod index 2f63cff37..47d44a03e 100644 --- a/go.mod +++ b/go.mod @@ -60,12 +60,14 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect + golang.org/x/mod v0.20.0 // indirect golang.org/x/net v0.28.0 // indirect golang.org/x/oauth2 v0.12.0 // indirect golang.org/x/sys v0.24.0 // indirect golang.org/x/term v0.23.0 // indirect golang.org/x/text v0.17.0 // indirect golang.org/x/time v0.3.0 // indirect + golang.org/x/tools v0.24.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.34.1 // indirect @@ -74,6 +76,8 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/apiextensions-apiserver v0.30.1 // indirect + k8s.io/code-generator v0.30.3 // indirect + k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect diff --git a/go.sum b/go.sum index ac8b993f2..40f0d6f9d 100644 --- a/go.sum +++ b/go.sum @@ -152,6 +152,8 @@ golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0 golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= +golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= @@ -238,6 +240,10 @@ k8s.io/apimachinery v0.30.3 h1:q1laaWCmrszyQuSQCfNB8cFgCuDAoPszKY4ucAjDwHc= k8s.io/apimachinery v0.30.3/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= k8s.io/client-go v0.30.3 h1:bHrJu3xQZNXIi8/MoxYtZBBWQQXwy16zqJwloXXfD3k= k8s.io/client-go v0.30.3/go.mod h1:8d4pf8vYu665/kUbsxWAQ/JDBNWqfFeZnvFiVdmx89U= +k8s.io/code-generator v0.30.3 h1:bmtnLJKagDS5f5uOEpLyJiDfIMKXGMKgOLBdde+w0Mc= +k8s.io/code-generator v0.30.3/go.mod h1:PFgBiv+miFV7TZYp+RXgROkhA+sWYZ+mtpbMLofMke8= +k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 h1:NGrVE502P0s0/1hudf8zjgwki1X/TByhmAoILTarmzo= +k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70/go.mod h1:VH3AT8AaQOqiGjMF9p0/IM1Dj+82ZwjfxUP1IxaHE+8= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= diff --git a/manifests/setup/fluent-operator-crd.yaml b/manifests/setup/fluent-operator-crd.yaml index b1fe030cd..c7723c253 100644 --- a/manifests/setup/fluent-operator-crd.yaml +++ b/manifests/setup/fluent-operator-crd.yaml @@ -1746,8 +1746,7 @@ spec: type: string flushSeconds: description: Interval to flush output - format: int64 - type: integer + type: number graceSeconds: description: Wait time on exit format: int64 @@ -16448,8 +16447,7 @@ spec: type: string flushSeconds: description: Interval to flush output - format: int64 - type: integer + type: number graceSeconds: description: Wait time on exit format: int64 diff --git a/manifests/setup/setup.yaml b/manifests/setup/setup.yaml index 3a111c138..9453cb6ac 100644 --- a/manifests/setup/setup.yaml +++ b/manifests/setup/setup.yaml @@ -1746,8 +1746,7 @@ spec: type: string flushSeconds: description: Interval to flush output - format: int64 - type: integer + type: number graceSeconds: description: Wait time on exit format: int64 @@ -16448,8 +16447,7 @@ spec: type: string flushSeconds: description: Interval to flush output - format: int64 - type: integer + type: number graceSeconds: description: Wait time on exit format: int64 From fccafd0b7ecbe2f54e7323f2d871f53c757517c8 Mon Sep 17 00:00:00 2001 From: Jedrzej Kotkowski Date: Fri, 8 Nov 2024 22:33:05 +0100 Subject: [PATCH 2/2] verify-crds.sh allowDangerousTypes=true Signed-off-by: Jedrzej Kotkowski --- hack/verify-crds.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/verify-crds.sh b/hack/verify-crds.sh index 12b479cdd..1b0108177 100755 --- a/hack/verify-crds.sh +++ b/hack/verify-crds.sh @@ -5,7 +5,7 @@ set -o nounset set -o pipefail SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/.. -CRD_OPTIONS="crd:generateEmbeddedObjectMeta=true" +CRD_OPTIONS="crd:generateEmbeddedObjectMeta=true,allowDangerousTypes=true" DIFFROOT="${SCRIPT_ROOT}/config/crd/bases/" TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/config/crd/bases/"