From 1175e8ba40e8000f42ac0bef6b41b4e422fb7aed Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 25 Nov 2024 12:50:01 +0100 Subject: [PATCH] use annotation to storage the groupsnapshot handle use annotation instead of label to storage the groupsnapshot handle to avoid length limit --- pkg/common-controller/groupsnapshot_controller_helper.go | 2 +- pkg/sidecar-controller/snapshot_controller.go | 6 +++--- pkg/utils/util.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/common-controller/groupsnapshot_controller_helper.go b/pkg/common-controller/groupsnapshot_controller_helper.go index e99e306c7..e4b5e4628 100644 --- a/pkg/common-controller/groupsnapshot_controller_helper.go +++ b/pkg/common-controller/groupsnapshot_controller_helper.go @@ -563,7 +563,7 @@ func (ctrl *csiSnapshotCommonController) createSnapshotsForGroupSnapshotContent( volumeSnapshotContent := &crdv1.VolumeSnapshotContent{ ObjectMeta: metav1.ObjectMeta{ Name: volumeSnapshotContentName, - Labels: map[string]string{ + Annotations: map[string]string{ utils.VolumeGroupSnapshotHandleLabel: *groupSnapshotContent.Status.VolumeGroupSnapshotHandle, }, }, diff --git a/pkg/sidecar-controller/snapshot_controller.go b/pkg/sidecar-controller/snapshot_controller.go index 6cc3df63f..0be89e0ad 100644 --- a/pkg/sidecar-controller/snapshot_controller.go +++ b/pkg/sidecar-controller/snapshot_controller.go @@ -86,7 +86,7 @@ func (ctrl *csiSnapshotSideCarController) syncContent(content *crdv1.VolumeSnaps // Create snapshot calling the CSI driver only if it is a dynamic // provisioning for an independent snapshot. - _, groupSnapshotMember := content.Labels[utils.VolumeGroupSnapshotHandleLabel] + _, groupSnapshotMember := content.Annotations[utils.VolumeGroupSnapshotHandleAnnotation] if content.Spec.Source.VolumeHandle != nil && content.Status == nil && !groupSnapshotMember { klog.V(5).Infof("syncContent: Call CreateSnapshot for content %s", content.Name) return ctrl.createSnapshot(content) @@ -235,7 +235,7 @@ func (ctrl *csiSnapshotSideCarController) getCSISnapshotInput(content *crdv1.Vol } } else { // If dynamic provisioning for an independent snapshot, return failure if no snapshot class - _, groupSnapshotMember := content.Labels[utils.VolumeGroupSnapshotHandleLabel] + _, groupSnapshotMember := content.Annotations[utils.VolumeGroupSnapshotHandleAnnotation] if content.Spec.Source.VolumeHandle != nil && !groupSnapshotMember { klog.Errorf("failed to getCSISnapshotInput %s without a snapshot class", content.Name) 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 return updatedContent, nil } - _, groupSnapshotMember := content.Labels[utils.VolumeGroupSnapshotHandleLabel] + _, groupSnapshotMember := content.Annotations[utils.VolumeGroupSnapshotHandleAnnotation] if !groupSnapshotMember { return ctrl.createSnapshotWrapper(content) } diff --git a/pkg/utils/util.go b/pkg/utils/util.go index e5b8c5e06..85107988c 100644 --- a/pkg/utils/util.go +++ b/pkg/utils/util.go @@ -153,9 +153,9 @@ const ( // VolumeGroupSnapshotHandleLabel is applied to VolumeSnapshotContents that are member // of a VolumeGroupSnapshotContent, and indicates the handle of the latter. // - // This label is applied to inform the sidecar not to call CSI driver + // This annotation is applied to inform the sidecar not to call CSI driver // to create snapshot if the snapshot belongs to a group. - VolumeGroupSnapshotHandleLabel = "groupsnapshot.storage.k8s.io/volumeGroupSnapshotHandle" + VolumeGroupSnapshotHandleAnnotation = "groupsnapshot.storage.k8s.io/volumeGroupSnapshotHandle" // VolumeSnapshotContentInvalidLabel is applied to invalid content as a label key. The value does not matter. // See https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/177-volume-snapshot/tighten-validation-webhook-crd.md#automatic-labelling-of-invalid-objects