rbd: update PV/PVC metadata on a reattach of PV

Example if a PVC was delete by setting `persistentVolumeReclaimPolicy` as
`Retain` on PV, and PV is reattached to a new PVC, we make sure to update
PV/PVC image metadata on a PV reattach.

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
Prasanna Kumar Kalever
2022-02-21 16:54:24 +05:30
committed by mergify[bot]
parent 0119d69ab2
commit ae5925f04c
3 changed files with 37 additions and 2 deletions

View File

@ -63,3 +63,19 @@ func GetVolumeMetadata(parameters map[string]string) map[string]string {
return newParam
}
// PrepareVolumeMetadata return PV/PVC/PVCNamespace metadata based on inputs.
func PrepareVolumeMetadata(pvcName, pvcNamespace, pvName string) map[string]string {
newParam := map[string]string{}
if pvcName != "" {
newParam[pvcNameKey] = pvcName
}
if pvcNamespace != "" {
newParam[pvcNamespaceKey] = pvcNamespace
}
if pvName != "" {
newParam[pvNameKey] = pvName
}
return newParam
}