Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[shell-operator] bump kube client #684

Merged
merged 5 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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-20241106151317-aedb66ab41ce
ldmonster marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ 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=
github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U=
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-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=
Expand Down
2 changes: 1 addition & 1 deletion pkg/shell-operator/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/shell-operator/kube_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(klient.WithLogger(logger))
client.WithContextName(app.KubeContext)
client.WithConfigPath(app.KubeConfig)
client.WithRateLimiterSettings(app.KubeClientQps, app.KubeClientBurst)
Expand All @@ -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)
Expand All @@ -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(klient.WithLogger(logger))
client.WithContextName(app.KubeContext)
client.WithConfigPath(app.KubeConfig)
client.WithRateLimiterSettings(app.ObjectPatcherKubeClientQps, app.ObjectPatcherKubeClientBurst)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/suite/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(klient.WithLogger(log.NewNop()))
KubeClient.WithContextName(ContextName)
err := KubeClient.Init()
Expect(err).ShouldNot(HaveOccurred())
Expand Down
Loading