From 6d92f2d1194a3aa29d05dfb1f3f8051e2d00a64f Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 22 Jan 2024 16:07:29 +0100 Subject: [PATCH] csi: use static name for cephfs/rbd use the static provisioner name for both cephfs and rbd csi driver irrespective of the namespace where they are deployed. Signed-off-by: Madhu Rajanna --- controllers/clusterversion_controller.go | 4 ++-- controllers/storageclassclaim_controller.go | 8 ++++---- pkg/csi/cephfsdaemonset.go | 6 +++--- pkg/csi/cephfsdeployment.go | 2 +- pkg/csi/csi.go | 8 ++++---- pkg/csi/rbddaemonset.go | 6 +++--- pkg/csi/rbddeployment.go | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/controllers/clusterversion_controller.go b/controllers/clusterversion_controller.go index a6607066..ab7aef6f 100644 --- a/controllers/clusterversion_controller.go +++ b/controllers/clusterversion_controller.go @@ -278,7 +278,7 @@ func (c *ClusterVersionReconciler) Reconcile(ctx context.Context, req ctrl.Reque // Need to handle deletion of the csiDriver object, we cannot set // ownerReference on it as its cluster scoped resource cephfsCSIDriver := templates.CephFSCSIDriver.DeepCopy() - cephfsCSIDriver.ObjectMeta.Name = csi.GetCephFSDriverName(c.OperatorNamespace) + cephfsCSIDriver.ObjectMeta.Name = csi.GetCephFSDriverName() err = csi.CreateCSIDriver(c.ctx, c.Client, cephfsCSIDriver) if err != nil { c.log.Error(err, "unable to create cephfs CSIDriver") @@ -286,7 +286,7 @@ func (c *ClusterVersionReconciler) Reconcile(ctx context.Context, req ctrl.Reque } rbdCSIDriver := templates.RbdCSIDriver.DeepCopy() - rbdCSIDriver.ObjectMeta.Name = csi.GetRBDDriverName(c.OperatorNamespace) + rbdCSIDriver.ObjectMeta.Name = csi.GetRBDDriverName() err = csi.CreateCSIDriver(c.ctx, c.Client, rbdCSIDriver) if err != nil { c.log.Error(err, "unable to create rbd CSIDriver") diff --git a/controllers/storageclassclaim_controller.go b/controllers/storageclassclaim_controller.go index 4c44f96f..00b1c7a8 100644 --- a/controllers/storageclassclaim_controller.go +++ b/controllers/storageclassclaim_controller.go @@ -461,7 +461,7 @@ func (r *StorageClassClaimReconciler) getCephFSStorageClass(data map[string]stri }, ReclaimPolicy: &pvReclaimPolicy, AllowVolumeExpansion: &allowVolumeExpansion, - Provisioner: fmt.Sprintf("%s.cephfs.csi.ceph.com", r.OperatorNamespace), + Provisioner: csi.GetCephFSDriverName(), Parameters: data, } return storageClass @@ -479,7 +479,7 @@ func (r *StorageClassClaimReconciler) getCephRBDStorageClass(data map[string]str }, ReclaimPolicy: &pvReclaimPolicy, AllowVolumeExpansion: &allowVolumeExpansion, - Provisioner: fmt.Sprintf("%s.rbd.csi.ceph.com", r.OperatorNamespace), + Provisioner: csi.GetRBDDriverName(), Parameters: data, } return storageClass @@ -490,7 +490,7 @@ func (r *StorageClassClaimReconciler) getCephFSVolumeSnapshotClass(data map[stri ObjectMeta: metav1.ObjectMeta{ Name: r.storageClassClaim.Name, }, - Driver: fmt.Sprintf("%s.cephfs.csi.ceph.com", r.OperatorNamespace), + Driver: csi.GetCephFSDriverName(), DeletionPolicy: snapapi.VolumeSnapshotContentDelete, Parameters: data, } @@ -502,7 +502,7 @@ func (r *StorageClassClaimReconciler) getCephRBDVolumeSnapshotClass(data map[str ObjectMeta: metav1.ObjectMeta{ Name: r.storageClassClaim.Name, }, - Driver: fmt.Sprintf("%s.rbd.csi.ceph.com", r.OperatorNamespace), + Driver: csi.GetRBDDriverName(), DeletionPolicy: snapapi.VolumeSnapshotContentDelete, Parameters: data, } diff --git a/pkg/csi/cephfsdaemonset.go b/pkg/csi/cephfsdaemonset.go index d40fff46..4d9ace2d 100644 --- a/pkg/csi/cephfsdaemonset.go +++ b/pkg/csi/cephfsdaemonset.go @@ -49,7 +49,7 @@ func GetCephFSDaemonSet(namespace string) *appsv1.DaemonSet { driverRegistrar.Args, fmt.Sprintf("--kubelet-registration-path=%s/plugins/%s/csi.sock", templates.DefaultKubeletDirPath, - GetCephFSDriverName(namespace)), + GetCephFSDriverName()), ) return &appsv1.DaemonSet{ ObjectMeta: metav1.ObjectMeta{ @@ -93,7 +93,7 @@ func GetCephFSDaemonSet(namespace string) *appsv1.DaemonSet { "--pidlimit=-1", "--type=cephfs", "--nodeserver=true", - fmt.Sprintf("--drivername=%s", GetCephFSDriverName(namespace)), + fmt.Sprintf("--drivername=%s", GetCephFSDriverName()), }, Resources: templates.CephFSPluginResourceRequirements, Env: []corev1.EnvVar{ @@ -230,7 +230,7 @@ func GetCephFSDaemonSet(namespace string) *appsv1.DaemonSet { Name: "plugin-dir", VolumeSource: corev1.VolumeSource{ HostPath: &corev1.HostPathVolumeSource{ - Path: fmt.Sprintf("%s/plugins/%s", templates.DefaultKubeletDirPath, GetCephFSDriverName(namespace)), + Path: fmt.Sprintf("%s/plugins/%s", templates.DefaultKubeletDirPath, GetCephFSDriverName()), Type: &hostPathDirectoryorCreate, }, }, diff --git a/pkg/csi/cephfsdeployment.go b/pkg/csi/cephfsdeployment.go index 4dbeb4d9..74e8196e 100644 --- a/pkg/csi/cephfsdeployment.go +++ b/pkg/csi/cephfsdeployment.go @@ -96,7 +96,7 @@ func GetCephFSDeployment(namespace string) *appsv1.Deployment { "--pidlimit=-1", "--type=cephfs", "--controllerserver=true", - fmt.Sprintf("--drivername=%s", GetCephFSDriverName(namespace)), + fmt.Sprintf("--drivername=%s", GetCephFSDriverName()), }, Resources: templates.CephFSPluginResourceRequirements, Env: []corev1.EnvVar{ diff --git a/pkg/csi/csi.go b/pkg/csi/csi.go index 79c307c6..41da28d5 100644 --- a/pkg/csi/csi.go +++ b/pkg/csi/csi.go @@ -75,11 +75,11 @@ func InitializeSidecars(ver string) error { } // GetCephFSDriverName returns the cephfs driver name -func GetCephFSDriverName(namespace string) string { - return fmt.Sprintf("%s.cephfs.csi.ceph.com", namespace) +func GetCephFSDriverName() string { + return "openshift-storage.cephfs.csi.ceph.com" } // GetRBDDriverName returns the rbd driver name -func GetRBDDriverName(namespace string) string { - return fmt.Sprintf("%s.rbd.csi.ceph.com", namespace) +func GetRBDDriverName() string { + return "openshift-storage.rbd.csi.ceph.com" } diff --git a/pkg/csi/rbddaemonset.go b/pkg/csi/rbddaemonset.go index 27d9a7b4..b4fdc314 100644 --- a/pkg/csi/rbddaemonset.go +++ b/pkg/csi/rbddaemonset.go @@ -61,7 +61,7 @@ func GetRBDDaemonSet(namespace string) *appsv1.DaemonSet { driverRegistrar.Args, fmt.Sprintf("--kubelet-registration-path=%s/plugins/%s/csi.sock", templates.DefaultKubeletDirPath, - GetRBDDriverName(namespace)), + GetRBDDriverName()), ) return &appsv1.DaemonSet{ ObjectMeta: metav1.ObjectMeta{ @@ -106,7 +106,7 @@ func GetRBDDaemonSet(namespace string) *appsv1.DaemonSet { "--pidlimit=-1", "--type=rbd", "--nodeserver=true", - fmt.Sprintf("--drivername=%s", GetRBDDriverName(namespace)), + fmt.Sprintf("--drivername=%s", GetRBDDriverName()), fmt.Sprintf("--stagingpath=%s/plugins/kubernetes.io/csi/", templates.DefaultKubeletDirPath), "--csi-addons-endpoint=$(CSIADDONS_ENDPOINT)", }, @@ -327,7 +327,7 @@ func GetRBDDaemonSet(namespace string) *appsv1.DaemonSet { Name: "plugin-dir", VolumeSource: corev1.VolumeSource{ HostPath: &corev1.HostPathVolumeSource{ - Path: fmt.Sprintf("%s/plugins/%s", templates.DefaultKubeletDirPath, GetRBDDriverName(namespace)), + Path: fmt.Sprintf("%s/plugins/%s", templates.DefaultKubeletDirPath, GetRBDDriverName()), Type: &hostPathDirectoryorCreate, }, }, diff --git a/pkg/csi/rbddeployment.go b/pkg/csi/rbddeployment.go index 1c3780fd..4cdd64bc 100644 --- a/pkg/csi/rbddeployment.go +++ b/pkg/csi/rbddeployment.go @@ -95,7 +95,7 @@ func GetRBDDeployment(namespace string) *appsv1.Deployment { "--pidlimit=-1", "--type=rbd", "--controllerserver=true", - fmt.Sprintf("--drivername=%s", GetRBDDriverName(namespace)), + fmt.Sprintf("--drivername=%s", GetRBDDriverName()), }, Resources: templates.RBDPluginResourceRequirements, Env: []corev1.EnvVar{