Skip to content

Commit 9cb9f0f

Browse files
authored
Merge pull request kubernetes-csi#1199 from leonardoce/remove-pvvolumesnapshotcontentlist
Remove PVVolumeSnapshotContentList field from the VolumeGroupSnapshotContentStatus API
2 parents a7443c7 + 5414afe commit 9cb9f0f

File tree

7 files changed

+5
-151
lines changed

7 files changed

+5
-151
lines changed

client/apis/volumegroupsnapshot/v1alpha1/types.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,6 @@ type VolumeGroupSnapshotContentStatus struct {
353353
// +optional
354354
Error *snapshotv1.VolumeSnapshotError `json:"error,omitempty" protobuf:"bytes,4,opt,name=error,casttype=VolumeSnapshotError"`
355355

356-
// PVVolumeSnapshotContentList is the list of pairs of PV and
357-
// VolumeSnapshotContent for this group snapshot
358-
// The maximum number of allowed snapshots in the group is 100.
359-
// +optional
360-
PVVolumeSnapshotContentList []PVVolumeSnapshotContentPair `json:"pvVolumeSnapshotContentList,omitempty" protobuf:"bytes,5,opt,name=pvVolumeSnapshotContentRefList"`
361-
362356
// VolumeSnapshotHandlePairList is a list of CSI "volume_id" and "snapshot_id"
363357
// pair returned by the CSI driver to identify snapshots and their source volumes
364358
// on the storage system.

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_volumegroupsnapshotcontents.yaml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -274,42 +274,6 @@ spec:
274274
format: date-time
275275
type: string
276276
type: object
277-
pvVolumeSnapshotContentList:
278-
description: |-
279-
PVVolumeSnapshotContentList is the list of pairs of PV and
280-
VolumeSnapshotContent for this group snapshot
281-
The maximum number of allowed snapshots in the group is 100.
282-
items:
283-
description: |-
284-
PVVolumeSnapshotContentPair represent a pair of PV names and
285-
VolumeSnapshotContent names
286-
properties:
287-
persistentVolumeRef:
288-
description: PersistentVolumeRef is a reference to the persistent
289-
volume resource
290-
properties:
291-
name:
292-
description: |-
293-
Name of the referent.
294-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
295-
TODO: Add other useful fields. apiVersion, kind, uid?
296-
type: string
297-
type: object
298-
x-kubernetes-map-type: atomic
299-
volumeSnapshotContentRef:
300-
description: VolumeSnapshotContentRef is a reference to the
301-
volume snapshot content resource
302-
properties:
303-
name:
304-
description: |-
305-
Name of the referent.
306-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
307-
TODO: Add other useful fields. apiVersion, kind, uid?
308-
type: string
309-
type: object
310-
x-kubernetes-map-type: atomic
311-
type: object
312-
type: array
313277
readyToUse:
314278
description: |-
315279
ReadyToUse indicates if all the individual snapshots in the group are ready to be

pkg/common-controller/groupsnapshot_controller_helper.go

Lines changed: 2 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,7 @@ func (ctrl *csiSnapshotCommonController) createSnapshotsForGroupSnapshotContent(
533533
"createSnapshotsForGroupSnapshotContent[%s]: creating volumesnapshots and volumesnapshotcontent for group snapshot content",
534534
groupSnapshotContent.Name)
535535

536-
groupSnapshotContent.Status.PVVolumeSnapshotContentList = make(
537-
[]crdv1alpha1.PVVolumeSnapshotContentPair,
538-
len(groupSnapshotContent.Status.VolumeSnapshotHandlePairList),
539-
)
540-
for i, snapshot := range groupSnapshotContent.Status.VolumeSnapshotHandlePairList {
536+
for _, snapshot := range groupSnapshotContent.Status.VolumeSnapshotHandlePairList {
541537
snapshotHandle := snapshot.SnapshotHandle
542538
volumeHandle := snapshot.VolumeHandle
543539

@@ -619,17 +615,6 @@ func (ctrl *csiSnapshotCommonController) createSnapshotsForGroupSnapshotContent(
619615
"createSnapshotsForGroupSnapshotContent: creating volumesnapshot %w", err)
620616
}
621617

622-
groupSnapshotContent.Status.PVVolumeSnapshotContentList[i] = crdv1alpha1.PVVolumeSnapshotContentPair{
623-
VolumeSnapshotContentRef: v1.LocalObjectReference{
624-
Name: volumeSnapshotContentName,
625-
},
626-
}
627-
if pv != nil {
628-
groupSnapshotContent.Status.PVVolumeSnapshotContentList[i].PersistentVolumeRef = v1.LocalObjectReference{
629-
Name: pv.Name,
630-
}
631-
}
632-
633618
// bind the volume snapshot content to the volume snapshot
634619
// like a dynamically provisioned snapshot would do
635620
volumeSnapshotContent.Spec.VolumeSnapshotRef.UID = createdVolumeSnapshot.UID
@@ -665,24 +650,7 @@ func (ctrl *csiSnapshotCommonController) createSnapshotsForGroupSnapshotContent(
665650
}
666651
}
667652

668-
// Phase 2: set the backlinks
669-
var patches []utils.PatchOp
670-
patches = append(patches, utils.PatchOp{
671-
Op: "replace",
672-
Path: "/status/pvVolumeSnapshotContentList",
673-
Value: groupSnapshotContent.Status.PVVolumeSnapshotContentList,
674-
})
675-
676-
newGroupSnapshotObj, err := utils.PatchVolumeGroupSnapshotContent(
677-
groupSnapshotContent,
678-
patches,
679-
ctrl.clientset,
680-
"status")
681-
if err != nil {
682-
return nil, newControllerUpdateError(utils.GroupSnapshotKey(groupSnapshot), err.Error())
683-
}
684-
685-
return newGroupSnapshotObj, nil
653+
return groupSnapshotContent, nil
686654
}
687655

688656
// findPersistentVolumeByCSIDriverHandle looks at an existing PersistentVolume
@@ -836,50 +804,6 @@ func (ctrl *csiSnapshotCommonController) updateGroupSnapshotStatus(groupSnapshot
836804
volumeSnapshotErr = groupSnapshotContent.Status.Error.DeepCopy()
837805
}
838806

839-
var pvcVolumeSnapshotRefList []crdv1alpha1.PVCVolumeSnapshotPair
840-
if groupSnapshotContent.Status != nil && len(groupSnapshotContent.Status.PVVolumeSnapshotContentList) != 0 {
841-
for _, contentRef := range groupSnapshotContent.Status.PVVolumeSnapshotContentList {
842-
var pvcReference v1.LocalObjectReference
843-
pv, err := ctrl.client.CoreV1().PersistentVolumes().Get(context.TODO(), contentRef.PersistentVolumeRef.Name, metav1.GetOptions{})
844-
if err != nil {
845-
if apierrs.IsNotFound(err) {
846-
klog.Errorf(
847-
"updateGroupSnapshotStatus[%s]: PV [%s] not found",
848-
utils.GroupSnapshotKey(groupSnapshot),
849-
contentRef.PersistentVolumeRef.Name,
850-
)
851-
} else {
852-
klog.Errorf(
853-
"updateGroupSnapshotStatus[%s]: unable to get PV [%s] from the API server: %q",
854-
utils.GroupSnapshotKey(groupSnapshot),
855-
contentRef.PersistentVolumeRef.Name,
856-
err.Error(),
857-
)
858-
}
859-
} else {
860-
if pv.Spec.ClaimRef != nil {
861-
pvcReference.Name = pv.Spec.ClaimRef.Name
862-
} else {
863-
klog.Errorf(
864-
"updateGroupSnapshotStatus[%s]: PV [%s] is not bound",
865-
utils.GroupSnapshotKey(groupSnapshot),
866-
contentRef.PersistentVolumeRef.Name)
867-
}
868-
}
869-
870-
volumeSnapshotContent, err := ctrl.contentLister.Get(contentRef.VolumeSnapshotContentRef.Name)
871-
if err != nil {
872-
return nil, fmt.Errorf("failed to get snapshot content %s from snapshot content store: %v", contentRef.VolumeSnapshotContentRef.Name, err)
873-
}
874-
pvcVolumeSnapshotRefList = append(pvcVolumeSnapshotRefList, crdv1alpha1.PVCVolumeSnapshotPair{
875-
VolumeSnapshotRef: v1.LocalObjectReference{
876-
Name: volumeSnapshotContent.Spec.VolumeSnapshotRef.Name,
877-
},
878-
PersistentVolumeClaimRef: pvcReference,
879-
})
880-
}
881-
}
882-
883807
klog.V(5).Infof("updateGroupSnapshotStatus: updating VolumeGroupSnapshot [%+v] based on VolumeGroupSnapshotContentStatus [%+v]", groupSnapshot, groupSnapshotContent.Status)
884808

885809
groupSnapshotObj, err := ctrl.clientset.GroupsnapshotV1alpha1().VolumeGroupSnapshots(groupSnapshot.Namespace).Get(context.TODO(), groupSnapshot.Name, metav1.GetOptions{})
@@ -900,9 +824,6 @@ func (ctrl *csiSnapshotCommonController) updateGroupSnapshotStatus(groupSnapshot
900824
if volumeSnapshotErr != nil {
901825
newStatus.Error = volumeSnapshotErr
902826
}
903-
if len(pvcVolumeSnapshotRefList) == 0 {
904-
newStatus.PVCVolumeSnapshotRefList = pvcVolumeSnapshotRefList
905-
}
906827

907828
updated = true
908829
} else {
@@ -926,10 +847,6 @@ func (ctrl *csiSnapshotCommonController) updateGroupSnapshotStatus(groupSnapshot
926847
newStatus.Error = volumeSnapshotErr
927848
updated = true
928849
}
929-
if len(newStatus.PVCVolumeSnapshotRefList) == 0 {
930-
newStatus.PVCVolumeSnapshotRefList = pvcVolumeSnapshotRefList
931-
updated = true
932-
}
933850
}
934851

935852
if updated {

pkg/sidecar-controller/groupsnapshot_helper.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,9 @@ func (ctrl *csiSnapshotSideCarController) deleteCSIGroupSnapshotOperation(groupS
247247
}
248248

249249
var snapshotIDs []string
250-
if groupSnapshotContent.Status != nil && len(groupSnapshotContent.Status.PVVolumeSnapshotContentList) != 0 {
251-
for _, contentRef := range groupSnapshotContent.Status.PVVolumeSnapshotContentList {
252-
snapshotContent, err := ctrl.contentLister.Get(contentRef.VolumeSnapshotContentRef.Name)
253-
if err != nil {
254-
return fmt.Errorf("failed to get snapshot content %s from snapshot content store: %v", contentRef.VolumeSnapshotContentRef.Name, err)
255-
}
256-
snapshotIDs = append(snapshotIDs, *snapshotContent.Status.SnapshotHandle)
250+
if groupSnapshotContent.Status != nil && len(groupSnapshotContent.Status.VolumeSnapshotHandlePairList) != 0 {
251+
for _, contentRef := range groupSnapshotContent.Status.VolumeSnapshotHandlePairList {
252+
snapshotIDs = append(snapshotIDs, contentRef.SnapshotHandle)
257253
}
258254
}
259255

@@ -290,7 +286,6 @@ func (ctrl *csiSnapshotSideCarController) clearGroupSnapshotContentStatus(
290286
groupSnapshotContent.Status.ReadyToUse = nil
291287
groupSnapshotContent.Status.CreationTime = nil
292288
groupSnapshotContent.Status.Error = nil
293-
groupSnapshotContent.Status.PVVolumeSnapshotContentList = nil
294289
}
295290
newContent, err := ctrl.clientset.GroupsnapshotV1alpha1().VolumeGroupSnapshotContents().UpdateStatus(context.TODO(), groupSnapshotContent, metav1.UpdateOptions{})
296291
if err != nil {

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)