Skip to content

Commit

Permalink
controllers: create odf-deps sub while starting manager
Browse files Browse the repository at this point in the history
creating odf-deps subscription while starting manager will speed up the
process.

Signed-off-by: Nitin Goyal <nigoyal@redhat.com>
  • Loading branch information
iamniting committed Nov 27, 2024
1 parent a1c57d2 commit 38ad0b1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions controllers/subscription_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

Expand Down Expand Up @@ -290,6 +291,22 @@ func (r *SubscriptionReconciler) SetupWithManager(mgr ctrl.Manager) error {
},
)

err := mgr.Add(manager.RunnableFunc(func(ctx context.Context) error {

odfDepsSub := GetStorageClusterSubscriptions()[0]

if odfDepsSub.Spec.Package != OdfDepsSubscriptionPackage {
panic("odfDepsSub variable is expected to contain the 'odf-dependencies' subscription. " +
"Ensure the 'odf-dependencies' subscription indexed at 0.")
}

return EnsureDesiredSubscription(r.Client, odfDepsSub)

}))
if err != nil {
return err
}

return ctrl.NewControllerManagedBy(mgr).
For(&operatorv1alpha1.Subscription{},
builder.WithPredicates(generationChangedPredicate, subscriptionPredicate)).
Expand Down
1 change: 1 addition & 0 deletions controllers/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ func GetStorageClusterSubscriptions() []*operatorv1alpha1.Subscription {
},
}

// Do not change the inxex of odfDepsSubscription. The 0 index is being used to create this subscription while starting
return []*operatorv1alpha1.Subscription{odfDepsSubscription, ocsSubscription, rookSubscription, noobaaSubscription,
csiAddonsSubscription, cephCsiSubscription, ocsClientSubscription, prometheusSubscription, recipeSubscription}
}
Expand Down

0 comments on commit 38ad0b1

Please sign in to comment.