Skip to content

Commit

Permalink
use annotation to storage the groupsnapshot handle
Browse files Browse the repository at this point in the history
use annotation instead of label to storage
the groupsnapshot handle to avoid length limit
  • Loading branch information
Madhu-1 committed Nov 25, 2024
1 parent 4183faa commit 1175e8b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/common-controller/groupsnapshot_controller_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/sidecar-controller/snapshot_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/utils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1175e8b

Please sign in to comment.