Skip to content

Commit

Permalink
Merge pull request #2517 from jarrpa/jarrpa/no-profile-svg
Browse files Browse the repository at this point in the history
controllers: remove storageprofiles from storageclassrequest
  • Loading branch information
openshift-merge-bot[bot] authored Mar 21, 2024
2 parents cdbfe1d + 086f90c commit 108c0c4
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 767 deletions.
33 changes: 10 additions & 23 deletions controllers/storageclassrequest/storageclassrequest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (r *StorageClassRequestReconciler) SetupWithManager(mgr ctrl.Manager) error
Complete(r)
}

func (r *StorageClassRequestReconciler) initPhase(storageProfile *v1.StorageProfile) error {
func (r *StorageClassRequestReconciler) initPhase() error {
gvk, err := apiutil.GVKForObject(&v1alpha1.StorageConsumer{}, r.Client.Scheme())
if err != nil {
return fmt.Errorf("failed to get gvk for consumer %w", err)
Expand All @@ -207,8 +207,6 @@ func (r *StorageClassRequestReconciler) initPhase(storageProfile *v1.StorageProf
return err
}

profileName := r.StorageClassRequest.Spec.StorageProfile

// check request status already contains the name of the resource. if not, add it.
if r.StorageClassRequest.Spec.Type == "blockpool" {
// initialize in-memory structs
Expand Down Expand Up @@ -241,18 +239,6 @@ func (r *StorageClassRequestReconciler) initPhase(storageProfile *v1.StorageProf
return fmt.Errorf("invalid number of CephBlockPoolRadosNamespaces for storage consumer %q: found %d, expecting 0 or 1", r.storageConsumer.Name, rnsItemsLen)
}
} else if r.StorageClassRequest.Spec.Type == "sharedfilesystem" {
if profileName == "" {
profileName = r.storageCluster.Spec.DefaultStorageProfile
}

// Fetch StorageProfile by name in the StorageCluster's namespace
storageProfile.Name = profileName
storageProfile.Namespace = r.storageCluster.Namespace

if err := r.get(storageProfile); err != nil {
return fmt.Errorf("no storage profile CR found for storage profile %s", profileName)
}

r.cephFilesystemSubVolumeGroup = &rookCephv1.CephFilesystemSubVolumeGroup{}
r.cephFilesystemSubVolumeGroup.Namespace = r.OperatorNamespace

Expand Down Expand Up @@ -300,9 +286,7 @@ func (r *StorageClassRequestReconciler) reconcilePhases() (reconcile.Result, err

r.StorageClassRequest.Status.Phase = v1alpha1.StorageClassRequestInitializing

storageProfile := v1.StorageProfile{}

if err := r.initPhase(&storageProfile); err != nil {
if err := r.initPhase(); err != nil {
return reconcile.Result{}, err
}

Expand Down Expand Up @@ -332,7 +316,7 @@ func (r *StorageClassRequestReconciler) reconcilePhases() (reconcile.Result, err
return reconcile.Result{}, err
}

if err := r.reconcileCephFilesystemSubVolumeGroup(&storageProfile); err != nil {
if err := r.reconcileCephFilesystemSubVolumeGroup(); err != nil {
return reconcile.Result{}, err
}
}
Expand Down Expand Up @@ -362,6 +346,8 @@ func (r *StorageClassRequestReconciler) reconcileRadosNamespace() error {

addLabel(r.cephRadosNamespace, controllers.StorageConsumerNameLabel, r.storageConsumer.Name)

// For RADOS namespaces, the "profile" is equivalent to the
// name of the desired block pool for the namespace.
blockPoolName := r.StorageClassRequest.Spec.StorageProfile
if blockPoolName == "" {
blockPoolName = fmt.Sprintf("%s-cephblockpool", r.storageCluster.Name)
Expand Down Expand Up @@ -396,7 +382,7 @@ func (r *StorageClassRequestReconciler) reconcileRadosNamespace() error {
return nil
}

func (r *StorageClassRequestReconciler) reconcileCephFilesystemSubVolumeGroup(storageProfile *v1.StorageProfile) error {
func (r *StorageClassRequestReconciler) reconcileCephFilesystemSubVolumeGroup() error {

cephFilesystem := rookCephv1.CephFilesystem{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -412,10 +398,12 @@ func (r *StorageClassRequestReconciler) reconcileCephFilesystemSubVolumeGroup(st
if err := r.own(r.cephFilesystemSubVolumeGroup); err != nil {
return err
}
deviceClass := storageProfile.Spec.DeviceClass

// For subvolume groups, the "profile" is equivalent to the
// name of the desired data pool ("" by default).
var dataPool *rookCephv1.NamedPoolSpec
for i := range cephFilesystem.Spec.DataPools {
if cephFilesystem.Spec.DataPools[i].DeviceClass == deviceClass {
if cephFilesystem.Spec.DataPools[i].Name == r.StorageClassRequest.Spec.StorageProfile {
dataPool = &cephFilesystem.Spec.DataPools[i]
break
}
Expand All @@ -425,7 +413,6 @@ func (r *StorageClassRequestReconciler) reconcileCephFilesystemSubVolumeGroup(st
}

addLabel(r.cephFilesystemSubVolumeGroup, controllers.StorageConsumerNameLabel, r.storageConsumer.Name)
addLabel(r.cephFilesystemSubVolumeGroup, controllers.StorageProfileSpecLabel, storageProfile.GetSpecHash())
// This label is required to set the dataPool on the CephFS
// storageclass so that each PVC created from CephFS storageclass can
// use correct dataPool backed by deviceclass.
Expand Down
Loading

0 comments on commit 108c0c4

Please sign in to comment.