Skip to content

Commit

Permalink
map pv annotations from storageClass while restore
Browse files Browse the repository at this point in the history
Signed-off-by: rakeshgm <[email protected]>
  • Loading branch information
rakeshgm authored and ShyamsundarR committed Nov 17, 2024
1 parent e4180c5 commit 591325b
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions internal/controller/vrg_volrep.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,21 @@ const (
//nolint:gosec
const (
// secretRef keys
controllerPublishSecretName = "csi.storage.k8s.io/controller-publish-secret-name"
controllerPublishSecretNamespace = "csi.storage.k8s.io/controller-publish-secret-namespace"
nodeStageSecretName = "csi.storage.k8s.io/node-stage-secret-name"
nodeStageSecretNamespace = "csi.storage.k8s.io/node-stage-secret-namespace"
nodePublishSecretName = "csi.storage.k8s.io/node-publish-secret-name"
nodePublishSecretNamespace = "csi.storage.k8s.io/node-publish-secret-namespace"
controllerExpandSecretName = "csi.storage.k8s.io/controller-expand-secret-name"
controllerExpandSecretNamespace = "csi.storage.k8s.io/controller-expand-secret-namespace"
nodeExpandSecretName = "csi.storage.k8s.io/node-expand-secret-name"
nodeExpandSecretNamespace = "csi.storage.k8s.io/node-expand-secret-namespace"
controllerPublishSecretName = "csi.storage.k8s.io/controller-publish-secret-name"
controllerPublishSecretNamespace = "csi.storage.k8s.io/controller-publish-secret-namespace"
nodeStageSecretName = "csi.storage.k8s.io/node-stage-secret-name"
nodeStageSecretNamespace = "csi.storage.k8s.io/node-stage-secret-namespace"
nodePublishSecretName = "csi.storage.k8s.io/node-publish-secret-name"
nodePublishSecretNamespace = "csi.storage.k8s.io/node-publish-secret-namespace"
controllerExpandSecretName = "csi.storage.k8s.io/controller-expand-secret-name"
controllerExpandSecretNamespace = "csi.storage.k8s.io/controller-expand-secret-namespace"
nodeExpandSecretName = "csi.storage.k8s.io/node-expand-secret-name"
nodeExpandSecretNamespace = "csi.storage.k8s.io/node-expand-secret-namespace"
provisionerSecretName = "csi.storage.k8s.io/provisioner-secret-name"
provisionerSecretNamespace = "csi.storage.k8s.io/provisioner-secret-namespace"
provisionerDeletionSecretName = "volume.kubernetes.io/provisioner-deletion-secret-name"
provisionerDeletionSecretNamespace = "volume.kubernetes.io/provisioner-deletion-secret-namespace"
provisionerKeyName = "pv.kubernetes.io/provisioned-by"
)

func logWithPvcName(log logr.Logger, pvc *corev1.PersistentVolumeClaim) logr.Logger {
Expand Down Expand Up @@ -2431,6 +2436,17 @@ func (v *VRGInstance) processPVSecrets(pv *corev1.PersistentVolume) error {
pv.Spec.CSI.ControllerExpandSecretRef = secFromSC
}

// the value for provisionerSecretName and provisionerDeletionSecretName are allways same. so we check
// if provisionerSecretName name exists in storageClass and if exists we populate PV Annotation with
// provisionerDeletionSecretName with the values from provisionerSecretName and its namespace values.
secFromSC, exists = secretsFromSC(sc.Parameters, provisionerSecretName, provisionerSecretNamespace)
if exists {
rmnutil.AddAnnotation(pv, provisionerDeletionSecretName, secFromSC.Name)
rmnutil.AddAnnotation(pv, provisionerDeletionSecretNamespace, secFromSC.Namespace)
}

rmnutil.AddAnnotation(pv, provisionerKeyName, sc.Provisioner)

return nil
}

Expand Down

0 comments on commit 591325b

Please sign in to comment.