Skip to content

Commit

Permalink
Merge pull request #1219 from Madhu-1/use-annotation
Browse files Browse the repository at this point in the history
use annotation to store the groupsnapshot handle
  • Loading branch information
k8s-ci-robot authored Nov 25, 2024
2 parents 4183faa + 023d38d commit 55def14
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pkg/common-controller/groupsnapshot_controller_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@ func (ctrl *csiSnapshotCommonController) createSnapshotsForGroupSnapshotContent(
volumeSnapshotContent := &crdv1.VolumeSnapshotContent{
ObjectMeta: metav1.ObjectMeta{
Name: volumeSnapshotContentName,
Labels: map[string]string{
utils.VolumeGroupSnapshotHandleLabel: *groupSnapshotContent.Status.VolumeGroupSnapshotHandle,
Annotations: map[string]string{
utils.VolumeGroupSnapshotHandleAnnotation: *groupSnapshotContent.Status.VolumeGroupSnapshotHandle,
},
},
Spec: crdv1.VolumeSnapshotContentSpec{
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
6 changes: 3 additions & 3 deletions pkg/utils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ const (
// of a VolumeGroupSnapshot, and indicates the name of the latter.
VolumeGroupSnapshotNameLabel = "groupsnapshot.storage.k8s.io/volumeGroupSnapshotName"

// VolumeGroupSnapshotHandleLabel is applied to VolumeSnapshotContents that are member
// VolumeGroupSnapshotHandleAnnotation 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 55def14

Please sign in to comment.