mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
cephfs: Add clusterName as metadata on snapshots
Example: sh-4.4$ ceph fs subvolume snapshot metadata ls myfs csi-vol-ba248f9e-0e75-11ed-b774-8e97192ff5ec \ csi-snap-ce24e3bb-0e75-11ed-b774-8e97192ff5ec --group_name csi { "csi.ceph.com/cluster/name": "\"K8s-cluster-1\"", "csi.storage.k8s.io/volumesnapshot/name": "cephfs-pvc-snapshot", "csi.storage.k8s.io/volumesnapshot/namespace": "rook-ceph", "csi.storage.k8s.io/volumesnapshotcontent/name": "snapcontent-2e89e1b2-e6e9-48fe-b365-edb493d7022e" } Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
56d7d3cd15
commit
de7128b3a2
@ -99,6 +99,14 @@ func (s *snapshotClient) SetAllSnapshotMetadata(parameters map[string]string) er
|
||||
}
|
||||
}
|
||||
|
||||
if s.clusterName != "" {
|
||||
err := s.setSnapshotMetadata(clusterNameKey, s.clusterName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to set metadata key %q, value %q on subvolume snapshot %s %s in fs %s: %w",
|
||||
clusterNameKey, s.clusterName, s.SnapshotID, s.VolID, s.FsName, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -114,5 +122,12 @@ func (s *snapshotClient) UnsetAllSnapshotMetadata(keys []string) error {
|
||||
}
|
||||
}
|
||||
|
||||
err := s.removeSnapshotMetadata(clusterNameKey)
|
||||
// TODO: replace string comparison with errno.
|
||||
if err != nil && !strings.Contains(err.Error(), "No such file or directory") {
|
||||
return fmt.Errorf("failed to unset metadata key %q on subvolume snapshot %s %s in fs %s: %w",
|
||||
clusterNameKey, s.SnapshotID, s.VolID, s.FsName, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user