Skip to content

Commit bf2ed74

Browse files
authored
Merge pull request #1337 from leonardoce/dev-api-review
Deprecate VolumeGroupSnapshot v1beta1, address API review comments
2 parents 5e23337 + 0d9a187 commit bf2ed74

File tree

34 files changed

+381
-45
lines changed

34 files changed

+381
-45
lines changed

client/apis/volumegroupsnapshot/v1beta1/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ type VolumeGroupSnapshotStatus struct {
119119
// +kubebuilder:object:root=true
120120
// +kubebuilder:resource:scope=Namespaced,shortName=vgs
121121
// +kubebuilder:subresource:status
122+
// +kubebuilder:deprecatedversion
122123
// +kubebuilder:printcolumn:name="ReadyToUse",type=boolean,JSONPath=`.status.readyToUse`,description="Indicates if all the individual snapshots in the group are ready to be used to restore a group of volumes."
123124
// +kubebuilder:printcolumn:name="VolumeGroupSnapshotClass",type=string,JSONPath=`.spec.volumeGroupSnapshotClassName`,description="The name of the VolumeGroupSnapshotClass requested by the VolumeGroupSnapshot."
124125
// +kubebuilder:printcolumn:name="VolumeGroupSnapshotContent",type=string,JSONPath=`.status.boundVolumeGroupSnapshotContentName`,description="Name of the VolumeGroupSnapshotContent object to which the VolumeGroupSnapshot object intends to bind to. Please note that verification of binding actually requires checking both VolumeGroupSnapshot and VolumeGroupSnapshotContent to ensure both are pointing at each other. Binding MUST be verified prior to usage of this object."
@@ -162,6 +163,7 @@ type VolumeGroupSnapshotList struct {
162163
// is used by specifying its name in a VolumeGroupSnapshot object.
163164
// VolumeGroupSnapshotClasses are non-namespaced.
164165
// +kubebuilder:object:root=true
166+
// +kubebuilder:deprecatedversion
165167
// +kubebuilder:resource:scope=Cluster,shortName=vgsclass;vgsclasses
166168
// +kubebuilder:printcolumn:name="Driver",type=string,JSONPath=`.driver`
167169
// +kubebuilder:printcolumn:name="DeletionPolicy",type=string,JSONPath=`.deletionPolicy`,description="Determines whether a VolumeGroupSnapshotContent created through the VolumeGroupSnapshotClass should be deleted when its bound VolumeGroupSnapshot is deleted."
@@ -218,6 +220,7 @@ type VolumeGroupSnapshotClassList struct {
218220
// in the underlying storage system
219221
// +kubebuilder:object:root=true
220222
// +kubebuilder:resource:scope=Cluster,shortName=vgsc;vgscs
223+
// +kubebuilder:deprecatedversion
221224
// +kubebuilder:subresource:status
222225
// +kubebuilder:printcolumn:name="ReadyToUse",type=boolean,JSONPath=`.status.readyToUse`,description="Indicates if all the individual snapshots in the group are ready to be used to restore a group of volumes."
223226
// +kubebuilder:printcolumn:name="DeletionPolicy",type=string,JSONPath=`.spec.deletionPolicy`,description="Determines whether this VolumeGroupSnapshotContent and its physical group snapshot on the underlying storage system should be deleted when its bound VolumeGroupSnapshot is deleted."

client/apis/volumegroupsnapshot/v1beta2/types.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,14 @@ type VolumeGroupSnapshotStatus struct {
8080
// VolumeGroupSnapshot and VolumeGroupSnapshotContent objects is successful
8181
// (by validating that both VolumeGroupSnapshot and VolumeGroupSnapshotContent
8282
// point at each other) before using this object.
83+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="boundVolumeGroupSnapshotContentName is immutable once set"
8384
// +optional
8485
BoundVolumeGroupSnapshotContentName *string `json:"boundVolumeGroupSnapshotContentName,omitempty" protobuf:"bytes,1,opt,name=boundVolumeGroupSnapshotContentName"`
8586

8687
// CreationTime is the timestamp when the point-in-time group snapshot is taken
8788
// by the underlying storage system.
8889
// If not specified, it may indicate that the creation time of the group snapshot
8990
// is unknown.
90-
// The format of this field is a Unix nanoseconds time encoded as an int64.
91-
// On Unix, the command date +%s%N returns the current time in nanoseconds
92-
// since 1970-01-01 00:00:00 UTC.
9391
// This field is updated based on the CreationTime field in VolumeGroupSnapshotContentStatus
9492
// +optional
9593
CreationTime *metav1.Time `json:"creationTime,omitempty" protobuf:"bytes,2,opt,name=creationTime"`
@@ -177,11 +175,13 @@ type VolumeGroupSnapshotClass struct {
177175

178176
// Driver is the name of the storage driver expected to handle this VolumeGroupSnapshotClass.
179177
// Required.
178+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="driver is immutable once set"
180179
Driver string `json:"driver" protobuf:"bytes,2,opt,name=driver"`
181180

182181
// Parameters is a key-value map with storage driver specific parameters for
183182
// creating group snapshots.
184183
// These values are opaque to Kubernetes and are passed directly to the driver.
184+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="parameters are immutable once set"
185185
// +optional
186186
Parameters map[string]string `json:"parameters,omitempty" protobuf:"bytes,3,rep,name=parameters"`
187187

@@ -194,6 +194,7 @@ type VolumeGroupSnapshotClass struct {
194194
// "Delete" means that the VolumeGroupSnapshotContent and its physical group
195195
// snapshot on underlying storage system are deleted.
196196
// Required.
197+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="deletionPolicy is immutable once set"
197198
DeletionPolicy snapshotv1.DeletionPolicy `json:"deletionPolicy" protobuf:"bytes,4,opt,name=deletionPolicy"`
198199
}
199200

@@ -270,6 +271,8 @@ type VolumeGroupSnapshotContentSpec struct {
270271
// This field is immutable after creation.
271272
// Required.
272273
// +kubebuilder:validation:XValidation:rule="has(self.name) && has(self.__namespace__)",message="both volumeGroupSnapshotRef.name and volumeGroupSnapshotRef.namespace must be set"
274+
// +kubebuilder:validation:XValidation:rule="self.name == oldSelf.name && self.__namespace__ == oldSelf.__namespace__",message="volumeGroupSnapshotRef.name and volumeGroupSnapshotRef.namespace are immutable"
275+
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.uid) || (has(self.uid) && self.uid == oldSelf.uid)",message="volumeGroupSnapshotRef.uid is immutable once set"
273276
VolumeGroupSnapshotRef core_v1.ObjectReference `json:"volumeGroupSnapshotRef" protobuf:"bytes,1,opt,name=volumeGroupSnapshotRef"`
274277

275278
// DeletionPolicy determines whether this VolumeGroupSnapshotContent and the
@@ -293,6 +296,7 @@ type VolumeGroupSnapshotContentSpec struct {
293296
// This MUST be the same as the name returned by the CSI GetPluginName() call for
294297
// that driver.
295298
// Required.
299+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="driver is immutable once set"
296300
Driver string `json:"driver" protobuf:"bytes,3,opt,name=driver"`
297301

298302
// VolumeGroupSnapshotClassName is the name of the VolumeGroupSnapshotClass from
@@ -303,6 +307,7 @@ type VolumeGroupSnapshotContentSpec struct {
303307
// For dynamic provisioning, this field must be set.
304308
// This field may be unset for pre-provisioned snapshots.
305309
// +optional
310+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupSnapshotClassName is immutable once set"
306311
VolumeGroupSnapshotClassName *string `json:"volumeGroupSnapshotClassName,omitempty" protobuf:"bytes,4,opt,name=volumeGroupSnapshotClassName"`
307312

308313
// Source specifies whether the snapshot is (or should be) dynamically provisioned
@@ -344,15 +349,13 @@ type VolumeGroupSnapshotContentStatus struct {
344349
// If a storage system does not provide such an id, the
345350
// CSI driver can choose to return the VolumeGroupSnapshot name.
346351
// +optional
352+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="volumeGroupSnapshotHandle is immutable once set"
347353
VolumeGroupSnapshotHandle *string `json:"volumeGroupSnapshotHandle,omitempty" protobuf:"bytes,1,opt,name=volumeGroupSnapshotHandle"`
348354

349355
// CreationTime is the timestamp when the point-in-time group snapshot is taken
350356
// by the underlying storage system.
351357
// If not specified, it indicates the creation time is unknown.
352358
// If not specified, it means the readiness of a group snapshot is unknown.
353-
// The format of this field is a Unix nanoseconds time encoded as an int64.
354-
// On Unix, the command date +%s%N returns the current time in nanoseconds
355-
// since 1970-01-01 00:00:00 UTC.
356359
// This field is the source for the CreationTime field in VolumeGroupSnapshotStatus
357360
// +optional
358361
CreationTime *metav1.Time `json:"creationTime,omitempty" protobuf:"bytes,2,opt,name=creationTime"`

client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotclasses.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/1150"
6+
api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/1337"
77
controller-gen.kubebuilder.io/version: v0.15.0
88
name: volumegroupsnapshotclasses.groupsnapshot.storage.k8s.io
99
spec:
@@ -31,6 +31,7 @@ spec:
3131
- jsonPath: .metadata.creationTimestamp
3232
name: Age
3333
type: date
34+
deprecated: true
3435
name: v1beta1
3536
schema:
3637
openAPIV3Schema:
@@ -136,11 +137,17 @@ spec:
136137
- Delete
137138
- Retain
138139
type: string
140+
x-kubernetes-validations:
141+
- message: deletionPolicy is immutable once set
142+
rule: self == oldSelf
139143
driver:
140144
description: |-
141145
Driver is the name of the storage driver expected to handle this VolumeGroupSnapshotClass.
142146
Required.
143147
type: string
148+
x-kubernetes-validations:
149+
- message: driver is immutable once set
150+
rule: self == oldSelf
144151
kind:
145152
description: |-
146153
Kind is a string value representing the REST resource this object represents.
@@ -159,6 +166,9 @@ spec:
159166
creating group snapshots.
160167
These values are opaque to Kubernetes and are passed directly to the driver.
161168
type: object
169+
x-kubernetes-validations:
170+
- message: parameters are immutable once set
171+
rule: self == oldSelf
162172
required:
163173
- deletionPolicy
164174
- driver

client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/1150"
6+
api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/1337"
77
controller-gen.kubebuilder.io/version: v0.15.0
88
name: volumegroupsnapshotcontents.groupsnapshot.storage.k8s.io
99
spec:
@@ -62,6 +62,7 @@ spec:
6262
- jsonPath: .metadata.creationTimestamp
6363
name: Age
6464
type: date
65+
deprecated: true
6566
name: v1beta1
6667
schema:
6768
openAPIV3Schema:
@@ -423,6 +424,9 @@ spec:
423424
that driver.
424425
Required.
425426
type: string
427+
x-kubernetes-validations:
428+
- message: driver is immutable once set
429+
rule: self == oldSelf
426430
source:
427431
description: |-
428432
Source specifies whether the snapshot is (or should be) dynamically provisioned
@@ -494,6 +498,9 @@ spec:
494498
For dynamic provisioning, this field must be set.
495499
This field may be unset for pre-provisioned snapshots.
496500
type: string
501+
x-kubernetes-validations:
502+
- message: volumeGroupSnapshotClassName is immutable once set
503+
rule: self == oldSelf
497504
volumeGroupSnapshotRef:
498505
description: |-
499506
VolumeGroupSnapshotRef specifies the VolumeGroupSnapshot object to which this
@@ -550,6 +557,11 @@ spec:
550557
- message: both volumeGroupSnapshotRef.name and volumeGroupSnapshotRef.namespace
551558
must be set
552559
rule: has(self.name) && has(self.__namespace__)
560+
- message: volumeGroupSnapshotRef.name and volumeGroupSnapshotRef.namespace
561+
are immutable
562+
rule: self.name == oldSelf.name && self.__namespace__ == oldSelf.__namespace__
563+
- message: volumeGroupSnapshotRef.uid is immutable once set
564+
rule: '!has(oldSelf.uid) || (has(self.uid) && self.uid == oldSelf.uid)'
553565
required:
554566
- deletionPolicy
555567
- driver
@@ -565,9 +577,6 @@ spec:
565577
by the underlying storage system.
566578
If not specified, it indicates the creation time is unknown.
567579
If not specified, it means the readiness of a group snapshot is unknown.
568-
The format of this field is a Unix nanoseconds time encoded as an int64.
569-
On Unix, the command date +%s%N returns the current time in nanoseconds
570-
since 1970-01-01 00:00:00 UTC.
571580
This field is the source for the CreationTime field in VolumeGroupSnapshotStatus
572581
format: date-time
573582
type: string
@@ -601,6 +610,9 @@ spec:
601610
If a storage system does not provide such an id, the
602611
CSI driver can choose to return the VolumeGroupSnapshot name.
603612
type: string
613+
x-kubernetes-validations:
614+
- message: volumeGroupSnapshotHandle is immutable once set
615+
rule: self == oldSelf
604616
volumeSnapshotInfoList:
605617
description: |-
606618
This field is introduced in v1beta2
@@ -623,19 +635,19 @@ spec:
623635
be used to restore a volume.
624636
type: boolean
625637
restoreSize:
626-
description: RestoreSize represents the complete size of the
627-
snapshot in bytes.
638+
description: |-
639+
RestoreSize represents the minimum size of volume required to create a volume
640+
from this snapshot.
628641
format: int64
629642
type: integer
630643
snapshotHandle:
631-
description: |-
632-
SnapshotHandle is a unique id returned by the CSI driver to identify a volume
633-
snapshot on the storage system
644+
description: SnapshotHandle is the CSI "snapshot_id" of this
645+
snapshot on the underlying storage system.
634646
type: string
635647
volumeHandle:
636648
description: |-
637-
VolumeHandle is a unique id returned by the CSI driver to identify a volume
638-
on the storage system
649+
VolumeHandle specifies the CSI "volume_id" of the volume from which this snapshot
650+
was taken from.
639651
type: string
640652
type: object
641653
type: array

client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshots.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/1150"
6+
api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/1337"
77
controller-gen.kubebuilder.io/version: v0.15.0
88
name: volumegroupsnapshots.groupsnapshot.storage.k8s.io
99
spec:
@@ -43,6 +43,7 @@ spec:
4343
- jsonPath: .metadata.creationTimestamp
4444
name: Age
4545
type: date
46+
deprecated: true
4647
name: v1beta1
4748
schema:
4849
openAPIV3Schema:
@@ -409,15 +410,15 @@ spec:
409410
(by validating that both VolumeGroupSnapshot and VolumeGroupSnapshotContent
410411
point at each other) before using this object.
411412
type: string
413+
x-kubernetes-validations:
414+
- message: boundVolumeGroupSnapshotContentName is immutable once set
415+
rule: self == oldSelf
412416
creationTime:
413417
description: |-
414418
CreationTime is the timestamp when the point-in-time group snapshot is taken
415419
by the underlying storage system.
416420
If not specified, it may indicate that the creation time of the group snapshot
417421
is unknown.
418-
The format of this field is a Unix nanoseconds time encoded as an int64.
419-
On Unix, the command date +%s%N returns the current time in nanoseconds
420-
since 1970-01-01 00:00:00 UTC.
421422
This field is updated based on the CreationTime field in VolumeGroupSnapshotContentStatus
422423
format: date-time
423424
type: string

client/hack/README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,9 @@ are correctly working.
121121
```
122122
./hack/run-cel-tests.sh
123123
124-
cel-tests/volumegroupsnapshotcontent/vgsc-change-ref-namespace.post.yaml: SUCCESS
125-
cel-tests/volumegroupsnapshotcontent/vgsc-source-volume-to-groupsnapshot.post.yaml: SUCCESS
126-
cel-tests/volumegroupsnapshotcontent/vgsc-source-empty.yaml: SUCCESS (expected failure)
127-
cel-tests/volumegroupsnapshotcontent/vgsc-change-ref-namespace.pre.yaml: SUCCESS
128-
cel-tests/volumegroupsnapshotcontent/vgsc-ref-only-name.yaml: SUCCESS (expected failure)
129-
[...]
130-
cel-tests/volumegroupsnapshotcontent/vgsc-change-ref-namespace.pre.yaml -> cel-tests/volumegroupsnapshotcontent/vgsc-change-ref-namespace.post.yaml: SUCCESS (expected failure)
131-
cel-tests/volumegroupsnapshotcontent/vgsc-source-volume-immutable.pre.yaml -> cel-tests/volumegroupsnapshotcontent/vgsc-source-volume-immutable.post.yaml: SUCCESS (expected failure)
132-
cel-tests/volumegroupsnapshotcontent/vgsc-source-volume-to-groupsnapshot.pre.yaml -> cel-tests/volumegroupsnapshotcontent/vgsc-source-volume-to-groupsnapshot.post.yaml: SUCCESS (expected failure)
133-
cel-tests/volumegroupsnapshotcontent/vgsc-source-groupsnapshot-immutable.pre.yaml -> cel-tests/volumegroupsnapshotcontent/vgsc-source-groupsnapshot-immutable.post.yaml: SUCCESS (expected failure)
134-
[...]
135-
136-
SUCCESS: 90
124+
SUCCESS: 108
137125
FAILURES: 0
138126
```
127+
128+
Adding the `-v` option to `run-cel-tests.sh` will show the output of each
129+
test case.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
apiVersion: groupsnapshot.storage.k8s.io/v1beta2
3+
kind: VolumeGroupSnapshotClass
4+
metadata:
5+
name: csi-hostpath-groupsnapclass
6+
driver: hostpath.csi.k8s.io
7+
deletionPolicy: Retain
8+
parameters:
9+
one: two
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deletionPolicy: Invalid value: "string": deletionPolicy is immutable once set
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
apiVersion: groupsnapshot.storage.k8s.io/v1beta2
3+
kind: VolumeGroupSnapshotClass
4+
metadata:
5+
name: csi-hostpath-groupsnapclass
6+
driver: hostpath.csi.k8s.io
7+
deletionPolicy: Delete
8+
parameters:
9+
one: two
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
apiVersion: groupsnapshot.storage.k8s.io/v1beta2
3+
kind: VolumeGroupSnapshotClass
4+
metadata:
5+
name: csi-hostpath-groupsnapclass
6+
driver: hostpath.csi.k8s.io
7+
deletionPolicy: Delete
8+
parameters:
9+
one: three

0 commit comments

Comments
 (0)