Skip to content

Commit 0bd355c

Browse files
committed
update API names in group snapshot content to be consistent with volume snapshots
1 parent bffa5ae commit 0bd355c

File tree

14 files changed

+169
-126
lines changed

14 files changed

+169
-126
lines changed

client/apis/volumegroupsnapshot/v1alpha1/types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,22 +348,22 @@ type VolumeGroupSnapshotContentStatus struct {
348348
// Exactly one of its members must be set.
349349
// Members in VolumeGroupSnapshotContentSource are immutable.
350350
type VolumeGroupSnapshotContentSource struct {
351-
// PersistentVolumeNames is a list of names of PersistentVolumes to be snapshotted
351+
// VolumeHandles is a list of volume handles on the backend to be snapshotted
352352
// together. It is specified for dynamic provisioning of the VolumeGroupSnapshot.
353353
// This field is immutable.
354354
// +optional
355-
PersistentVolumeNames []string `json:"persistentVolumeNames,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeNames"`
355+
VolumeHandles []string `json:"volumeHandles,omitempty" protobuf:"bytes,1,opt,name=volumeHandles"`
356356

357-
// GroupSnapshotHandleSource specifies the CSI "group_snapshot_id" of a pre-existing
357+
// GroupSnapshotHandles specifies the CSI "group_snapshot_id" of a pre-existing
358358
// group snapshot and a list of CSI "snapshot_id" of pre-existing snapshots
359359
// on the underlying storage system for which a Kubernetes object
360360
// representation was (or should be) created.
361361
// This field is immutable.
362362
// +optional
363-
GroupSnapshotHandleSource *VolumeGroupSnapshotHandleSource `json:"groupSnapshotHandleSource,omitempty" protobuf:"bytes,2,opt,name=groupSnapshotHandleSource"`
363+
GroupSnapshotHandles *GroupSnapshotHandles `json:"groupSnapshotHandles,omitempty" protobuf:"bytes,2,opt,name=groupSnapshotHandles"`
364364
}
365365

366-
type VolumeGroupSnapshotHandleSource struct {
366+
type GroupSnapshotHandles struct {
367367
// VolumeGroupSnapshotHandle specifies the CSI "group_snapshot_id" of a pre-existing
368368
// group snapshot on the underlying storage system for which a Kubernetes object
369369
// representation was (or should be) created.

client/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go

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

client/apis/volumesnapshot/v1/zz_generated.deepcopy.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.

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ spec:
104104
dynamically provisioned or already exists, and just requires a Kubernetes
105105
object representation. This field is immutable after creation. Required.
106106
properties:
107-
groupSnapshotHandleSource:
108-
description: GroupSnapshotHandleSource specifies the CSI "group_snapshot_id"
107+
groupSnapshotHandles:
108+
description: GroupSnapshotHandles specifies the CSI "group_snapshot_id"
109109
of a pre-existing group snapshot and a list of CSI "snapshot_id"
110110
of pre-existing snapshots on the underlying storage system for
111111
which a Kubernetes object representation was (or should be)
@@ -129,17 +129,17 @@ spec:
129129
- volumeGroupSnapshotHandle
130130
- volumeSnapshotHandles
131131
type: object
132-
persistentVolumeNames:
133-
description: PersistentVolumeNames is a list of names of PersistentVolumes
134-
to be snapshotted together. It is specified for dynamic provisioning
135-
of the VolumeGroupSnapshot. This field is immutable.
132+
volumeHandles:
133+
description: VolumeHandles is a list of volume handles on the
134+
backend to be snapshotted together. It is specified for dynamic
135+
provisioning of the VolumeGroupSnapshot. This field is immutable.
136136
items:
137137
type: string
138138
type: array
139139
type: object
140140
oneOf:
141-
- required: ["persistentVolumeNames"]
142-
- required: ["groupSnapshotHandleSource"]
141+
- required: ["volumeHandles"]
142+
- required: ["groupSnapshotHandles"]
143143
volumeGroupSnapshotClassName:
144144
description: VolumeGroupSnapshotClassName is the name of the VolumeGroupSnapshotClass
145145
from which this group snapshot was (or will be) created. Note that

client/hack/README.md

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,30 +144,49 @@ Update the restoreSize property to use type string only:
144144
145145
* Add the VolumeSnapshot namespace to the `additionalPrinterColumns` section. Refer https://github.com/kubernetes-csi/external-snapshotter/pull/535 for more details.
146146
147-
* In `client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml `, we need to add the `oneOf` constraint to make sure only one of `persistentVolumeNames` and `volumeGroupSnapshotHandle` is specified in the `source` field of the `spec` of `VolumeGroupSnapshotContent`.
147+
* In `client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml `, we need to add the `oneOf` constraint to make sure only one of `volumeHandles` and `groupSnapshotHandles` is specified in the `source` field of the `spec` of `VolumeGroupSnapshotContent`.
148148
149149
```bash
150150
source:
151151
description: Source specifies whether the snapshot is (or should be)
152152
dynamically provisioned or already exists, and just requires a Kubernetes
153153
object representation. This field is immutable after creation. Required.
154154
properties:
155-
persistentVolumeNames:
156-
description: PersistentVolumeNames is a list of names of PersistentVolumes
157-
to be snapshotted together. It is specified for dynamic provisioning
158-
of the VolumeGroupSnapshot. This field is immutable.
155+
groupSnapshotHandles:
156+
description: GroupSnapshotHandles specifies the CSI "group_snapshot_id"
157+
of a pre-existing group snapshot and a list of CSI "snapshot_id"
158+
of pre-existing snapshots on the underlying storage system for
159+
which a Kubernetes object representation was (or should be)
160+
created. This field is immutable.
161+
properties:
162+
volumeGroupSnapshotHandle:
163+
description: VolumeGroupSnapshotHandle specifies the CSI "group_snapshot_id"
164+
of a pre-existing group snapshot on the underlying storage
165+
system for which a Kubernetes object representation was
166+
(or should be) created. This field is immutable. Required.
167+
type: string
168+
volumeSnapshotHandles:
169+
description: VolumeSnapshotHandles is a list of CSI "snapshot_id"
170+
of pre-existing snapshots on the underlying storage system
171+
for which Kubernetes objects representation were (or should
172+
be) created. This field is immutable. Required.
173+
items:
174+
type: string
175+
type: array
176+
required:
177+
- volumeGroupSnapshotHandle
178+
- volumeSnapshotHandles
179+
type: object
180+
volumeHandles:
181+
description: VolumeHandles is a list of volume handles on the
182+
backend to be snapshotted together. It is specified for dynamic
183+
provisioning of the VolumeGroupSnapshot. This field is immutable.
159184
items:
160185
type: string
161186
type: array
162-
volumeGroupSnapshotHandle:
163-
description: VolumeGroupSnapshotHandle specifies the CSI "group_snapshot_id"
164-
of a pre-existing group snapshot on the underlying storage system
165-
for which a Kubernetes object representation was (or should
166-
be) created. This field is immutable.
167-
type: string
168187
type: object
169188
oneOf:
170-
- required: ["persistentVolumeNames"]
171-
- required: ["volumeGroupSnapshotHandle"]
189+
- required: ["volumeHandles"]
190+
- required: ["groupSnapshotHandles"]
172191
volumeGroupSnapshotClassName:
173192
```

pkg/common-controller/groupsnapshot_controller_helper.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ func (ctrl *csiSnapshotCommonController) syncUnreadyGroupSnapshot(groupSnapshot
426426

427427
if contentObj != nil {
428428
klog.V(5).Infof("Found VolumeGroupSnapshotContent object %s for group snapshot %s", contentObj.Name, uniqueGroupSnapshotName)
429-
if contentObj.Spec.Source.VolumeGroupSnapshotHandle != nil {
429+
if contentObj.Spec.Source.GroupSnapshotHandles != nil {
430430
ctrl.updateGroupSnapshotErrorStatusWithEvent(groupSnapshot, true, v1.EventTypeWarning, "GroupSnapshotHandleSet", fmt.Sprintf("GroupSnapshot handle should not be set in group snapshot content %s for dynamic provisioning", uniqueGroupSnapshotName))
431431
return fmt.Errorf("VolumeGroupSnapshotHandle should not be set in the group snapshot content for dynamic provisioning for group snapshot %s", uniqueGroupSnapshotName)
432432
}
@@ -483,7 +483,7 @@ func (ctrl *csiSnapshotCommonController) getPreprovisionedGroupSnapshotContentFr
483483
return nil, nil
484484
}
485485
// check whether the content is a pre-provisioned VolumeGroupSnapshotContent
486-
if groupSnapshotContent.Spec.Source.VolumeGroupSnapshotHandle == nil {
486+
if groupSnapshotContent.Spec.Source.GroupSnapshotHandles == nil {
487487
// found a group snapshot content which represents a dynamically provisioned group snapshot
488488
// update the group snapshot and return an error
489489
ctrl.updateGroupSnapshotErrorStatusWithEvent(groupSnapshot, true, v1.EventTypeWarning, "GroupSnapshotContentMismatch", "VolumeGroupSnapshotContent is dynamically provisioned while expecting a pre-provisioned one")
@@ -682,7 +682,7 @@ func (ctrl *csiSnapshotCommonController) getDynamicallyProvisionedGroupContentFr
682682
return nil, nil
683683
}
684684
// check whether the group snapshot content represents a dynamically provisioned snapshot
685-
if groupSnapshotContent.Spec.Source.VolumeGroupSnapshotHandle != nil {
685+
if groupSnapshotContent.Spec.Source.GroupSnapshotHandles != nil {
686686
ctrl.updateGroupSnapshotErrorStatusWithEvent(groupSnapshot, true, v1.EventTypeWarning, "GroupSnapshotContentMismatch", "VolumeGroupSnapshotContent "+contentName+" is pre-provisioned while expecting a dynamically provisioned one")
687687
klog.V(4).Infof("sync group snapshot[%s]: group snapshot content %s is pre-provisioned while expecting a dynamically provisioned one", utils.GroupSnapshotKey(groupSnapshot), contentName)
688688
return nil, fmt.Errorf("group snapshot %s expects a dynamically provisioned VolumeGroupSnapshotContent %s but gets a pre-provisioned one", utils.GroupSnapshotKey(groupSnapshot), contentName)
@@ -752,9 +752,9 @@ func (ctrl *csiSnapshotCommonController) createGroupSnapshotContent(groupSnapsho
752752
if err != nil {
753753
return nil, err
754754
}
755-
var pvNames []string
755+
var volumeHandles []string
756756
for _, pv := range volumes {
757-
pvNames = append(pvNames, pv.Name)
757+
volumeHandles = append(volumeHandles, pv.Spec.CSI.VolumeHandle)
758758
}
759759

760760
groupSnapshotContent := &crdv1alpha1.VolumeGroupSnapshotContent{
@@ -764,7 +764,7 @@ func (ctrl *csiSnapshotCommonController) createGroupSnapshotContent(groupSnapsho
764764
Spec: crdv1alpha1.VolumeGroupSnapshotContentSpec{
765765
VolumeGroupSnapshotRef: *snapshotRef,
766766
Source: crdv1alpha1.VolumeGroupSnapshotContentSource{
767-
PersistentVolumeNames: pvNames,
767+
VolumeHandles: volumeHandles,
768768
},
769769
VolumeGroupSnapshotClassName: &(groupSnapshotClass.Name),
770770
DeletionPolicy: groupSnapshotClass.DeletionPolicy,
@@ -846,9 +846,9 @@ func (ctrl *csiSnapshotCommonController) syncGroupSnapshotContent(groupSnapshotC
846846
klog.V(5).Infof("syncGroupSnapshotContent[%s]: check if we should add invalid label on group snapshot content", groupSnapshotContent.Name)
847847

848848
// Keep this check in the controller since the validation webhook may not have been deployed.
849-
if (groupSnapshotContent.Spec.Source.VolumeGroupSnapshotHandle == nil && len(groupSnapshotContent.Spec.Source.PersistentVolumeNames) == 0) ||
850-
(groupSnapshotContent.Spec.Source.VolumeGroupSnapshotHandle != nil && len(groupSnapshotContent.Spec.Source.PersistentVolumeNames) > 0) {
851-
err := fmt.Errorf("Exactly one of VolumeGroupSnapshotHandle and PersistentVolumeNames should be specified")
849+
if (groupSnapshotContent.Spec.Source.GroupSnapshotHandles == nil && len(groupSnapshotContent.Spec.Source.VolumeHandles) == 0) ||
850+
(groupSnapshotContent.Spec.Source.GroupSnapshotHandles != nil && len(groupSnapshotContent.Spec.Source.VolumeHandles) > 0) {
851+
err := fmt.Errorf("Exactly one of GroupSnapshotHandles and VolumeHandles should be specified")
852852
klog.Errorf("syncGroupSnapshotContent[%s]: validation error, %s", groupSnapshotContent.Name, err.Error())
853853
ctrl.eventRecorder.Event(groupSnapshotContent, v1.EventTypeWarning, "GroupContentValidationError", err.Error())
854854
return err

0 commit comments

Comments
 (0)