From 82c82bbe13e4e34e0dab5cf2aec9fc7427d3213d Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Wed, 8 Jan 2025 16:02:27 -0700 Subject: [PATCH 1/2] core: remove unnecessary param to watch namespaces Cleanup obsolete code where the context no longer needs to be passed as a parameter to determine the namespaces to watch. Signed-off-by: Travis Nielsen --- pkg/operator/ceph/operator.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/operator/ceph/operator.go b/pkg/operator/ceph/operator.go index 410cdc526..e43ba8c78 100644 --- a/pkg/operator/ceph/operator.go +++ b/pkg/operator/ceph/operator.go @@ -131,7 +131,7 @@ func (o *Operator) runCRDManager() { // The operator config manager is also watching for changes here so if the operator config map // content changes for ROOK_CURRENT_NAMESPACE_ONLY we must reload the operator CRD manager - o.namespaceToWatch(opManagerContext) + o.namespaceToWatch() // Pass the parent context to the cluster controller so that the monitoring go routines can // consume it to terminate gracefully @@ -148,11 +148,11 @@ func (o *Operator) runCRDManager() { }() } -func (o *Operator) namespaceToWatch(context context.Context) { +func (o *Operator) namespaceToWatch() { currentNamespaceOnly, _ := k8sutil.GetOperatorSetting(opManagerContext, o.context.Clientset, opcontroller.OperatorSettingConfigMapName, "ROOK_CURRENT_NAMESPACE_ONLY", "true") if currentNamespaceOnly == "true" { o.config.NamespaceToWatch = o.config.OperatorNamespace - logger.Infof("watching the current namespace %q for a Ceph CRs", o.config.OperatorNamespace) + logger.Infof("watching the current namespace %q for Ceph CRs", o.config.OperatorNamespace) } else { o.config.NamespaceToWatch = v1.NamespaceAll logger.Infof("watching all namespaces for Ceph CRs") From ac1767fa0f724a5f385492f9f25e8f962c031616 Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Wed, 8 Jan 2025 16:04:27 -0700 Subject: [PATCH 2/2] csi: set correct driver name with csi operator When the cluster is in a different namespace from the rook operator, the csi provider name was setting the incorrect namespace prefix. Now the prefix will be the same as the ceph cluster namespace. Signed-off-by: Travis Nielsen --- pkg/operator/ceph/csi/operator_driver.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/operator/ceph/csi/operator_driver.go b/pkg/operator/ceph/csi/operator_driver.go index 0a3fa8107..ae111c6a8 100644 --- a/pkg/operator/ceph/csi/operator_driver.go +++ b/pkg/operator/ceph/csi/operator_driver.go @@ -77,7 +77,7 @@ func (r *ReconcileCSI) createOrUpdateDriverResources(cluster cephv1.CephCluster, } func (r *ReconcileCSI) createOrUpdateRBDDriverResource(cluster cephv1.CephCluster, clusterInfo *cephclient.ClusterInfo) error { - resourceName := fmt.Sprintf("%s.rbd.csi.ceph.com", r.opConfig.OperatorNamespace) + resourceName := fmt.Sprintf("%s.rbd.csi.ceph.com", cluster.Namespace) spec, err := r.generateDriverSpec(cluster.Name) if err != nil { return err @@ -116,14 +116,14 @@ func (r *ReconcileCSI) createOrUpdateRBDDriverResource(cluster cephv1.CephCluste err = r.createOrUpdateDriverResource(clusterInfo, rbdDriver) if err != nil { - return errors.Wrapf(err, "failed to create or update RDB driver resource %q", rbdDriver.Name) + return errors.Wrapf(err, "failed to create or update RBD driver resource %q", rbdDriver.Name) } return nil } func (r *ReconcileCSI) createOrUpdateCephFSDriverResource(cluster cephv1.CephCluster, clusterInfo *cephclient.ClusterInfo) error { - resourceName := fmt.Sprintf("%s.cephfs.csi.ceph.com", r.opConfig.OperatorNamespace) + resourceName := fmt.Sprintf("%s.cephfs.csi.ceph.com", cluster.Namespace) spec, err := r.generateDriverSpec(cluster.Name) if err != nil { return err @@ -175,7 +175,7 @@ func (r *ReconcileCSI) createOrUpdateCephFSDriverResource(cluster cephv1.CephClu } func (r *ReconcileCSI) createOrUpdateNFSDriverResource(cluster cephv1.CephCluster, clusterInfo *cephclient.ClusterInfo) error { - resourceName := fmt.Sprintf("%s.nfs.csi.ceph.com", r.opConfig.OperatorNamespace) + resourceName := fmt.Sprintf("%s.nfs.csi.ceph.com", cluster.Namespace) spec, err := r.generateDriverSpec(cluster.Name) if err != nil { return err