Skip to content

Commit 6761111

Browse files
committed
Bump csi-lib-utils to v0.9.0
1 parent 7efebbe commit 6761111

File tree

22 files changed

+140
-1877
lines changed

22 files changed

+140
-1877
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ Read more about how to install the example webhook [here](deploy/kubernetes/webh
106106

107107
* `--leader-election-namespace <namespace>`: The namespace where the leader election resource exists. Defaults to the pod namespace if not set.
108108

109-
* `--metrics-address`: The TCP network address where the prometheus metrics endpoint will run (example: `:8080` which corresponds to port 8080 on local host). The default is empty string, which means metrics endpoint is disabled.
109+
* `--http-endpoint`: The TCP network address where the HTTP server for diagnostics, including metrics and leader election health check, will listen (example: `:8080` which corresponds to port 8080 on local host). The default is empty string, which means the server is disabled.
110+
111+
* `--metrics-address`: (deprecated) The TCP network address where the prometheus metrics endpoint will run (example: `:8080` which corresponds to port 8080 on local host). The default is empty string, which means metrics endpoint is disabled.
110112

111113
* `--metrics-path`: The HTTP path where prometheus metrics will be exposed. Default is `/metrics`.
112114

@@ -147,6 +149,13 @@ Read more about how to install the example webhook [here](deploy/kubernetes/webh
147149

148150
* All glog / klog arguments are supported, such as `-v <log level>` or `-alsologtostderr`.
149151

152+
#### HTTP endpoint
153+
154+
The external-snapshotter optionally exposes an HTTP endpoint at address:port specified by `--http-endpoint` argument. When set, these two paths are exposed:
155+
156+
* Metrics path, as set by `--metrics-path` argument (default is `/metrics`).
157+
158+
* Leader election health check at `/healthz/leader-election`. It is recommended to run a liveness probe against this endpoint when leader election is used to kill external-provisioner leader that fails to connect to the API server to renew its leadership. See https://github.com/kubernetes-csi/csi-lib-utils/issues/66 for details.
150159

151160
## Upgrade from v1alpha1 to v1beta1
152161

cmd/csi-snapshotter/main.go

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"flag"
2222
"fmt"
23+
"net/http"
2324
"os"
2425
"os/signal"
2526
"strings"
@@ -67,7 +68,8 @@ var (
6768
leaderElection = flag.Bool("leader-election", false, "Enables leader election.")
6869
leaderElectionNamespace = flag.String("leader-election-namespace", "", "The namespace where the leader election resource exists. Defaults to the pod namespace if not set.")
6970

70-
metricsAddress = flag.String("metrics-address", "", "The TCP network address where the prometheus metrics endpoint will listen (example: `:8080`). The default is empty string, which means metrics endpoint is disabled.")
71+
metricsAddress = flag.String("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.")
72+
httpEndpoint = flag.String("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.")
7173
metricsPath = flag.String("metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`.")
7274
)
7375

@@ -112,6 +114,15 @@ func main() {
112114
// Add Snapshot types to the default Kubernetes so events can be logged for them
113115
snapshotscheme.AddToScheme(scheme.Scheme)
114116

117+
if *metricsAddress != "" && *httpEndpoint != "" {
118+
klog.Error("only one of `--metrics-address` and `--http-endpoint` can be set.")
119+
os.Exit(1)
120+
}
121+
addr := *metricsAddress
122+
if addr == "" {
123+
addr = *httpEndpoint
124+
}
125+
115126
// Connect to CSI.
116127
metricsManager := metrics.NewCSIMetricsManager("" /* driverName */)
117128
csiConn, err := connection.Connect(
@@ -135,8 +146,20 @@ func main() {
135146
}
136147

137148
klog.V(2).Infof("CSI driver name: %q", driverName)
138-
metricsManager.SetDriverName(driverName)
139-
metricsManager.StartMetricsEndpoint(*metricsAddress, *metricsPath)
149+
150+
// Prepare http endpoint for metrics + leader election healthz
151+
mux := http.NewServeMux()
152+
if addr != "" {
153+
metricsManager.RegisterToServer(mux, *metricsPath)
154+
metricsManager.SetDriverName(driverName)
155+
go func() {
156+
klog.Infof("ServeMux listening at %q", addr)
157+
err := http.ListenAndServe(*metricsAddress, mux)
158+
if err != nil {
159+
klog.Fatalf("Failed to start HTTP server at specified address (%q) and metrics path (%q): %s", addr, *metricsPath, err)
160+
}
161+
}()
162+
}
140163

141164
// Check it's ready
142165
if err = csirpc.ProbeForever(csiConn, *csiTimeout); err != nil {
@@ -202,6 +225,10 @@ func main() {
202225
klog.Fatalf("failed to create leaderelection client: %v", err)
203226
}
204227
le := leaderelection.NewLeaderElection(leClientset, lockName, run)
228+
if *httpEndpoint != "" {
229+
le.PrepareHealthCheck(mux, leaderelection.DefaultHealthCheckTimeout)
230+
}
231+
205232
if *leaderElectionNamespace != "" {
206233
le.WithNamespace(*leaderElectionNamespace)
207234
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/golang/protobuf v1.4.2
1010
github.com/google/gofuzz v1.1.0
1111
github.com/imdario/mergo v0.3.9 // indirect
12-
github.com/kubernetes-csi/csi-lib-utils v0.8.1
12+
github.com/kubernetes-csi/csi-lib-utils v0.9.0
1313
github.com/kubernetes-csi/csi-test v2.0.0+incompatible
1414
github.com/kubernetes-csi/external-snapshotter/client/v3 v3.0.0
1515
github.com/prometheus/client_golang v1.7.1

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
329329
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
330330
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
331331
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
332-
github.com/kubernetes-csi/csi-lib-utils v0.8.1 h1:DHFs4MgzjSGF/FH95TEdLVa7R1CCi9UJ76jTUPO8iF0=
333-
github.com/kubernetes-csi/csi-lib-utils v0.8.1/go.mod h1:FZflf0cCYlCquPQxVHa6Tyy0i/so6VAZTiEVK1do7CU=
332+
github.com/kubernetes-csi/csi-lib-utils v0.9.0 h1:TbuDmxoVqM+fvVkzG/7sShyX/8jUln0ElLHuETcsQJI=
333+
github.com/kubernetes-csi/csi-lib-utils v0.9.0/go.mod h1:8E2jVUX9j3QgspwHXa6LwyN7IHQDjW9jX3kwoWnSC+M=
334334
github.com/kubernetes-csi/csi-test v2.0.0+incompatible h1:ia04uVFUM/J9n/v3LEMn3rEG6FmKV5BH9QLw7H68h44=
335335
github.com/kubernetes-csi/csi-test v2.0.0+incompatible/go.mod h1:YxJ4UiuPWIhMBkxUKY5c267DyA0uDZ/MtAimhx/2TA0=
336336
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
@@ -784,8 +784,6 @@ k8s.io/csi-translation-lib v0.19.0/go.mod h1:zGS1YqV8U2So/t4Hz8SoRXMx5y5/KSKnA6B
784784
k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
785785
k8s.io/gengo v0.0.0-20200428234225-8167cfdcfc14/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
786786
k8s.io/heapster v1.2.0-beta.1/go.mod h1:h1uhptVXMwC8xtZBYsPXKVi8fpdlYkTs6k949KozGrM=
787-
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
788-
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
789787
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
790788
k8s.io/klog/v2 v2.2.0 h1:XRvcwJozkgZ1UQJmfMGpvRthQHOvihEhYtDfAaxMz/A=
791789
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=

pkg/validation-webhook/certwatcher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"sync"
2323

2424
"github.com/fsnotify/fsnotify"
25-
"k8s.io/klog"
25+
"k8s.io/klog/v2"
2626
)
2727

2828
// This file originated from github.com/kubernetes-sigs/controller-runtime/pkg/webhook/internal/certwatcher.

vendor/github.com/kubernetes-csi/csi-lib-utils/connection/connection.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/kubernetes-csi/csi-lib-utils/leaderelection/leader_election.go

Lines changed: 47 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/kubernetes-csi/csi-lib-utils/metrics/metrics.go

Lines changed: 46 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/kubernetes-csi/csi-lib-utils/rpc/common.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/k8s.io/klog/.travis.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)