Skip to content

Commit 3649806

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 dbd6113 commit 3649806

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

controllers/subscription_controller.go

+9
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,14 @@ func (r *SubscriptionReconciler) SetupWithManager(mgr ctrl.Manager) error {
290291
},
291292
)
292293

294+
err := mgr.Add(manager.RunnableFunc(func(ctx context.Context) error {
295+
odfDepsSub := GetStorageClusterSubscriptions()[0]
296+
return EnsureDesiredSubscription(r.Client, odfDepsSub)
297+
}))
298+
if err != nil {
299+
return err
300+
}
301+
293302
return ctrl.NewControllerManagedBy(mgr).
294303
For(&operatorv1alpha1.Subscription{},
295304
builder.WithPredicates(generationChangedPredicate, subscriptionPredicate)).

controllers/subscriptions.go

+2
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,8 @@ 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
622+
// while starting in the subscription controller in SetupWithManager.
621623
return []*operatorv1alpha1.Subscription{odfDepsSubscription, ocsSubscription, rookSubscription, noobaaSubscription,
622624
csiAddonsSubscription, cephCsiSubscription, ocsClientSubscription, prometheusSubscription, recipeSubscription}
623625
}

controllers/subscriptions_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ import (
3030
odfv1alpha1 "github.com/red-hat-storage/odf-operator/api/v1alpha1"
3131
)
3232

33+
func TestSubscriptionIndex(t *testing.T) {
34+
odfDepsSub := GetStorageClusterSubscriptions()[0]
35+
msg := "odfDepsSub variable is expected to contain the 'odf-dependencies' subscription. " +
36+
"Ensure the 'odf-dependencies' subscription indexed at 0."
37+
assert.Equal(t, OdfDepsSubscriptionPackage, odfDepsSub.Spec.Package, msg)
38+
}
39+
3340
func TestEnsureSubscription(t *testing.T) {
3441

3542
testCases := []struct {

0 commit comments

Comments
 (0)