mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rbd: set cluster Name as metadata on the image
This change helps read the cluster name from the cmdline args, the provisioner will set the same on the RBD images. Fixes: #2973 Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
deb003e605
commit
2880c25fd6
@ -78,6 +78,9 @@ const (
|
||||
|
||||
// krbd attribute file to check supported features.
|
||||
krbdSupportedFeaturesFile = "/sys/bus/rbd/supported_features"
|
||||
|
||||
// clusterNameKey cluster Key, set on RBD image.
|
||||
clusterNameKey = "csi.ceph.com/cluster/name"
|
||||
)
|
||||
|
||||
// rbdImage contains common attributes and methods for the rbdVolume and
|
||||
@ -121,6 +124,9 @@ type rbdImage struct {
|
||||
// Primary represent if the image is primary or not.
|
||||
Primary bool
|
||||
|
||||
// Cluster name
|
||||
ClusterName string
|
||||
|
||||
// encryption provides access to optional VolumeEncryption functions
|
||||
encryption *util.VolumeEncryption
|
||||
// Owner is the creator (tenant, Kubernetes Namespace) of the volume
|
||||
@ -2001,6 +2007,14 @@ func (rv *rbdVolume) setAllMetadata(parameters map[string]string) error {
|
||||
}
|
||||
}
|
||||
|
||||
if rv.ClusterName != "" {
|
||||
err := rv.SetMetadata(clusterNameKey, rv.ClusterName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to set metadata key %q, value %q on image: %w",
|
||||
clusterNameKey, rv.ClusterName, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user