Skip to content

Commit

Permalink
Merge pull request #2196 from malayparida2000/nfs_key
Browse files Browse the repository at this point in the history
Bug 2234664:[release-4.13] When NFS is enabled on the storagecluster pass ROOK_CSI_ENABLE_NFS: true
  • Loading branch information
openshift-ci[bot] authored Oct 3, 2023
2 parents 5303d93 + 44fd61f commit ce3954d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
2 changes: 2 additions & 0 deletions controllers/ocsinitialization/ocsinitialization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ func (r *OCSInitializationReconciler) ensureOcsOperatorConfigExists(initialData
clusterNameKey = "CSI_CLUSTER_NAME"
enableReadAffinityKey = "CSI_ENABLE_READ_AFFINITY"
cephFSKernelMountOptionsKey = "CSI_CEPHFS_KERNEL_MOUNT_OPTIONS"
enableNFSKey = "ROOK_CSI_ENABLE_NFS"
)
ocsOperatorConfig := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -248,6 +249,7 @@ func (r *OCSInitializationReconciler) ensureOcsOperatorConfigExists(initialData
clusterNameKey: "",
enableReadAffinityKey: "true",
cephFSKernelMountOptionsKey: "ms_mode=prefer-crc",
enableNFSKey: "false",
},
}
err := r.Client.Create(r.ctx, ocsOperatorConfig)
Expand Down
19 changes: 17 additions & 2 deletions controllers/storagecluster/ocs_operator_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ func (r *StorageClusterReconciler) ensureOCSOperatorConfig(sc *ocsv1.StorageClus
clusterNameKey = "CSI_CLUSTER_NAME"
enableReadAffinityKey = "CSI_ENABLE_READ_AFFINITY"
cephFSKernelMountOptionsKey = "CSI_CEPHFS_KERNEL_MOUNT_OPTIONS"
enableNFSKey = "ROOK_CSI_ENABLE_NFS"
)
var (
clusterNameVal = r.getClusterID()
enableReadAffinityVal = strconv.FormatBool(!sc.Spec.ExternalStorage.Enable)
cephFSKernelMountOptionVal = getCephFSKernelMountOptions(sc)
enableNFSVal = getEnableNFSVal(sc)
)

cm := &corev1.ConfigMap{
Expand All @@ -35,8 +37,10 @@ func (r *StorageClusterReconciler) ensureOCSOperatorConfig(sc *ocsv1.StorageClus
Namespace: sc.Namespace,
},
Data: map[string]string{
clusterNameKey: clusterNameVal,
enableReadAffinityKey: enableReadAffinityVal,
clusterNameKey: clusterNameVal,
enableReadAffinityKey: enableReadAffinityVal,
cephFSKernelMountOptionsKey: cephFSKernelMountOptionVal,
enableNFSKey: enableNFSVal,
},
}

Expand All @@ -58,6 +62,9 @@ func (r *StorageClusterReconciler) ensureOCSOperatorConfig(sc *ocsv1.StorageClus
if cm.Data[cephFSKernelMountOptionsKey] != cephFSKernelMountOptionVal {
cm.Data[cephFSKernelMountOptionsKey] = cephFSKernelMountOptionVal
}
if cm.Data[enableNFSKey] != enableNFSVal {
cm.Data[enableNFSKey] = enableNFSVal
}
return ctrl.SetControllerReference(sc, cm, r.Scheme)
})
if err != nil {
Expand Down Expand Up @@ -128,3 +135,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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3004,6 +3004,11 @@ spec:
configMapKeyRef:
key: CSI_CEPHFS_KERNEL_MOUNT_OPTIONS
name: ocs-operator-config
- name: ROOK_CSI_ENABLE_NFS
valueFrom:
configMapKeyRef:
key: ROOK_CSI_ENABLE_NFS
name: ocs-operator-config
- name: CSI_PROVISIONER_TOLERATIONS
value: |2-
Expand Down
11 changes: 11 additions & 0 deletions tools/csv-merger/csv-merger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: `
Expand Down

0 comments on commit ce3954d

Please sign in to comment.