diff --git a/controllers/ocsinitialization/ocsinitialization_controller.go b/controllers/ocsinitialization/ocsinitialization_controller.go index 0f62229d70..3e6c1b431d 100644 --- a/controllers/ocsinitialization/ocsinitialization_controller.go +++ b/controllers/ocsinitialization/ocsinitialization_controller.go @@ -345,9 +345,23 @@ func (r *OCSInitializationReconciler) ensureOcsOperatorConfigExists(initialData Name: util.OcsOperatorConfigName, Namespace: initialData.Namespace, }, - Data: ocsOperatorConfigData, } opResult, err := ctrl.CreateOrUpdate(r.ctx, r.Client, ocsOperatorConfig, func() error { + + // If the configmap is being created for the first time, set the entry for + // CSI_REMOVE_HOLDER_PODS to "true". This configuration is applied for new clusters + // starting from ODF version 4.16 onwards. For old or upgraded clusters, + // it's initially set to "false", allowing users time to manually migrate from holder pods. + // In ODF version 4.17, we will universally set it to "true" for all users. + + if ocsOperatorConfig.CreationTimestamp.IsZero() { + ocsOperatorConfigData[util.CsiRemoveHolderPodsKey] = "true" + } else if ocsOperatorConfig.Data[util.CsiRemoveHolderPodsKey] == "" { + ocsOperatorConfigData[util.CsiRemoveHolderPodsKey] = "false" + } else if ocsOperatorConfig.Data[util.CsiRemoveHolderPodsKey] != "" { + ocsOperatorConfigData[util.CsiRemoveHolderPodsKey] = ocsOperatorConfig.Data[util.CsiRemoveHolderPodsKey] + } + if !reflect.DeepEqual(ocsOperatorConfig.Data, ocsOperatorConfigData) { r.Log.Info("Updating ocs-operator-config configmap") ocsOperatorConfig.Data = ocsOperatorConfigData diff --git a/controllers/util/k8sutil.go b/controllers/util/k8sutil.go index 2b4f66c545..682dcbb590 100644 --- a/controllers/util/k8sutil.go +++ b/controllers/util/k8sutil.go @@ -35,6 +35,7 @@ const ( EnableTopologyKey = "CSI_ENABLE_TOPOLOGY" TopologyDomainLabelsKey = "CSI_TOPOLOGY_DOMAIN_LABELS" EnableNFSKey = "ROOK_CSI_ENABLE_NFS" + CsiRemoveHolderPodsKey = "CSI_REMOVE_HOLDER_PODS" ) // GetWatchNamespace returns the namespace the operator should be watching for changes