Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 2279992: csi: add a new flag to disable csi driver #647

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Documentation/Helm-Charts/operator-chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ The following table lists the configurable parameters of the rook-operator chart
| `csi.csiRBDPluginVolume` | The volume of the CephCSI RBD plugin DaemonSet | `nil` |
| `csi.csiRBDPluginVolumeMount` | The volume mounts of the CephCSI RBD plugin DaemonSet | `nil` |
| `csi.csiRBDProvisionerResource` | CEPH CSI RBD provisioner resource requirement list csi-omap-generator resources will be applied only if `enableOMAPGenerator` is set to `true` | see values.yaml |
| `csi.disableCsiDriver` | Disable the CSI driver. | `"false"` |
| `csi.enableCSIEncryption` | Enable Ceph CSI PVC encryption support | `false` |
| `csi.enableCSIHostNetwork` | Enable host networking for CSI CephFS and RBD nodeplugins. This may be necessary in some network configurations where the SDN does not provide access to an external cluster or there is significant drop in read/write performance | `true` |
| `csi.enableCephfsDriver` | Enable Ceph CSI CephFS driver | `true` |
Expand Down
1 change: 1 addition & 0 deletions deploy/charts/rook-ceph/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ data:
{{- if .Values.csi }}
ROOK_CSI_ENABLE_RBD: {{ .Values.csi.enableRbdDriver | quote }}
ROOK_CSI_ENABLE_CEPHFS: {{ .Values.csi.enableCephfsDriver | quote }}
ROOK_CSI_DISABLE_DRIVER: {{ .Values.csi.disableCsiDriver | quote }}
CSI_ENABLE_CEPHFS_SNAPSHOTTER: {{ .Values.csi.enableCephfsSnapshotter | quote }}
CSI_ENABLE_NFS_SNAPSHOTTER: {{ .Values.csi.enableNFSSnapshotter | quote }}
CSI_ENABLE_RBD_SNAPSHOTTER: {{ .Values.csi.enableRBDSnapshotter | quote }}
Expand Down
3 changes: 3 additions & 0 deletions deploy/charts/rook-ceph/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ csi:
enableRbdDriver: true
# -- Enable Ceph CSI CephFS driver
enableCephfsDriver: true
# -- Disable the CSI driver.
disableCsiDriver: "false"

# -- Enable host networking for CSI CephFS and RBD nodeplugins. This may be necessary
# in some network configurations where the SDN does not provide access to an external cluster or
# there is significant drop in read/write performance
Expand Down
2 changes: 2 additions & 0 deletions deploy/examples/operator-openshift.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ data:
ROOK_CSI_ENABLE_RBD: "true"
# Enable the CSI NFS driver. To start another version of the CSI driver, see image properties below.
ROOK_CSI_ENABLE_NFS: "false"
# Disable the CSI driver.
ROOK_CSI_DISABLE_DRIVER: "false"

# Set to true to enable Ceph CSI pvc encryption support.
CSI_ENABLE_ENCRYPTION: "false"
Expand Down
2 changes: 2 additions & 0 deletions deploy/examples/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ data:
ROOK_CSI_ENABLE_RBD: "true"
# Enable the CSI NFS driver. To start another version of the CSI driver, see image properties below.
ROOK_CSI_ENABLE_NFS: "false"
# Disable the CSI driver.
ROOK_CSI_DISABLE_DRIVER: "false"

# Set to true to enable Ceph CSI pvc encryption support.
CSI_ENABLE_ENCRYPTION: "false"
Expand Down
46 changes: 28 additions & 18 deletions pkg/operator/ceph/csi/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,34 @@ func (r *ReconcileCSI) reconcile(request reconcile.Request) (reconcile.Result, e
// reconcileResult is used to communicate the result of the reconciliation back to the caller
var reconcileResult reconcile.Result

// Fetch the operator's configmap. We force the NamespaceName to the operator since the request
// could be a CephCluster. If so the NamespaceName will be the one from the cluster and thus the
// CM won't be found
opNamespaceName := types.NamespacedName{Name: opcontroller.OperatorSettingConfigMapName, Namespace: r.opConfig.OperatorNamespace}
opConfig := &v1.ConfigMap{}
err := r.client.Get(r.opManagerContext, opNamespaceName, opConfig)
if err != nil {
if kerrors.IsNotFound(err) {
logger.Debug("operator's configmap resource not found. will use default value or env var.")
r.opConfig.Parameters = make(map[string]string)
} else {
// Error reading the object - requeue the request.
return opcontroller.ImmediateRetryResult, errors.Wrap(err, "failed to get operator's configmap")
}
} else {
// Populate the operator's config
r.opConfig.Parameters = opConfig.Data
}

// do not recocnile if csi driver is disabled
disableCSI, err := strconv.ParseBool(k8sutil.GetValue(r.opConfig.Parameters, "ROOK_CSI_DISABLE_DRIVER", "false"))
if err != nil {
return reconcile.Result{}, errors.Wrap(err, "unable to parse value for 'ROOK_CSI_DISABLE_DRIVER")
} else if disableCSI {
logger.Info("ceph csi driver is disabled")
return reconcile.Result{}, nil
}

serverVersion, err := r.context.Clientset.Discovery().ServerVersion()
if err != nil {
return opcontroller.ImmediateRetryResult, errors.Wrap(err, "failed to get server version")
Expand Down Expand Up @@ -168,24 +196,6 @@ func (r *ReconcileCSI) reconcile(request reconcile.Request) (reconcile.Result, e

return reconcile.Result{}, nil
}
// Fetch the operator's configmap. We force the NamespaceName to the operator since the request
// could be a CephCluster. If so the NamespaceName will be the one from the cluster and thus the
// CM won't be found
opNamespaceName := types.NamespacedName{Name: opcontroller.OperatorSettingConfigMapName, Namespace: r.opConfig.OperatorNamespace}
opConfig := &v1.ConfigMap{}
err = r.client.Get(r.opManagerContext, opNamespaceName, opConfig)
if err != nil {
if kerrors.IsNotFound(err) {
logger.Debug("operator's configmap resource not found. will use default value or env var.")
r.opConfig.Parameters = make(map[string]string)
} else {
// Error reading the object - requeue the request.
return opcontroller.ImmediateRetryResult, errors.Wrap(err, "failed to get operator's configmap")
}
} else {
// Populate the operator's config
r.opConfig.Parameters = opConfig.Data
}

csiHostNetworkEnabled, err := strconv.ParseBool(k8sutil.GetValue(r.opConfig.Parameters, "CSI_ENABLE_HOST_NETWORK", "true"))
if err != nil {
Expand Down
Loading