Skip to content

Commit 55def14

Browse files
authored
Merge pull request #1219 from Madhu-1/use-annotation
use annotation to store the groupsnapshot handle
2 parents 4183faa + 023d38d commit 55def14

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

pkg/common-controller/groupsnapshot_controller_helper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,8 @@ func (ctrl *csiSnapshotCommonController) createSnapshotsForGroupSnapshotContent(
563563
volumeSnapshotContent := &crdv1.VolumeSnapshotContent{
564564
ObjectMeta: metav1.ObjectMeta{
565565
Name: volumeSnapshotContentName,
566-
Labels: map[string]string{
567-
utils.VolumeGroupSnapshotHandleLabel: *groupSnapshotContent.Status.VolumeGroupSnapshotHandle,
566+
Annotations: map[string]string{
567+
utils.VolumeGroupSnapshotHandleAnnotation: *groupSnapshotContent.Status.VolumeGroupSnapshotHandle,
568568
},
569569
},
570570
Spec: crdv1.VolumeSnapshotContentSpec{

pkg/sidecar-controller/snapshot_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (ctrl *csiSnapshotSideCarController) syncContent(content *crdv1.VolumeSnaps
8686

8787
// Create snapshot calling the CSI driver only if it is a dynamic
8888
// provisioning for an independent snapshot.
89-
_, groupSnapshotMember := content.Labels[utils.VolumeGroupSnapshotHandleLabel]
89+
_, groupSnapshotMember := content.Annotations[utils.VolumeGroupSnapshotHandleAnnotation]
9090
if content.Spec.Source.VolumeHandle != nil && content.Status == nil && !groupSnapshotMember {
9191
klog.V(5).Infof("syncContent: Call CreateSnapshot for content %s", content.Name)
9292
return ctrl.createSnapshot(content)
@@ -235,7 +235,7 @@ func (ctrl *csiSnapshotSideCarController) getCSISnapshotInput(content *crdv1.Vol
235235
}
236236
} else {
237237
// If dynamic provisioning for an independent snapshot, return failure if no snapshot class
238-
_, groupSnapshotMember := content.Labels[utils.VolumeGroupSnapshotHandleLabel]
238+
_, groupSnapshotMember := content.Annotations[utils.VolumeGroupSnapshotHandleAnnotation]
239239
if content.Spec.Source.VolumeHandle != nil && !groupSnapshotMember {
240240
klog.Errorf("failed to getCSISnapshotInput %s without a snapshot class", content.Name)
241241
return nil, nil, fmt.Errorf("failed to take snapshot %s without a snapshot class", content.Name)
@@ -316,7 +316,7 @@ func (ctrl *csiSnapshotSideCarController) checkandUpdateContentStatusOperation(c
316316
return updatedContent, nil
317317
}
318318

319-
_, groupSnapshotMember := content.Labels[utils.VolumeGroupSnapshotHandleLabel]
319+
_, groupSnapshotMember := content.Annotations[utils.VolumeGroupSnapshotHandleAnnotation]
320320
if !groupSnapshotMember {
321321
return ctrl.createSnapshotWrapper(content)
322322
}

pkg/utils/util.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ const (
150150
// of a VolumeGroupSnapshot, and indicates the name of the latter.
151151
VolumeGroupSnapshotNameLabel = "groupsnapshot.storage.k8s.io/volumeGroupSnapshotName"
152152

153-
// VolumeGroupSnapshotHandleLabel is applied to VolumeSnapshotContents that are member
153+
// VolumeGroupSnapshotHandleAnnotation is applied to VolumeSnapshotContents that are member
154154
// of a VolumeGroupSnapshotContent, and indicates the handle of the latter.
155155
//
156-
// This label is applied to inform the sidecar not to call CSI driver
156+
// This annotation is applied to inform the sidecar not to call CSI driver
157157
// to create snapshot if the snapshot belongs to a group.
158-
VolumeGroupSnapshotHandleLabel = "groupsnapshot.storage.k8s.io/volumeGroupSnapshotHandle"
158+
VolumeGroupSnapshotHandleAnnotation = "groupsnapshot.storage.k8s.io/volumeGroupSnapshotHandle"
159159

160160
// VolumeSnapshotContentInvalidLabel is applied to invalid content as a label key. The value does not matter.
161161
// See https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/177-volume-snapshot/tighten-validation-webhook-crd.md#automatic-labelling-of-invalid-objects

0 commit comments

Comments
 (0)