From d25cd3abe3c6f95fc3e69588186c86dfe3b39fcc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Nov 2025 12:19:31 +0000 Subject: [PATCH] Bump the k8s-dependencies group across 1 directory with 2 updates Bumps the k8s-dependencies group with 2 updates in the / directory: [github.com/kubernetes-csi/csi-lib-utils](https://github.com/kubernetes-csi/csi-lib-utils) and [sigs.k8s.io/apiserver-network-proxy/konnectivity-client](https://github.com/kubernetes-sigs/apiserver-network-proxy). Updates `github.com/kubernetes-csi/csi-lib-utils` from 0.22.0 to 0.23.0 - [Release notes](https://github.com/kubernetes-csi/csi-lib-utils/releases) - [Commits](https://github.com/kubernetes-csi/csi-lib-utils/compare/v0.22.0...v0.23.0) Updates `sigs.k8s.io/apiserver-network-proxy/konnectivity-client` from 0.31.2 to 0.34.0 - [Release notes](https://github.com/kubernetes-sigs/apiserver-network-proxy/releases) - [Changelog](https://github.com/kubernetes-sigs/apiserver-network-proxy/blob/master/RELEASE.md) - [Commits](https://github.com/kubernetes-sigs/apiserver-network-proxy/compare/v0.31.2...v0.34.0) --- updated-dependencies: - dependency-name: github.com/kubernetes-csi/csi-lib-utils dependency-version: 0.23.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: k8s-dependencies - dependency-name: sigs.k8s.io/apiserver-network-proxy/konnectivity-client dependency-version: 0.34.0 dependency-type: indirect update-type: version-update:semver-minor dependency-group: k8s-dependencies ... Signed-off-by: dependabot[bot] --- go.mod | 16 ++-- go.sum | 8 +- .../leaderelection/leader_election.go | 64 +++++++++++++- .../csi-lib-utils/standardflags/flags.go | 83 +++++++++++++++++++ vendor/modules.txt | 14 ++-- .../proto/client/client.pb.go | 1 - 6 files changed, 163 insertions(+), 23 deletions(-) create mode 100644 vendor/github.com/kubernetes-csi/csi-lib-utils/standardflags/flags.go diff --git a/go.mod b/go.mod index 8ffce4b76..eda388ad5 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/kubernetes-csi/external-snapshotter/v8 -go 1.24.0 - -toolchain go1.24.6 +go 1.24.6 require ( github.com/container-storage-interface/spec v1.12.0 @@ -10,7 +8,7 @@ require ( github.com/fsnotify/fsnotify v1.9.0 github.com/golang/mock v1.6.0 github.com/google/go-cmp v0.7.0 - github.com/kubernetes-csi/csi-lib-utils v0.22.0 + github.com/kubernetes-csi/csi-lib-utils v0.23.0 github.com/kubernetes-csi/csi-test/v5 v5.4.0 github.com/kubernetes-csi/external-snapshotter/client/v8 v8.2.0 github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 @@ -19,12 +17,12 @@ require ( github.com/prometheus/common v0.62.0 google.golang.org/grpc v1.72.1 google.golang.org/protobuf v1.36.5 - k8s.io/api v0.34.0 + k8s.io/api v0.34.1 k8s.io/apiextensions-apiserver v0.34.0 - k8s.io/apimachinery v0.34.0 + k8s.io/apimachinery v0.34.1 k8s.io/apiserver v0.34.0 - k8s.io/client-go v0.34.0 - k8s.io/component-base v0.34.0 + k8s.io/client-go v0.34.1 + k8s.io/component-base v0.34.1 k8s.io/component-helpers v0.34.0 k8s.io/klog/v2 v2.130.1 k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 @@ -105,7 +103,7 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect - sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 // indirect + sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.34.0 // indirect sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect sigs.k8s.io/randfill v1.0.0 // indirect sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect diff --git a/go.sum b/go.sum index 885e1163d..6b8e23540 100644 --- a/go.sum +++ b/go.sum @@ -98,8 +98,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kubernetes-csi/csi-lib-utils v0.22.0 h1:EUAs1+uHGps3OtVj4XVx16urhpI02eu+Z8Vps6plpHY= -github.com/kubernetes-csi/csi-lib-utils v0.22.0/go.mod h1:f+PalKyS4Ujsjb9+m6Rj0W6c28y3nfea3paQ/VqjI28= +github.com/kubernetes-csi/csi-lib-utils v0.23.0 h1:070SC4ubEvJpQak0ibxgv7l5dUoDVdqKyktam6zkm4s= +github.com/kubernetes-csi/csi-lib-utils v0.23.0/go.mod h1:H5+JRXAvb7lpC4nrddI7sfQfaXA1O8Tek3uNrTIx1/g= github.com/kubernetes-csi/csi-test/v5 v5.4.0 h1:u5DgYNIreSNO2+u4Nq2Wpl+bbakRSjNyxZHmDTAqnYA= github.com/kubernetes-csi/csi-test/v5 v5.4.0/go.mod h1:anAJKFUb/SdHhIHECgSKxC5LSiLzib+1I6mrWF5Hve8= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= @@ -307,8 +307,8 @@ k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b h1:MloQ9/bdJyIu9lb1PzujOP k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b/go.mod h1:UZ2yyWbFTpuhSbFhv24aGNOdoRdJZgsIObGBUaYVsts= k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 h1:hwvWFiBzdWw1FhfY1FooPn3kzWuJ8tmbZBHi4zVsl1Y= k8s.io/utils v0.0.0-20250604170112-4c0f3b243397/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 h1:jpcvIRr3GLoUoEKRkHKSmGjxb6lWwrBlJsXc+eUYQHM= -sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= +sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.34.0 h1:hSfpvjjTQXQY2Fol2CS0QHMNs/WI1MOSGzCm1KhM5ec= +sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.34.0/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE= sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= diff --git a/vendor/github.com/kubernetes-csi/csi-lib-utils/leaderelection/leader_election.go b/vendor/github.com/kubernetes-csi/csi-lib-utils/leaderelection/leader_election.go index 4045127c5..b67de54f0 100644 --- a/vendor/github.com/kubernetes-csi/csi-lib-utils/leaderelection/leader_election.go +++ b/vendor/github.com/kubernetes-csi/csi-lib-utils/leaderelection/leader_election.go @@ -25,10 +25,12 @@ import ( "strings" "time" + "github.com/kubernetes-csi/csi-lib-utils/standardflags" v1 "k8s.io/api/core/v1" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" corev1 "k8s.io/client-go/kubernetes/typed/core/v1" + "k8s.io/client-go/rest" "k8s.io/client-go/tools/leaderelection" "k8s.io/client-go/tools/leaderelection/resourcelock" "k8s.io/client-go/tools/record" @@ -77,6 +79,8 @@ type leaderElection struct { ctx context.Context clientset kubernetes.Interface + + labels map[string]string } // NewLeaderElection returns the default & preferred leader election type @@ -122,6 +126,11 @@ func (l *leaderElection) WithReleaseOnCancel(releaseOnCancel bool) { l.releaseOnCancel = releaseOnCancel } +// WithLabels adds labels to the lease object when this instance becomes leader +func (l *leaderElection) WithLabels(labels map[string]string) { + l.labels = labels +} + // WithContext Add context func (l *leaderElection) WithContext(ctx context.Context) { l.ctx = ctx @@ -176,8 +185,7 @@ func (l *leaderElection) Run() error { Identity: sanitizeName(l.identity), EventRecorder: eventRecorder, } - - lock, err := resourcelock.New(l.resourceLock, l.namespace, sanitizeName(l.lockName), l.clientset.CoreV1(), l.clientset.CoordinationV1(), rlConfig) + lock, err := resourcelock.NewWithLabels(l.resourceLock, l.namespace, sanitizeName(l.lockName), l.clientset.CoreV1(), l.clientset.CoordinationV1(), rlConfig, l.labels) if err != nil { return err } @@ -209,6 +217,58 @@ func (l *leaderElection) Run() error { return nil // should never reach here } +func RunWithLeaderElection( + ctx context.Context, + config *rest.Config, + opts standardflags.SidecarConfiguration, + run func(context.Context), + driverName string, + mux *http.ServeMux, + releaseOnExit bool) { + + logger := klog.FromContext(ctx) + + if !opts.LeaderElection { + run(ctx) + } else { + // Create a new clientset for leader election. When the attacher + // gets busy and its client gets throttled, the leader election + // can proceed without issues. + leClientset, err := kubernetes.NewForConfig(config) + if err != nil { + logger.Error(err, "Failed to create leaderelection client") + klog.FlushAndExit(klog.ExitFlushTimeout, 1) + } + + // Name of config map with leader election lock + le := NewLeaderElection(leClientset, driverName, run) + if opts.HttpEndpoint != "" { + le.PrepareHealthCheck(mux, DefaultHealthCheckTimeout) + } + + if opts.LeaderElectionNamespace != "" { + le.WithNamespace(opts.LeaderElectionNamespace) + } + + if opts.LeaderElectionLabels != nil { + le.WithLabels(opts.LeaderElectionLabels) + } + + le.WithLeaseDuration(opts.LeaderElectionLeaseDuration) + le.WithRenewDeadline(opts.LeaderElectionRenewDeadline) + le.WithRetryPeriod(opts.LeaderElectionRetryPeriod) + if releaseOnExit { + le.WithReleaseOnCancel(true) + le.WithContext(ctx) + } + + if err := le.Run(); err != nil { + logger.Error(err, "Failed to initialize leader election") + klog.FlushAndExit(klog.ExitFlushTimeout, 1) + } + } +} + func defaultLeaderElectionIdentity() (string, error) { return os.Hostname() } diff --git a/vendor/github.com/kubernetes-csi/csi-lib-utils/standardflags/flags.go b/vendor/github.com/kubernetes-csi/csi-lib-utils/standardflags/flags.go new file mode 100644 index 000000000..54a2d12e3 --- /dev/null +++ b/vendor/github.com/kubernetes-csi/csi-lib-utils/standardflags/flags.go @@ -0,0 +1,83 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package standardflags + +import ( + "flag" + "fmt" + "strings" + "time" +) + +type SidecarConfiguration struct { + ShowVersion bool + + KubeConfig string + CSIAddress string + + LeaderElection bool + LeaderElectionNamespace string + LeaderElectionLeaseDuration time.Duration + LeaderElectionRenewDeadline time.Duration + LeaderElectionRetryPeriod time.Duration + LeaderElectionLabels stringMap + + KubeAPIQPS float64 + KubeAPIBurst int + + HttpEndpoint string + MetricsAddress string + MetricsPath string +} + +var Configuration = SidecarConfiguration{} + +func RegisterCommonFlags(flags *flag.FlagSet) { + flags.BoolVar(&Configuration.ShowVersion, "version", false, "Show version.") + flags.StringVar(&Configuration.KubeConfig, "kubeconfig", "", "Absolute path to the kubeconfig file. Required only when running out of cluster.") + flags.StringVar(&Configuration.CSIAddress, "csi-address", "/run/csi/socket", "The gRPC endpoint for Target CSI Volume.") + flags.BoolVar(&Configuration.LeaderElection, "leader-election", false, "Enable leader election.") + flags.StringVar(&Configuration.LeaderElectionNamespace, "leader-election-namespace", "", "Namespace where the leader election resource lives. Defaults to the pod namespace if not set.") + flags.DurationVar(&Configuration.LeaderElectionLeaseDuration, "leader-election-lease-duration", 15*time.Second, "Duration, in seconds, that non-leader candidates will wait to force acquire leadership. Defaults to 15 seconds.") + flags.DurationVar(&Configuration.LeaderElectionRenewDeadline, "leader-election-renew-deadline", 10*time.Second, "Duration, in seconds, that the acting leader will retry refreshing leadership before giving up. Defaults to 10 seconds.") + flags.DurationVar(&Configuration.LeaderElectionRetryPeriod, "leader-election-retry-period", 5*time.Second, "Duration, in seconds, the LeaderElector clients should wait between tries of actions. Defaults to 5 seconds.") + flags.Var(&Configuration.LeaderElectionLabels, "leader-election-labels", "List of labels to add to lease when given replica becomes leader. Formatted as a comma seperated list of key:value labels. Example: 'my-label:my-value,my-second-label:my-second-value'") + flags.Float64Var(&Configuration.KubeAPIQPS, "kube-api-qps", 5, "QPS to use while communicating with the kubernetes apiserver. Defaults to 5.0.") + flags.IntVar(&Configuration.KubeAPIBurst, "kube-api-burst", 10, "Burst to use while communicating with the kubernetes apiserver. Defaults to 10.") + flags.StringVar(&Configuration.HttpEndpoint, "http-endpoint", "", "The TCP network address where the HTTP server for diagnostics, including metrics and leader election health check, will listen (example: `:8080`). The default is empty string, which means the server is disabled. Only one of `--metrics-address` and `--http-endpoint` can be set.") + flags.StringVar(&Configuration.MetricsAddress, "metrics-address", "", "(deprecated) The TCP network address where the prometheus metrics endpoint will listen (example: `:8080`). The default is empty string, which means metrics endpoint is disabled. Only one of `--metrics-address` and `--http-endpoint` can be set.") + flag.StringVar(&Configuration.MetricsPath, "metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`.") +} + +type stringMap map[string]string + +func (sm *stringMap) String() string { + return fmt.Sprintf("%s", *sm) +} + +func (sm *stringMap) Set(value string) error { + outMap := *sm + items := strings.Split(value, ",") + for _, i := range items { + label := strings.Split(i, ":") + if len(label) != 2 { + return fmt.Errorf("malformed item in list of labels: %s", i) + } + outMap[label[0]] = label[1] + } + return nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 957838a00..d7c21df0a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -143,8 +143,8 @@ github.com/josharian/intern # github.com/json-iterator/go v1.1.12 ## explicit; go 1.12 github.com/json-iterator/go -# github.com/kubernetes-csi/csi-lib-utils v0.22.0 -## explicit; go 1.24.0 +# github.com/kubernetes-csi/csi-lib-utils v0.23.0 +## explicit; go 1.24.6 github.com/kubernetes-csi/csi-lib-utils/connection github.com/kubernetes-csi/csi-lib-utils/leaderelection github.com/kubernetes-csi/csi-lib-utils/metrics @@ -542,7 +542,7 @@ gopkg.in/inf.v0 # gopkg.in/yaml.v3 v3.0.1 ## explicit gopkg.in/yaml.v3 -# k8s.io/api v0.34.0 => k8s.io/api v0.34.0 +# k8s.io/api v0.34.1 => k8s.io/api v0.34.0 ## explicit; go 1.24.0 k8s.io/api/admission/v1 k8s.io/api/admission/v1beta1 @@ -609,7 +609,7 @@ k8s.io/api/storagemigration/v1alpha1 k8s.io/apiextensions-apiserver/pkg/apis/apiextensions k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1 k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1 -# k8s.io/apimachinery v0.34.0 => k8s.io/apimachinery v0.34.0 +# k8s.io/apimachinery v0.34.1 => k8s.io/apimachinery v0.34.0 ## explicit; go 1.24.0 k8s.io/apimachinery/pkg/api/equality k8s.io/apimachinery/pkg/api/errors @@ -810,7 +810,7 @@ k8s.io/apiserver/pkg/util/x509metrics k8s.io/apiserver/pkg/validation k8s.io/apiserver/pkg/warning k8s.io/apiserver/plugin/pkg/authenticator/token/webhook -# k8s.io/client-go v0.34.0 => k8s.io/client-go v0.34.0 +# k8s.io/client-go v0.34.1 => k8s.io/client-go v0.34.0 ## explicit; go 1.24.0 k8s.io/client-go/applyconfigurations k8s.io/client-go/applyconfigurations/admissionregistration/v1 @@ -1147,7 +1147,7 @@ k8s.io/client-go/util/homedir k8s.io/client-go/util/keyutil k8s.io/client-go/util/retry k8s.io/client-go/util/workqueue -# k8s.io/component-base v0.34.0 => k8s.io/component-base v0.34.0 +# k8s.io/component-base v0.34.1 => k8s.io/component-base v0.34.0 ## explicit; go 1.24.0 k8s.io/component-base/cli/flag k8s.io/component-base/compatibility @@ -1223,7 +1223,7 @@ k8s.io/utils/net k8s.io/utils/path k8s.io/utils/ptr k8s.io/utils/trace -# sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 +# sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.34.0 ## explicit; go 1.21 sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/client sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/client/metrics diff --git a/vendor/sigs.k8s.io/apiserver-network-proxy/konnectivity-client/proto/client/client.pb.go b/vendor/sigs.k8s.io/apiserver-network-proxy/konnectivity-client/proto/client/client.pb.go index 0831f3e63..b94c40e43 100644 --- a/vendor/sigs.k8s.io/apiserver-network-proxy/konnectivity-client/proto/client/client.pb.go +++ b/vendor/sigs.k8s.io/apiserver-network-proxy/konnectivity-client/proto/client/client.pb.go @@ -102,7 +102,6 @@ type Packet struct { Type PacketType `protobuf:"varint,1,opt,name=type,proto3,enum=PacketType" json:"type,omitempty"` // Types that are assignable to Payload: - // // *Packet_DialRequest // *Packet_DialResponse // *Packet_Data