Skip to content

Commit

Permalink
Should not use utilruntime.Must (#115)
Browse files Browse the repository at this point in the history
Signed-off-by: Jian Qiu <[email protected]>
  • Loading branch information
qiujian16 authored Aug 23, 2023
1 parent 43603df commit b94ba18
Showing 1 changed file with 41 additions and 27 deletions.
68 changes: 41 additions & 27 deletions pkg/controllers/ocmcontroller/ocmcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ocmcontroller

import (
"context"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/dynamic/dynamicinformer"
ocmfeature "open-cluster-management.io/api/feature"
Expand Down Expand Up @@ -110,8 +109,8 @@ func runControllers(ctx context.Context,
addOnInformers := addoninformers.NewSharedInformerFactory(addOnClient, 10*time.Minute)
dynamicInformers := dynamicinformer.NewDynamicSharedInformerFactory(dynamicClient, 10*time.Minute)

go utilruntime.Must(
opts.RunControllerManagerWithInformers(
go func() {
if err := opts.RunControllerManagerWithInformers(
ctx,
controllerContext,
kubeClient,
Expand All @@ -121,37 +120,52 @@ func runControllers(ctx context.Context,
clusterInformers,
workInformers,
addOnInformers,
))
); err != nil {
klog.Fatal(err)
}
}()

go utilruntime.Must(placementcontrollers.RunControllerManagerWithInformers(
ctx,
controllerContext,
kubeClient,
clusterClient,
clusterInformers,
))

if features.HubMutableFeatureGate.Enabled(ocmfeature.ManifestWorkReplicaSet) {
go utilruntime.Must(workhub.RunControllerManagerWithInformers(
go func() {
if err := placementcontrollers.RunControllerManagerWithInformers(
ctx,
controllerContext,
workClient,
workInformers,
kubeClient,
clusterClient,
clusterInformers,
))
); err != nil {
klog.Fatal(err)
}
}()

if features.HubMutableFeatureGate.Enabled(ocmfeature.ManifestWorkReplicaSet) {
go func() {
if err := workhub.RunControllerManagerWithInformers(
ctx,
controllerContext,
workClient,
workInformers,
clusterInformers,
); err != nil {
klog.Fatal(err)
}
}()
}

if features.HubMutableFeatureGate.Enabled(ocmfeature.AddonManagement) {
go utilruntime.Must(addonhub.RunControllerManagerWithInformers(
ctx,
controllerContext,
kubeClient,
addOnClient,
clusterInformers,
addOnInformers,
workInformers,
dynamicInformers,
))
go func() {
if err := addonhub.RunControllerManagerWithInformers(
ctx,
controllerContext,
kubeClient,
addOnClient,
clusterInformers,
addOnInformers,
workInformers,
dynamicInformers,
); err != nil {
klog.Fatal(err)
}
}()
}

go kubeInformers.Start(ctx.Done())
Expand Down

0 comments on commit b94ba18

Please sign in to comment.