From 884294952c1413c48a3f2cdad6f67e01e2eeeb1e Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Thu, 10 Mar 2022 10:19:18 -0700 Subject: [PATCH 1/2] csi: log a warning if pod namespace env var not found If the pod namespace was not found by the csi helper to update the mon endpoints configmap, the reconcile was failing. To allow for the update to continue in unit tests and ignore the env var, we only log the warning instead of failing the reconcile. Signed-off-by: Travis Nielsen (cherry picked from commit 76b349d80897d3da58eb5bf113605734244d9a7f) --- pkg/operator/ceph/csi/cluster_config.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/operator/ceph/csi/cluster_config.go b/pkg/operator/ceph/csi/cluster_config.go index 3f4ad3b8c..a8df1ce88 100644 --- a/pkg/operator/ceph/csi/cluster_config.go +++ b/pkg/operator/ceph/csi/cluster_config.go @@ -195,16 +195,17 @@ func SaveClusterConfig(clientset kubernetes.Interface, clusterNamespace string, return nil } - configMutex.Lock() - defer configMutex.Unlock() - // csi is deployed into the same namespace as the operator csiNamespace := os.Getenv(k8sutil.PodNamespaceEnvVar) if csiNamespace == "" { - return errors.Errorf("namespace value missing for %q", k8sutil.PodNamespaceEnvVar) + logger.Warningf("cannot save csi config due to missing env var %q", k8sutil.PodNamespaceEnvVar) + return nil } logger.Debugf("using %q for csi configmap namespace", csiNamespace) + configMutex.Lock() + defer configMutex.Unlock() + // fetch current ConfigMap contents configMap, err := clientset.CoreV1().ConfigMaps(csiNamespace).Get(clusterInfo.Context, ConfigName, metav1.GetOptions{}) if err != nil { From e1ef97372aafcb7656d504a83f18a9b7fbf6bbb2 Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Thu, 10 Mar 2022 10:20:18 -0700 Subject: [PATCH 2/2] csi: populate mon endpoints even if driver not enabled If the csi driver was enabled at a later time, the mon endpoints would not be populated. The populate the csi config, either a new cluster reconcile or restarting the operator would be necessary. It is simpler just to update the csi configmap with every reconcile even if the csi driver is not enabled. Signed-off-by: Travis Nielsen (cherry picked from commit 8bce38fadb6a21d91bacf35a26c9f085e6e9a6f4) --- pkg/operator/ceph/csi/cluster_config.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pkg/operator/ceph/csi/cluster_config.go b/pkg/operator/ceph/csi/cluster_config.go index a8df1ce88..1c95b4bf2 100644 --- a/pkg/operator/ceph/csi/cluster_config.go +++ b/pkg/operator/ceph/csi/cluster_config.go @@ -190,11 +190,6 @@ func CreateCsiConfigMap(namespace string, clientset kubernetes.Interface, ownerI // The locker l is typically a mutex and is used to prevent the config // map from being updated for multiple clusters simultaneously. func SaveClusterConfig(clientset kubernetes.Interface, clusterNamespace string, clusterInfo *cephclient.ClusterInfo, newCsiClusterConfigEntry *CsiClusterConfigEntry) error { - if !CSIEnabled() { - logger.Debug("skipping csi config update because csi is not enabled") - return nil - } - // csi is deployed into the same namespace as the operator csiNamespace := os.Getenv(k8sutil.PodNamespaceEnvVar) if csiNamespace == "" {