Skip to content

Commit 38ad0b1

Browse files
committed
controllers: create odf-deps sub while starting manager
creating odf-deps subscription while starting manager will speed up the process. Signed-off-by: Nitin Goyal <nigoyal@redhat.com>
1 parent a1c57d2 commit 38ad0b1

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

controllers/subscription_controller.go

+17
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"sigs.k8s.io/controller-runtime/pkg/event"
3333
"sigs.k8s.io/controller-runtime/pkg/handler"
3434
"sigs.k8s.io/controller-runtime/pkg/log"
35+
"sigs.k8s.io/controller-runtime/pkg/manager"
3536
"sigs.k8s.io/controller-runtime/pkg/predicate"
3637
"sigs.k8s.io/controller-runtime/pkg/reconcile"
3738

@@ -290,6 +291,22 @@ func (r *SubscriptionReconciler) SetupWithManager(mgr ctrl.Manager) error {
290291
},
291292
)
292293

294+
err := mgr.Add(manager.RunnableFunc(func(ctx context.Context) error {
295+
296+
odfDepsSub := GetStorageClusterSubscriptions()[0]
297+
298+
if odfDepsSub.Spec.Package != OdfDepsSubscriptionPackage {
299+
panic("odfDepsSub variable is expected to contain the 'odf-dependencies' subscription. " +
300+
"Ensure the 'odf-dependencies' subscription indexed at 0.")
301+
}
302+
303+
return EnsureDesiredSubscription(r.Client, odfDepsSub)
304+
305+
}))
306+
if err != nil {
307+
return err
308+
}
309+
293310
return ctrl.NewControllerManagedBy(mgr).
294311
For(&operatorv1alpha1.Subscription{},
295312
builder.WithPredicates(generationChangedPredicate, subscriptionPredicate)).

controllers/subscriptions.go

+1
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ func GetStorageClusterSubscriptions() []*operatorv1alpha1.Subscription {
618618
},
619619
}
620620

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

0 commit comments

Comments
 (0)