Skip to content

Commit 52ab893

Browse files
Merge pull request kubernetes-csi#56 from bertinatto/merge-v4.2.0
Bug 1993934: Merge upstream v4.2.0
2 parents 390bd9e + c8a3a65 commit 52ab893

File tree

743 files changed

+27369
-20837
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

743 files changed

+27369
-20837
lines changed

.travis.yml

-1
This file was deleted.

CHANGELOG/CHANGELOG-4.2.md

+247
Large diffs are not rendered by default.

OWNERS_ALIASES

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ aliases:
44
- tsmetana
55
- gnufied
66
- bertinatto
7-
- huffmanca
7+
- dobsonj

README.md

+25-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
[![Build Status](https://travis-ci.org/kubernetes-csi/external-snapshotter.svg?branch=master)](https://travis-ci.org/kubernetes-csi/external-snapshotter)
2-
31
# CSI Snapshotter
42

53
The CSI snapshotter is part of Kubernetes implementation of [Container Storage Interface (CSI)](https://github.com/container-storage-interface/spec).
64

7-
The volume snapshot feature supports CSI v1.0 and higher. It was introduced as an Alpha feature in Kubernetes v1.12 and has been promoted to an Beta feature in Kubernetes 1.17. In Kubernetes 1.20, the volume snapshot feature moves to GA.
5+
The volume snapshot feature supports CSI v1.0 and higher. It was introduced as an Alpha feature in Kubernetes v1.12 and has been promoted to a Beta feature in Kubernetes 1.17. In Kubernetes 1.20, the volume snapshot feature moves to GA.
86

97
> :warning: **WARNING**: There is a new validating webhook server which provides tightened validation on snapshot objects. This SHOULD be installed by all users of this feature. More details [below](#validating-webhook).
108
@@ -22,9 +20,9 @@ This information reflects the head of this branch.
2220

2321
| Minimum CSI Version | Recommended CSI Version | Container Image | [Min K8s Version](https://kubernetes-csi.github.io/docs/kubernetes-compatibility.html#minimum-version) | [Recommended K8s Version](https://kubernetes-csi.github.io/docs/project-policies.html#recommended-version) |
2422
| ------------------------------------------------------------------------------------------ | ----------------------------| --------------- | --------------- | --------------- |
25-
| [CSI Spec v1.0.0](https://github.com/container-storage-interface/spec/releases/tag/v1.0.0) | [CSI Spec v1.4.0](https://github.com/container-storage-interface/spec/releases/tag/v1.4.0) | k8s.gcr.io/sig-storage/csi-snapshotter | 1.20 | 1.20 |
26-
| [CSI Spec v1.0.0](https://github.com/container-storage-interface/spec/releases/tag/v1.0.0) | [CSI Spec v1.4.0](https://github.com/container-storage-interface/spec/releases/tag/v1.4.0) | k8s.gcr.io/sig-storage/snapshot-controller | 1.20 | 1.20 |
27-
| [CSI Spec v1.0.0](https://github.com/container-storage-interface/spec/releases/tag/v1.0.0) | [CSI Spec v1.4.0](https://github.com/container-storage-interface/spec/releases/tag/v1.4.0) | k8s.gcr.io/sig-storage/snapshot-validation-webhook | 1.20 | 1.20 |
23+
| [CSI Spec v1.0.0](https://github.com/container-storage-interface/spec/releases/tag/v1.0.0) | [CSI Spec v1.5.0](https://github.com/container-storage-interface/spec/releases/tag/v1.5.0) | k8s.gcr.io/sig-storage/csi-snapshotter | 1.20 | 1.20 |
24+
| [CSI Spec v1.0.0](https://github.com/container-storage-interface/spec/releases/tag/v1.0.0) | [CSI Spec v1.5.0](https://github.com/container-storage-interface/spec/releases/tag/v1.5.0) | k8s.gcr.io/sig-storage/snapshot-controller | 1.20 | 1.20 |
25+
| [CSI Spec v1.0.0](https://github.com/container-storage-interface/spec/releases/tag/v1.0.0) | [CSI Spec v1.5.0](https://github.com/container-storage-interface/spec/releases/tag/v1.5.0) | k8s.gcr.io/sig-storage/snapshot-validation-webhook | 1.20 | 1.20 |
2826

2927
Note: snapshot-controller, snapshot-validation-webhook, csi-snapshotter v4.1 requires v1 snapshot CRDs to be installed, but it serves both v1 and v1beta1 snapshot objects. Storage version is changed from v1beta1 to v1 in 4.1.0 so v1beta1 is deprecated and will be removed in a future release.
3028

@@ -63,7 +61,7 @@ If your Kubernetes distribution does not bundle the snapshot controller, you may
6361

6462
There is a new validating webhook server which provides tightened validation on snapshot objects. The cluster admin or Kubernetes distribution admin should install the webhook alongside the snapshot controllers and CRDs. More details [below](#validating-webhook).
6563

66-
Install Snapshot Beta CRDs:
64+
Install Snapshot CRDs:
6765
* kubectl create -f client/config/crd
6866
* https://github.com/kubernetes-csi/external-snapshotter/tree/master/client/config/crd
6967
* Do this once per cluster
@@ -96,7 +94,7 @@ If there are no existing invalid v1beta1 objects, after upgrading to v1, the web
9694

9795
If there are existing invalid v1beta1 objects, the user should make sure that the snapshot controller is upgraded to v3.0.0 or higher (v3.0.3 is the latest recommended v3.0.x release) and install the corresponding validation webhook before upgrading to v1 so that those invalid objects will be labeled and can be identified easily and removed before upgrading to v1.
9896

99-
If there are existing invalid v1beta1 objects and the user didn't upgrade to the snapshot controller 3.0.0 or higher and install the corresponding validation webhook before upgrading to v1, those existing invalid v1beta1 objects will not be labeled by the snapshot controller.
97+
If there are existing invalid v1beta1 objects, and the user didn't upgrade to the snapshot controller 3.0.0 or higher and install the corresponding validation webhook before upgrading to v1, those existing invalid v1beta1 objects will not be labeled by the snapshot controller.
10098

10199
So the recommendation is that before upgrading to v1 CRDs and upgrading snapshot controller and validation webhook to v4.0, the user should upgrade to the snapshot controller 3.0.0 and higher (v3.0.3 is the latest recommended version for 3.0.x) and install the corresponding validation webhook so that all existing invalid objects will be labeled and can be easily identified and deleted.
102100

@@ -119,14 +117,22 @@ Read more about how to install the example webhook [here](deploy/kubernetes/webh
119117

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

122-
* `--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.
120+
* `--leader-election-lease-duration <duration>`: Duration, in seconds, that non-leader candidates will wait to force acquire leadership. Defaults to 15 seconds.
121+
122+
* `--leader-election-renew-deadline <duration>`: Duration, in seconds, that the acting leader will retry refreshing leadership before giving up. Defaults to 10 seconds.
123123

124-
* `--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.
124+
* `--leader-election-retry-period <duration>`: Duration, in seconds, the LeaderElector clients should wait between tries of actions. Defaults to 5 seconds.
125+
126+
* `--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.
125127

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

128130
* `--worker-threads`: Number of worker threads. Default value is 10.
129131

132+
* `--retry-interval-start`: Initial retry interval of failed volume snapshot creation or deletion. It doubles with each failure, up to retry-interval-max. Default value is 1 second.
133+
134+
*`--retry-interval-max`: Maximum retry interval of failed volume snapshot creation or deletion. Default value is 5 minutes.
135+
130136
#### Other recognized arguments
131137
* `--kubeconfig <path>`: Path to Kubernetes client configuration that the snapshot controller uses to connect to Kubernetes API server. When omitted, default token provided by Kubernetes will be used. This option is useful only when the snapshot controller does not run as a Kubernetes pod, e.g. for debugging.
132138

@@ -145,6 +151,12 @@ Read more about how to install the example webhook [here](deploy/kubernetes/webh
145151

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

154+
* `--leader-election-lease-duration <duration>`: Duration, in seconds, that non-leader candidates will wait to force acquire leadership. Defaults to 15 seconds.
155+
156+
* `--leader-election-renew-deadline <duration>`: Duration, in seconds, that the acting leader will retry refreshing leadership before giving up. Defaults to 10 seconds.
157+
158+
* `--leader-election-retry-period <duration>`: Duration, in seconds, the LeaderElector clients should wait between tries of actions. Defaults to 5 seconds.
159+
148160
* `--timeout <duration>`: Timeout of all calls to CSI driver. It should be set to value that accommodates majority of `CreateSnapshot`, `DeleteSnapshot`, and `ListSnapshots` calls. 1 minute is used by default.
149161

150162
* `snapshot-name-prefix`: Prefix to apply to the name of a created snapshot. Default is `snapshot`.
@@ -153,6 +165,9 @@ Read more about how to install the example webhook [here](deploy/kubernetes/webh
153165

154166
* `--worker-threads`: Number of worker threads for running create snapshot and delete snapshot operations. Default value is 10.
155167

168+
* `--retry-interval-start`: Initial retry interval of failed volume snapshot creation or deletion. It doubles with each failure, up to retry-interval-max. Default value is 1 second.
169+
170+
*`--retry-interval-max`: Maximum retry interval of failed volume snapshot creation or deletion. Default value is 5 minutes.
156171
#### Other recognized arguments
157172
* `--kubeconfig <path>`: Path to Kubernetes client configuration that the CSI external-snapshotter uses to connect to Kubernetes API server. When omitted, default token provided by Kubernetes will be used. This option is useful only when the external-snapshotter does not run as a Kubernetes pod, e.g. for debugging.
158173

client/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ spec:
4242
jsonPath: .spec.volumeSnapshotRef.name
4343
name: VolumeSnapshot
4444
type: string
45+
- description: Namespace of the VolumeSnapshot object to which this VolumeSnapshotContent object is bound.
46+
jsonPath: .spec.volumeSnapshotRef.namespace
47+
name: VolumeSnapshotNamespace
48+
type: string
4549
- jsonPath: .metadata.creationTimestamp
4650
name: Age
4751
type: date
@@ -177,6 +181,10 @@ spec:
177181
jsonPath: .spec.volumeSnapshotRef.name
178182
name: VolumeSnapshot
179183
type: string
184+
- description: Namespace of the VolumeSnapshot object to which this VolumeSnapshotContent object is bound.
185+
jsonPath: .spec.volumeSnapshotRef.namespace
186+
name: VolumeSnapshotNamespace
187+
type: string
180188
- jsonPath: .metadata.creationTimestamp
181189
name: Age
182190
type: date

cmd/csi-snapshotter/main.go

+19-7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"k8s.io/client-go/kubernetes/scheme"
3333
"k8s.io/client-go/rest"
3434
"k8s.io/client-go/tools/clientcmd"
35+
"k8s.io/client-go/util/workqueue"
3536
klog "k8s.io/klog/v2"
3637

3738
"github.com/container-storage-interface/spec/lib/go/csi"
@@ -57,20 +58,25 @@ const (
5758
var (
5859
kubeconfig = flag.String("kubeconfig", "", "Absolute path to the kubeconfig file. Required only when running out of cluster.")
5960
csiAddress = flag.String("csi-address", "/run/csi/socket", "Address of the CSI driver socket.")
60-
resyncPeriod = flag.Duration("resync-period", 15*time.Minute, "Resync interval of the controller.")
61+
resyncPeriod = flag.Duration("resync-period", 15*time.Minute, "Resync interval of the controller. Default is 15 minutes")
6162
snapshotNamePrefix = flag.String("snapshot-name-prefix", "snapshot", "Prefix to apply to the name of a created snapshot")
6263
snapshotNameUUIDLength = flag.Int("snapshot-name-uuid-length", -1, "Length in characters for the generated uuid of a created snapshot. Defaults behavior is to NOT truncate.")
6364
showVersion = flag.Bool("version", false, "Show version.")
6465
threads = flag.Int("worker-threads", 10, "Number of worker threads.")
6566
csiTimeout = flag.Duration("timeout", defaultCSITimeout, "The timeout for any RPCs to the CSI driver. Default is 1 minute.")
6667
extraCreateMetadata = flag.Bool("extra-create-metadata", false, "If set, add snapshot metadata to plugin snapshot requests as parameters.")
6768

68-
leaderElection = flag.Bool("leader-election", false, "Enables leader election.")
69-
leaderElectionNamespace = flag.String("leader-election-namespace", "", "The namespace where the leader election resource exists. Defaults to the pod namespace if not set.")
70-
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.")
73-
metricsPath = flag.String("metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`.")
69+
leaderElection = flag.Bool("leader-election", false, "Enables leader election.")
70+
leaderElectionNamespace = flag.String("leader-election-namespace", "", "The namespace where the leader election resource exists. Defaults to the pod namespace if not set.")
71+
leaderElectionLeaseDuration = flag.Duration("leader-election-lease-duration", 15*time.Second, "Duration, in seconds, that non-leader candidates will wait to force acquire leadership. Defaults to 15 seconds.")
72+
leaderElectionRenewDeadline = flag.Duration("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.")
73+
leaderElectionRetryPeriod = flag.Duration("leader-election-retry-period", 5*time.Second, "Duration, in seconds, the LeaderElector clients should wait between tries of actions. Defaults to 5 seconds.")
74+
75+
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.")
76+
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.")
77+
metricsPath = flag.String("metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`.")
78+
retryIntervalStart = flag.Duration("retry-interval-start", time.Second, "Initial retry interval of failed volume snapshot creation or deletion. It doubles with each failure, up to retry-interval-max. Default is 1 second.")
79+
retryIntervalMax = flag.Duration("retry-interval-max", 5*time.Minute, "Maximum retry interval of failed volume snapshot creation or deletion. Default is 5 minutes.")
7480
)
7581

7682
var (
@@ -198,6 +204,7 @@ func main() {
198204
*snapshotNamePrefix,
199205
*snapshotNameUUIDLength,
200206
*extraCreateMetadata,
207+
workqueue.NewItemExponentialFailureRateLimiter(*retryIntervalStart, *retryIntervalMax),
201208
)
202209

203210
run := func(context.Context) {
@@ -232,6 +239,11 @@ func main() {
232239
if *leaderElectionNamespace != "" {
233240
le.WithNamespace(*leaderElectionNamespace)
234241
}
242+
243+
le.WithLeaseDuration(*leaderElectionLeaseDuration)
244+
le.WithRenewDeadline(*leaderElectionRenewDeadline)
245+
le.WithRetryPeriod(*leaderElectionRetryPeriod)
246+
235247
if err := le.Run(); err != nil {
236248
klog.Fatalf("failed to initialize leader election: %v", err)
237249
}

0 commit comments

Comments
 (0)