Use const to represent snapshot.storage.kubernetes.io/managed-by.

Signed-off-by: Xun Jiang <xun.jiang@broadcom.com>
This commit is contained in:
Xun Jiang
2025-07-29 11:44:04 +08:00
committed by Xun Jiang/Bruce Jiang
parent 8678ea28ee
commit 7b872473df
2 changed files with 7 additions and 2 deletions

View File

@@ -471,8 +471,8 @@ func (e *csiSnapshotExposer) createBackupVSC(ctx context.Context, ownerObject co
https://github.com/kubernetes-csi/external-snapshotter/tree/4cedb3f45790ac593ebfa3324c490abedf739477?tab=readme-ov-file#distributed-snapshotting
https://github.com/kubernetes-csi/external-snapshotter/blob/4cedb3f45790ac593ebfa3324c490abedf739477/pkg/utils/util.go#L158
*/
if manager, ok := snapshotVSC.Labels["snapshot.storage.kubernetes.io/managed-by"]; ok {
vsc.ObjectMeta.Labels["snapshot.storage.kubernetes.io/managed-by"] = manager
if manager, ok := snapshotVSC.Labels[kube.VolumeSnapshotContentManagedByLabel]; ok {
vsc.ObjectMeta.Labels[kube.VolumeSnapshotContentManagedByLabel] = manager
}
return e.csiSnapshotClient.VolumeSnapshotContents().Create(ctx, vsc, metav1.CreateOptions{})

View File

@@ -53,6 +53,11 @@ const (
KubeAnnSelectedNode = "volume.kubernetes.io/selected-node"
)
// VolumeSnapshotContentManagedByLabel is applied by the snapshot controller
// to the VolumeSnapshotContent object in case distributed snapshotting is enabled.
// The value contains the name of the node that handles the snapshot for the volume local to that node.
const VolumeSnapshotContentManagedByLabel = "snapshot.storage.kubernetes.io/managed-by"
var ErrorPodVolumeIsNotPVC = errors.New("pod volume is not a PVC")
// NamespaceAndName returns a string in the format <namespace>/<name>