Skip to content

Commit

Permalink
Merge pull request #2429 from Madhu-1/csi-prefix
Browse files Browse the repository at this point in the history
add CSI_DRIVER_NAME_PREFIX to Rook config
  • Loading branch information
openshift-merge-bot[bot] authored Jan 31, 2024
2 parents f8deb54 + e22a728 commit 13a9dfb
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
4 changes: 2 additions & 2 deletions controllers/storagecluster/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ func generateNameForSnapshotClass(initData *ocsv1.StorageCluster, snapshotType S
return fmt.Sprintf("%s-%splugin-snapclass", initData.Name, snapshotType)
}

func generateNameForSnapshotClassDriver(initData *ocsv1.StorageCluster, snapshotType SnapshotterType) string {
return fmt.Sprintf("%s.%s.csi.ceph.com", initData.Namespace, snapshotType)
func generateNameForSnapshotClassDriver(snapshotType SnapshotterType) string {
return fmt.Sprintf("%s.%s.csi.ceph.com", csiDriverNamePrefix, snapshotType)
}

func generateNameForSnapshotClassSecret(instance *ocsv1.StorageCluster, snapshotType SnapshotterType) string {
Expand Down
27 changes: 16 additions & 11 deletions controllers/storagecluster/storageclasses.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ import (
const (
storageClassSkippedError = "some StorageClasses were skipped while waiting for pre-requisites to be met"
defaultStorageClassAnnotation = "storageclass.kubernetes.io/is-default-class"

//csi driver name prefix
csiDriverNamePrefix = "openshift-storage"
)

var (
rbdDriverName = csiDriverNamePrefix + ".rbd.csi.ceph.com"
cephFSDriverName = csiDriverNamePrefix + ".cephfs.csi.ceph.com"
nfsDriverName = csiDriverNamePrefix + ".nfs.csi.ceph.com"
)

// StorageClassConfiguration provides configuration options for a StorageClass.
Expand Down Expand Up @@ -92,10 +101,6 @@ func (obj *ocsStorageClass) ensureDeleted(r *StorageClusterReconciler, instance
}

func (r *StorageClusterReconciler) createStorageClasses(sccs []StorageClassConfiguration, namespace string) error {
operatorNamespace, err := util.GetOperatorNamespace()
if err != nil {
return err
}
var skippedSC []string
for _, scc := range sccs {
if scc.reconcileStrategy == ReconcileStrategyIgnore || scc.disable {
Expand All @@ -104,7 +109,7 @@ func (r *StorageClusterReconciler) createStorageClasses(sccs []StorageClassConfi
sc := scc.storageClass

switch {
case (strings.Contains(sc.Name, "-ceph-rbd") || strings.Contains(sc.Provisioner, fmt.Sprintf("%s.rbd.csi.ceph.com", operatorNamespace))) && !scc.isClusterExternal:
case (strings.Contains(sc.Name, "-ceph-rbd") || strings.Contains(sc.Provisioner, rbdDriverName)) && !scc.isClusterExternal:
// wait for CephBlockPool to be ready
cephBlockPool := cephv1.CephBlockPool{}
key := types.NamespacedName{Name: sc.Parameters["pool"], Namespace: namespace}
Expand Down Expand Up @@ -166,7 +171,7 @@ func (r *StorageClusterReconciler) createStorageClasses(sccs []StorageClassConfi
skippedSC = append(skippedSC, sc.Name)
continue
}
case (strings.Contains(sc.Name, "-cephfs") || strings.Contains(sc.Provisioner, fmt.Sprintf("%s.cephfs.csi.ceph.com", operatorNamespace))) && !scc.isClusterExternal:
case (strings.Contains(sc.Name, "-cephfs") || strings.Contains(sc.Provisioner, cephFSDriverName)) && !scc.isClusterExternal:
// wait for CephFilesystem to be ready
cephFilesystem := cephv1.CephFilesystem{}
key := types.NamespacedName{Name: sc.Parameters["fsName"], Namespace: namespace}
Expand All @@ -179,7 +184,7 @@ func (r *StorageClusterReconciler) createStorageClasses(sccs []StorageClassConfi
skippedSC = append(skippedSC, sc.Name)
continue
}
case strings.Contains(sc.Name, "-nfs") || strings.Contains(sc.Provisioner, fmt.Sprintf("%s.nfs.csi.ceph.com", operatorNamespace)):
case strings.Contains(sc.Name, "-nfs") || strings.Contains(sc.Provisioner, nfsDriverName):
// wait for CephNFS to be ready
cephNFS := cephv1.CephNFS{}
key := types.NamespacedName{Name: sc.Parameters["nfsCluster"], Namespace: namespace}
Expand Down Expand Up @@ -250,7 +255,7 @@ func newCephFilesystemStorageClassConfiguration(initData *ocsv1.StorageCluster)
"description": "Provides RWO and RWX Filesystem volumes",
},
},
Provisioner: fmt.Sprintf("%s.cephfs.csi.ceph.com", os.Getenv(util.OperatorNamespaceEnvVar)),
Provisioner: cephFSDriverName,
ReclaimPolicy: &persistentVolumeReclaimDelete,
// AllowVolumeExpansion is set to true to enable expansion of OCS backed Volumes
AllowVolumeExpansion: &allowVolumeExpansion,
Expand Down Expand Up @@ -284,7 +289,7 @@ func newCephBlockPoolStorageClassConfiguration(initData *ocsv1.StorageCluster) S
"description": "Provides RWO Filesystem volumes, and RWO and RWX Block volumes",
},
},
Provisioner: fmt.Sprintf("%s.rbd.csi.ceph.com", os.Getenv(util.OperatorNamespaceEnvVar)),
Provisioner: rbdDriverName,
ReclaimPolicy: &persistentVolumeReclaimDelete,
// AllowVolumeExpansion is set to true to enable expansion of OCS backed Volumes
AllowVolumeExpansion: &allowVolumeExpansion,
Expand Down Expand Up @@ -339,7 +344,7 @@ func newNonResilientCephBlockPoolStorageClassConfiguration(initData *ocsv1.Stora
"description": "Ceph Non Resilient Pools : Provides RWO Filesystem volumes, and RWO and RWX Block volumes",
},
},
Provisioner: fmt.Sprintf("%s.rbd.csi.ceph.com", os.Getenv(util.OperatorNamespaceEnvVar)),
Provisioner: rbdDriverName,
ReclaimPolicy: &persistentVolumeReclaimDelete,
VolumeBindingMode: &volumeBindingWaitForFirstConsumer,
// AllowVolumeExpansion is set to true to enable expansion of OCS backed Volumes
Expand Down Expand Up @@ -375,7 +380,7 @@ func newCephNFSStorageClassConfiguration(initData *ocsv1.StorageCluster) Storage
"description": "Provides RWO and RWX Filesystem volumes",
},
},
Provisioner: fmt.Sprintf("%s.nfs.csi.ceph.com", os.Getenv(util.OperatorNamespaceEnvVar)),
Provisioner: nfsDriverName,
ReclaimPolicy: &persistentVolumeReclaimDelete,
AllowVolumeExpansion: &allowVolumeExpansion,
Parameters: map[string]string{
Expand Down
2 changes: 1 addition & 1 deletion controllers/storagecluster/volumesnapshotterclasses.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func newVolumeSnapshotClass(instance *ocsv1.StorageCluster, snapShotterType Snap
ObjectMeta: metav1.ObjectMeta{
Name: generateNameForSnapshotClass(instance, snapShotterType),
},
Driver: generateNameForSnapshotClassDriver(instance, snapShotterType),
Driver: generateNameForSnapshotClassDriver(snapShotterType),
Parameters: map[string]string{
"clusterID": instance.Namespace,
snapshotterSecretName: generateNameForSnapshotClassSecret(instance, snapShotterType),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3196,6 +3196,8 @@ spec:
configMapKeyRef:
key: CSI_CLUSTER_NAME
name: ocs-operator-config
- name: CSI_DRIVER_NAME_PREFIX
value: openshift-storage
- name: CSI_ENABLE_TOPOLOGY
valueFrom:
configMapKeyRef:
Expand Down
4 changes: 4 additions & 0 deletions tools/csv-merger/csv-merger.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ func unmarshalCSV(filePath string) *csvv1.ClusterServiceVersion {
},
},
},
{
Name: "CSI_DRIVER_NAME_PREFIX",
Value: "openshift-storage",
},
{
Name: "CSI_ENABLE_TOPOLOGY",
ValueFrom: &corev1.EnvVarSource{
Expand Down

0 comments on commit 13a9dfb

Please sign in to comment.