Skip to content

Commit

Permalink
Merge pull request #2975 from iamniting/configmap
Browse files Browse the repository at this point in the history
set ROOK_CSI_ENABLE_CEPHFS in the ocs-operator-config configmap
  • Loading branch information
openshift-merge-bot[bot] authored Jan 23, 2025
2 parents 241dd7c + 1101755 commit 20f61df
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
25 changes: 25 additions & 0 deletions controllers/ocsinitialization/ocsinitialization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,19 @@ func (r *OCSInitializationReconciler) ensureOcsOperatorConfigExists(initialData
return sc.Spec.AllowRemoteStorageConsumers
})

enableCephfsVal, err := r.getEnableCephfsKeyValue()
if err != nil {
r.Log.Error(err, "Failed to get enableCephfsKeyValue")
return err
}

ocsOperatorConfigData := map[string]string{
util.ClusterNameKey: util.GetClusterID(r.ctx, r.Client, &r.Log),
util.RookCurrentNamespaceOnlyKey: strconv.FormatBool(!(len(r.clusters.GetStorageClusters()) > 1)),
util.EnableTopologyKey: r.getEnableTopologyKeyValue(),
util.TopologyDomainLabelsKey: r.getTopologyDomainLabelsKeyValue(),
util.EnableNFSKey: r.getEnableNFSKeyValue(),
util.EnableCephfsKey: enableCephfsVal,
util.DisableCSIDriverKey: strconv.FormatBool(allowConsumers),
}

Expand Down Expand Up @@ -603,6 +610,24 @@ func (r *OCSInitializationReconciler) getEnableNFSKeyValue() string {
return "false"
}

func (r *OCSInitializationReconciler) getEnableCephfsKeyValue() (string, error) {

// list all storage classes and check if any of them is using cephfs
storageClasses := &storagev1.StorageClassList{}
if err := r.Client.List(r.ctx, storageClasses); err != nil {
r.Log.Error(err, "Failed to list storage classes")
return "", err
}

for _, sc := range storageClasses.Items {
if strings.HasSuffix(sc.Provisioner, "cephfs.csi.ceph.com") {
return "true", nil
}
}

return "false", nil
}

func getFailureDomainKeyFromStorageClassParameter(sc *storagev1.StorageClass) string {
failuredomain := sc.Parameters["topologyFailureDomainLabel"]
if failuredomain == "zone" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/stretchr/testify/assert"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
storagev1 "k8s.io/api/storage/v1"
extensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -120,6 +121,11 @@ func createFakeScheme(t *testing.T) *runtime.Scheme {
assert.Fail(t, "failed to add extensionsv1 scheme")
}

err = storagev1.AddToScheme(scheme)
if err != nil {
assert.Fail(t, "failed to add storagev1 scheme")
}

return scheme
}

Expand Down
1 change: 1 addition & 0 deletions controllers/util/k8sutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const (
TopologyDomainLabelsKey = "CSI_TOPOLOGY_DOMAIN_LABELS"
EnableNFSKey = "ROOK_CSI_ENABLE_NFS"
DisableCSIDriverKey = "ROOK_CSI_DISABLE_DRIVER"
EnableCephfsKey = "ROOK_CSI_ENABLE_CEPHFS"

// This is the name for the FieldIndex
OwnerUIDIndexName = "ownerUID"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 20f61df

Please sign in to comment.