Skip to content

Commit 3c79996

Browse files
authored
Merge pull request #1200 from leonardoce/remove-PVCVolumeSnapshotRefList
Remove PVCVolumeSnapshotRefList from VolumeGroupSnapshot API
2 parents 9e30bb0 + 1ea7a1a commit 3c79996

File tree

7 files changed

+18
-70
lines changed

7 files changed

+18
-70
lines changed

client/apis/volumegroupsnapshot/v1alpha1/types.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ type VolumeGroupSnapshotStatus struct {
108108
// group snapshot creation. Upon success, this error field will be cleared.
109109
// +optional
110110
Error *snapshotv1.VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeSnapshotError"`
111-
112-
// VolumeSnapshotRefList is the list of PVC and VolumeSnapshot pairs that
113-
// is part of this group snapshot.
114-
// The maximum number of allowed snapshots in the group is 100.
115-
// +optional
116-
PVCVolumeSnapshotRefList []PVCVolumeSnapshotPair `json:"pvcVolumeSnapshotRefList,omitempty" protobuf:"bytes,5,opt,name=pvcVolumeSnapshotRefList"`
117111
}
118112

119113
// PVCVolumeSnapshotPair defines a pair of a PVC reference and a Volume Snapshot Reference

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

Lines changed: 0 additions & 5 deletions
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_volumegroupsnapshots.yaml

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -221,41 +221,6 @@ spec:
221221
format: date-time
222222
type: string
223223
type: object
224-
pvcVolumeSnapshotRefList:
225-
description: |-
226-
VolumeSnapshotRefList is the list of PVC and VolumeSnapshot pairs that
227-
is part of this group snapshot.
228-
The maximum number of allowed snapshots in the group is 100.
229-
items:
230-
description: PVCVolumeSnapshotPair defines a pair of a PVC reference
231-
and a Volume Snapshot Reference
232-
properties:
233-
persistentVolumeClaimRef:
234-
description: PersistentVolumeClaimRef is a reference to the
235-
PVC this pair is referring to
236-
properties:
237-
name:
238-
description: |-
239-
Name of the referent.
240-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
241-
TODO: Add other useful fields. apiVersion, kind, uid?
242-
type: string
243-
type: object
244-
x-kubernetes-map-type: atomic
245-
volumeSnapshotRef:
246-
description: VolumeSnapshotRef is a reference to the VolumeSnapshot
247-
this pair is referring to
248-
properties:
249-
name:
250-
description: |-
251-
Name of the referent.
252-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
253-
TODO: Add other useful fields. apiVersion, kind, uid?
254-
type: string
255-
type: object
256-
x-kubernetes-map-type: atomic
257-
type: object
258-
type: array
259224
readyToUse:
260225
description: |-
261226
ReadyToUse indicates if all the individual snapshots in the group are ready

pkg/common-controller/groupsnapshot_controller_helper.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ func (ctrl *csiSnapshotCommonController) syncGroupSnapshot(ctx context.Context,
325325
// 2) groupSnapshot.Status.ReadyToUse is false
326326
// 3) groupSnapshot.Status.IsBoundVolumeGroupSnapshotContentNameSet is not set
327327
// 4) groupSnapshot.Status.IsVolumeSnapshotRefListSet is not set
328-
if !utils.IsGroupSnapshotReady(groupSnapshot) || !utils.IsBoundVolumeGroupSnapshotContentNameSet(groupSnapshot) || !utils.IsPVCVolumeSnapshotRefListSet(groupSnapshot) {
328+
if !utils.IsGroupSnapshotReady(groupSnapshot) || !utils.IsBoundVolumeGroupSnapshotContentNameSet(groupSnapshot) {
329329
return ctrl.syncUnreadyGroupSnapshot(ctx, groupSnapshot)
330330
}
331331
return ctrl.syncReadyGroupSnapshot(groupSnapshot)
@@ -1437,11 +1437,17 @@ func (ctrl *csiSnapshotCommonController) processGroupSnapshotWithDeletionTimesta
14371437
return nil
14381438
}
14391439

1440+
snapshotMembers, err := ctrl.snapshotLister.List(labels.SelectorFromSet(
1441+
labels.Set{
1442+
utils.VolumeGroupSnapshotNameLabel: groupSnapshot.Name,
1443+
},
1444+
))
1445+
14401446
// check if an individual snapshot belonging to the group snapshot is being
14411447
// used for restore a PVC
14421448
// If yes, do nothing and wait until PVC restoration finishes
1443-
for _, snapshotRef := range groupSnapshot.Status.PVCVolumeSnapshotRefList {
1444-
snapshot, err := ctrl.snapshotLister.VolumeSnapshots(groupSnapshot.Namespace).Get(snapshotRef.VolumeSnapshotRef.Name)
1449+
for _, snapshot := range snapshotMembers {
1450+
snapshot, err := ctrl.snapshotLister.VolumeSnapshots(groupSnapshot.Namespace).Get(snapshot.Name)
14451451
if err != nil {
14461452
if apierrs.IsNotFound(err) {
14471453
continue
@@ -1488,10 +1494,16 @@ func (ctrl *csiSnapshotCommonController) processGroupSnapshotWithDeletionTimesta
14881494
klog.V(5).Infof("processGroupSnapshotWithDeletionTimestamp[%s]: Delete individual snapshots that are part of the group snapshot", utils.GroupSnapshotKey(groupSnapshot))
14891495

14901496
// Delete the individual snapshots part of the group snapshot
1491-
for _, snapshot := range groupSnapshot.Status.PVCVolumeSnapshotRefList {
1492-
err := ctrl.clientset.SnapshotV1().VolumeSnapshots(groupSnapshot.Namespace).Delete(context.TODO(), snapshot.VolumeSnapshotRef.Name, metav1.DeleteOptions{})
1497+
for _, snapshot := range snapshotMembers {
1498+
err := ctrl.clientset.SnapshotV1().
1499+
VolumeSnapshots(groupSnapshot.Namespace).
1500+
Delete(context.TODO(), snapshot.Name, metav1.DeleteOptions{})
14931501
if err != nil && !apierrs.IsNotFound(err) {
1494-
msg := fmt.Sprintf("failed to delete snapshot API object %s/%s part of group snapshot %s: %v", groupSnapshot.Namespace, snapshot.VolumeSnapshotRef.Name, utils.GroupSnapshotKey(groupSnapshot), err)
1502+
msg := fmt.Sprintf(
1503+
"failed to delete snapshot API object %s/%s part of group snapshot %s: %v",
1504+
groupSnapshot.Namespace,
1505+
snapshot.Name,
1506+
utils.GroupSnapshotKey(groupSnapshot), err)
14951507
klog.Error(msg)
14961508
ctrl.eventRecorder.Event(groupSnapshot, v1.EventTypeWarning, "SnapshotDeleteError", msg)
14971509
return fmt.Errorf(msg)

pkg/utils/util.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -655,13 +655,6 @@ func IsBoundVolumeGroupSnapshotContentNameSet(groupSnapshot *crdv1alpha1.VolumeG
655655
return true
656656
}
657657

658-
func IsPVCVolumeSnapshotRefListSet(groupSnapshot *crdv1alpha1.VolumeGroupSnapshot) bool {
659-
if groupSnapshot.Status == nil || len(groupSnapshot.Status.PVCVolumeSnapshotRefList) == 0 {
660-
return false
661-
}
662-
return true
663-
}
664-
665658
func IsVolumeGroupSnapshotRefSet(groupSnapshot *crdv1alpha1.VolumeGroupSnapshot, content *crdv1alpha1.VolumeGroupSnapshotContent) bool {
666659
if content.Spec.VolumeGroupSnapshotRef.Name == groupSnapshot.Name &&
667660
content.Spec.VolumeGroupSnapshotRef.Namespace == groupSnapshot.Namespace &&

vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/types.go

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

vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)