From 271b421bb06fd30c5dbfe655a36693acb3ff0116 Mon Sep 17 00:00:00 2001 From: Pavel Okhlopkov Date: Wed, 6 Nov 2024 17:53:37 +0300 Subject: [PATCH 1/5] bump Signed-off-by: Pavel Okhlopkov --- go.mod | 4 ++-- go.sum | 8 ++++---- pkg/shell-operator/bootstrap.go | 2 +- pkg/shell-operator/kube_client.go | 14 +++++++------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index e36a08cc..a673659e 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/flant/shell-operator go 1.22.8 require ( - github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241102120041-7e44e3e22ab9 - github.com/flant/kube-client v1.2.1 + github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241106140903-258b93b3334e + github.com/flant/kube-client v0.0.0-20241106144802-74dd66e8b239 github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee // branch: master github.com/go-chi/chi/v5 v5.1.0 github.com/go-openapi/spec v0.19.8 diff --git a/go.sum b/go.sum index ba266de3..41e70bbf 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241102120041-7e44e3e22ab9 h1:gCV1iKcaE69x3Knzj8isyVyEtRuG2YI4nmLIzBHBWeQ= -github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241102120041-7e44e3e22ab9/go.mod h1:Mk5HRzkc5pIcDIZ2JJ6DPuuqnwhXVkb3you8M8Mg+4w= +github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241106140903-258b93b3334e h1:QUQy+5Bv7/UzhfrytiG3c5gfLGhPppepVbRpbMisVIw= +github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241106140903-258b93b3334e/go.mod h1:Mk5HRzkc5pIcDIZ2JJ6DPuuqnwhXVkb3you8M8Mg+4w= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= @@ -33,8 +33,8 @@ github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCv github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/flant/go-openapi-validate v0.19.12-flant.0 h1:xk6kvc9fHKMgUdB6J7kbpbLR5vJOUzKAK8p3nrD7mDk= github.com/flant/go-openapi-validate v0.19.12-flant.0/go.mod h1:Rzou8hA/CBw8donlS6WNEUQupNvUZ0waH08tGe6kAQ4= -github.com/flant/kube-client v1.2.1 h1:8lHF8+wGZrhsXM6TeS3CNAPupXyx7UJLkBvNMpCe/ZI= -github.com/flant/kube-client v1.2.1/go.mod h1:62vCzrIUzWMU4DB0Pn6/02Pu7uwKh5/mHGWy2NmxZAk= +github.com/flant/kube-client v0.0.0-20241106144802-74dd66e8b239 h1:CALDLTCaqutYLAeCM+VaueLu73r66jtL5/8qRZ8jWW0= +github.com/flant/kube-client v0.0.0-20241106144802-74dd66e8b239/go.mod h1:eMa3aJ6V1PRWSQ/RCROkObDpY4S74uM84SJS4G/LINg= github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee h1:evii83J+/6QGNvyf6tjQ/p27DPY9iftxIBb37ALJRTg= github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee/go.mod h1:f+REaGl/+pZR97rbTcwHEka/MAipoQQ2Mc0iQUj4ak0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= diff --git a/pkg/shell-operator/bootstrap.go b/pkg/shell-operator/bootstrap.go index cf4ccc4e..760726a4 100644 --- a/pkg/shell-operator/bootstrap.go +++ b/pkg/shell-operator/bootstrap.go @@ -84,7 +84,7 @@ func (op *ShellOperator) AssembleCommonOperator(listenAddress, listenPort string op.setupHookMetricStorage() // 'main' Kubernetes client. - op.KubeClient, err = initDefaultMainKubeClient(op.MetricStorage) + op.KubeClient, err = initDefaultMainKubeClient(op.MetricStorage, op.logger) if err != nil { return err } diff --git a/pkg/shell-operator/kube_client.go b/pkg/shell-operator/kube_client.go index 59287fb4..e77f721c 100644 --- a/pkg/shell-operator/kube_client.go +++ b/pkg/shell-operator/kube_client.go @@ -19,8 +19,8 @@ var ( // defaultMainKubeClient creates a Kubernetes client for hooks. No timeout specified, because // timeout will reset connections for Watchers. -func defaultMainKubeClient(metricStorage *metric_storage.MetricStorage, metricLabels map[string]string) *klient.Client { - client := klient.New() +func defaultMainKubeClient(metricStorage *metric_storage.MetricStorage, metricLabels map[string]string, logger *log.Logger) *klient.Client { + client := klient.New(logger) client.WithContextName(app.KubeContext) client.WithConfigPath(app.KubeConfig) client.WithRateLimiterSettings(app.KubeClientQps, app.KubeClientBurst) @@ -29,10 +29,10 @@ func defaultMainKubeClient(metricStorage *metric_storage.MetricStorage, metricLa return client } -func initDefaultMainKubeClient(metricStorage *metric_storage.MetricStorage) (*klient.Client, error) { +func initDefaultMainKubeClient(metricStorage *metric_storage.MetricStorage, logger *log.Logger) (*klient.Client, error) { //nolint:staticcheck klient.RegisterKubernetesClientMetrics(metricStorage, defaultMainKubeClientMetricLabels) - kubeClient := defaultMainKubeClient(metricStorage, defaultMainKubeClientMetricLabels) + kubeClient := defaultMainKubeClient(metricStorage, defaultMainKubeClientMetricLabels, logger.Named("main-kube-client")) err := kubeClient.Init() if err != nil { return nil, fmt.Errorf("initialize 'main' Kubernetes client: %s\n", err) @@ -41,8 +41,8 @@ func initDefaultMainKubeClient(metricStorage *metric_storage.MetricStorage) (*kl } // defaultObjectPatcherKubeClient initializes a Kubernetes client for ObjectPatcher. Timeout is specified here. -func defaultObjectPatcherKubeClient(metricStorage *metric_storage.MetricStorage, metricLabels map[string]string) *klient.Client { - client := klient.New() +func defaultObjectPatcherKubeClient(metricStorage *metric_storage.MetricStorage, metricLabels map[string]string, logger *log.Logger) *klient.Client { + client := klient.New(logger) client.WithContextName(app.KubeContext) client.WithConfigPath(app.KubeConfig) client.WithRateLimiterSettings(app.ObjectPatcherKubeClientQps, app.ObjectPatcherKubeClientBurst) @@ -53,7 +53,7 @@ func defaultObjectPatcherKubeClient(metricStorage *metric_storage.MetricStorage, } func initDefaultObjectPatcher(metricStorage *metric_storage.MetricStorage, logger *log.Logger) (*object_patch.ObjectPatcher, error) { - patcherKubeClient := defaultObjectPatcherKubeClient(metricStorage, defaultObjectPatcherKubeClientMetricLabels) + patcherKubeClient := defaultObjectPatcherKubeClient(metricStorage, defaultObjectPatcherKubeClientMetricLabels, logger.Named("object-patcher-kube-client")) err := patcherKubeClient.Init() if err != nil { return nil, fmt.Errorf("initialize Kubernetes client for Object patcher: %s\n", err) From b43800ffc4a621933b3aa5ab4703af5b54004ae8 Mon Sep 17 00:00:00 2001 From: Pavel Okhlopkov Date: Wed, 6 Nov 2024 18:04:10 +0300 Subject: [PATCH 2/5] lint todo Signed-off-by: Pavel Okhlopkov --- .golangci.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.golangci.yaml b/.golangci.yaml index a418e83a..ece73ad1 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -38,6 +38,11 @@ linters-settings: local-prefixes: github.com/flant/ nolintlint: allow-unused: true + # TODO: replace deprecated methods + # ignore deprecated + # https://staticcheck.dev/docs/checks/#SA1019 + staticcheck: + checks: ["all","-SA1019"] sloglint: # Enforce not mixing key-value pairs and attributes. no-mixed-args: true From f81f94a42727616ed8bd6f72b01292562cd10216 Mon Sep 17 00:00:00 2001 From: Pavel Okhlopkov Date: Wed, 6 Nov 2024 18:05:57 +0300 Subject: [PATCH 3/5] fix tests Signed-off-by: Pavel Okhlopkov --- test/integration/suite/run.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/suite/run.go b/test/integration/suite/run.go index 1144d209..565def8d 100644 --- a/test/integration/suite/run.go +++ b/test/integration/suite/run.go @@ -32,7 +32,7 @@ func RunIntegrationSuite(t *testing.T, description string, clusterPrefix string) var _ = BeforeSuite(func() { // Initialize kube client out-of-cluster - KubeClient = klient.New() + KubeClient = klient.New(log.NewNop()) KubeClient.WithContextName(ContextName) err := KubeClient.Init() Expect(err).ShouldNot(HaveOccurred()) From 52bd5f65949073388ab6964fb120d28b3da12704 Mon Sep 17 00:00:00 2001 From: Pavel Okhlopkov Date: Wed, 6 Nov 2024 18:14:29 +0300 Subject: [PATCH 4/5] add options Signed-off-by: Pavel Okhlopkov --- go.mod | 2 +- go.sum | 4 ++-- pkg/shell-operator/kube_client.go | 4 ++-- test/integration/suite/run.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index a673659e..6bafb6c1 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22.8 require ( github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241106140903-258b93b3334e - github.com/flant/kube-client v0.0.0-20241106144802-74dd66e8b239 + github.com/flant/kube-client v0.0.0-20241106151317-aedb66ab41ce github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee // branch: master github.com/go-chi/chi/v5 v5.1.0 github.com/go-openapi/spec v0.19.8 diff --git a/go.sum b/go.sum index 41e70bbf..937fe63a 100644 --- a/go.sum +++ b/go.sum @@ -33,8 +33,8 @@ github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCv github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/flant/go-openapi-validate v0.19.12-flant.0 h1:xk6kvc9fHKMgUdB6J7kbpbLR5vJOUzKAK8p3nrD7mDk= github.com/flant/go-openapi-validate v0.19.12-flant.0/go.mod h1:Rzou8hA/CBw8donlS6WNEUQupNvUZ0waH08tGe6kAQ4= -github.com/flant/kube-client v0.0.0-20241106144802-74dd66e8b239 h1:CALDLTCaqutYLAeCM+VaueLu73r66jtL5/8qRZ8jWW0= -github.com/flant/kube-client v0.0.0-20241106144802-74dd66e8b239/go.mod h1:eMa3aJ6V1PRWSQ/RCROkObDpY4S74uM84SJS4G/LINg= +github.com/flant/kube-client v0.0.0-20241106151317-aedb66ab41ce h1:FL+9YUB2Hlu3s4shy8TvW6S0q8Ia8g+9O6cC44K+awo= +github.com/flant/kube-client v0.0.0-20241106151317-aedb66ab41ce/go.mod h1:eMa3aJ6V1PRWSQ/RCROkObDpY4S74uM84SJS4G/LINg= github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee h1:evii83J+/6QGNvyf6tjQ/p27DPY9iftxIBb37ALJRTg= github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee/go.mod h1:f+REaGl/+pZR97rbTcwHEka/MAipoQQ2Mc0iQUj4ak0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= diff --git a/pkg/shell-operator/kube_client.go b/pkg/shell-operator/kube_client.go index e77f721c..733341ac 100644 --- a/pkg/shell-operator/kube_client.go +++ b/pkg/shell-operator/kube_client.go @@ -20,7 +20,7 @@ var ( // defaultMainKubeClient creates a Kubernetes client for hooks. No timeout specified, because // timeout will reset connections for Watchers. func defaultMainKubeClient(metricStorage *metric_storage.MetricStorage, metricLabels map[string]string, logger *log.Logger) *klient.Client { - client := klient.New(logger) + client := klient.New(klient.WithLogger(logger)) client.WithContextName(app.KubeContext) client.WithConfigPath(app.KubeConfig) client.WithRateLimiterSettings(app.KubeClientQps, app.KubeClientBurst) @@ -42,7 +42,7 @@ func initDefaultMainKubeClient(metricStorage *metric_storage.MetricStorage, logg // defaultObjectPatcherKubeClient initializes a Kubernetes client for ObjectPatcher. Timeout is specified here. func defaultObjectPatcherKubeClient(metricStorage *metric_storage.MetricStorage, metricLabels map[string]string, logger *log.Logger) *klient.Client { - client := klient.New(logger) + client := klient.New(klient.WithLogger(logger)) client.WithContextName(app.KubeContext) client.WithConfigPath(app.KubeConfig) client.WithRateLimiterSettings(app.ObjectPatcherKubeClientQps, app.ObjectPatcherKubeClientBurst) diff --git a/test/integration/suite/run.go b/test/integration/suite/run.go index 565def8d..f6fb6dc6 100644 --- a/test/integration/suite/run.go +++ b/test/integration/suite/run.go @@ -32,7 +32,7 @@ func RunIntegrationSuite(t *testing.T, description string, clusterPrefix string) var _ = BeforeSuite(func() { // Initialize kube client out-of-cluster - KubeClient = klient.New(log.NewNop()) + KubeClient = klient.New(klient.WithLogger(log.NewNop())) KubeClient.WithContextName(ContextName) err := KubeClient.Init() Expect(err).ShouldNot(HaveOccurred()) From 0212bdfeea23f0226bc629c0acda8fe67b08db56 Mon Sep 17 00:00:00 2001 From: Pavel Okhlopkov Date: Thu, 7 Nov 2024 12:41:00 +0300 Subject: [PATCH 5/5] bump kube-client Signed-off-by: Pavel Okhlopkov --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6bafb6c1..d5739ada 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22.8 require ( github.com/deckhouse/deckhouse/pkg/log v0.0.0-20241106140903-258b93b3334e - github.com/flant/kube-client v0.0.0-20241106151317-aedb66ab41ce + github.com/flant/kube-client v1.2.2 github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee // branch: master github.com/go-chi/chi/v5 v5.1.0 github.com/go-openapi/spec v0.19.8 diff --git a/go.sum b/go.sum index 937fe63a..d25d28f3 100644 --- a/go.sum +++ b/go.sum @@ -33,8 +33,8 @@ github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCv github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/flant/go-openapi-validate v0.19.12-flant.0 h1:xk6kvc9fHKMgUdB6J7kbpbLR5vJOUzKAK8p3nrD7mDk= github.com/flant/go-openapi-validate v0.19.12-flant.0/go.mod h1:Rzou8hA/CBw8donlS6WNEUQupNvUZ0waH08tGe6kAQ4= -github.com/flant/kube-client v0.0.0-20241106151317-aedb66ab41ce h1:FL+9YUB2Hlu3s4shy8TvW6S0q8Ia8g+9O6cC44K+awo= -github.com/flant/kube-client v0.0.0-20241106151317-aedb66ab41ce/go.mod h1:eMa3aJ6V1PRWSQ/RCROkObDpY4S74uM84SJS4G/LINg= +github.com/flant/kube-client v1.2.2 h1:27LBs+PKJEFnkQXjPU9eIps7a7iyI13AKcSYj897DCU= +github.com/flant/kube-client v1.2.2/go.mod h1:eMa3aJ6V1PRWSQ/RCROkObDpY4S74uM84SJS4G/LINg= github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee h1:evii83J+/6QGNvyf6tjQ/p27DPY9iftxIBb37ALJRTg= github.com/flant/libjq-go v1.6.3-0.20201126171326-c46a40ff22ee/go.mod h1:f+REaGl/+pZR97rbTcwHEka/MAipoQQ2Mc0iQUj4ak0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=