From 319c5610ac77eb09620b4a9d3fa02555bc9d25b0 Mon Sep 17 00:00:00 2001 From: Malay Kumar Parida Date: Fri, 22 Sep 2023 11:16:25 +0530 Subject: [PATCH] When NFS is enabled on the storagecluster pass ROOK_CSI_ENABLE_NFS: true Earlier when enabling NFS the key needed to be passed manually to rook via patching the rook-ceph-operator-config cm. Now the key is passed automatically via env variable to the rook pod. Signed-off-by: Malay Kumar Parida --- .../ocsinitialization/ocsinitialization_controller.go | 1 + controllers/storagecluster/ocs_operator_config.go | 9 +++++++++ controllers/util/k8sutil.go | 1 + tools/csv-merger/csv-merger.go | 11 +++++++++++ 4 files changed, 22 insertions(+) diff --git a/controllers/ocsinitialization/ocsinitialization_controller.go b/controllers/ocsinitialization/ocsinitialization_controller.go index 02d93f5b31..ac7fdcce60 100644 --- a/controllers/ocsinitialization/ocsinitialization_controller.go +++ b/controllers/ocsinitialization/ocsinitialization_controller.go @@ -241,6 +241,7 @@ func (r *OCSInitializationReconciler) ensureOcsOperatorConfigExists(initialData util.ClusterNameKey: util.GetClusterID(r.ctx, r.Client, &r.Log), util.EnableReadAffinityKey: "true", util.CephFSKernelMountOptionsKey: "ms_mode=prefer-crc", + util.EnableNFSKey: "false", } ocsOperatorConfig := &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ diff --git a/controllers/storagecluster/ocs_operator_config.go b/controllers/storagecluster/ocs_operator_config.go index 2db47b2029..f18fb8f4ba 100644 --- a/controllers/storagecluster/ocs_operator_config.go +++ b/controllers/storagecluster/ocs_operator_config.go @@ -17,6 +17,7 @@ func (r *StorageClusterReconciler) ensureOCSOperatorConfig(sc *ocsv1.StorageClus util.ClusterNameKey: util.GetClusterID(r.ctx, r.Client, &r.Log), util.EnableReadAffinityKey: strconv.FormatBool(!sc.Spec.ExternalStorage.Enable), util.CephFSKernelMountOptionsKey: getCephFSKernelMountOptions(sc), + util.EnableNFSKey: getEnableNFSVal(sc), } cm := &corev1.ConfigMap{ @@ -80,3 +81,11 @@ func getCephFSKernelMountOptions(sc *ocsv1.StorageCluster) string { // so we need to set the mount options to prefer-crc return "ms_mode=prefer-crc" } + +// getEnableNFSVal returns the value of enableNFS based on the spec on the StorageCluster +func getEnableNFSVal(sc *ocsv1.StorageCluster) string { + if sc.Spec.NFS != nil && sc.Spec.NFS.Enable { + return "true" + } + return "false" +} diff --git a/controllers/util/k8sutil.go b/controllers/util/k8sutil.go index a73bab1c11..5137ba0763 100644 --- a/controllers/util/k8sutil.go +++ b/controllers/util/k8sutil.go @@ -29,6 +29,7 @@ const ( ClusterNameKey = "CSI_CLUSTER_NAME" EnableReadAffinityKey = "CSI_ENABLE_READ_AFFINITY" CephFSKernelMountOptionsKey = "CSI_CEPHFS_KERNEL_MOUNT_OPTIONS" + EnableNFSKey = "ROOK_CSI_ENABLE_NFS" ) // GetWatchNamespace returns the namespace the operator should be watching for changes diff --git a/tools/csv-merger/csv-merger.go b/tools/csv-merger/csv-merger.go index 1618d3275b..29cfe896d8 100644 --- a/tools/csv-merger/csv-merger.go +++ b/tools/csv-merger/csv-merger.go @@ -270,6 +270,17 @@ func unmarshalCSV(filePath string) *csvv1.ClusterServiceVersion { }, }, }, + { + Name: "ROOK_CSI_ENABLE_NFS", + ValueFrom: &corev1.EnvVarSource{ + ConfigMapKeyRef: &corev1.ConfigMapKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "ocs-operator-config", + }, + Key: "ROOK_CSI_ENABLE_NFS", + }, + }, + }, { Name: "CSI_PROVISIONER_TOLERATIONS", Value: `