Skip to content

Commit

Permalink
start only when feature is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
tremes committed Jun 9, 2023
1 parent d29ea61 commit 86109d3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
11 changes: 1 addition & 10 deletions pkg/config/configobserver/insighgtsdatagather_observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ type insightsDataGatherController struct {
listeners map[chan *v1alpha1.GatherConfig]struct{}
configV1Alpha1Cli *configCliv1alpha1.ConfigV1alpha1Client
gatherConfig *v1alpha1.GatherConfig
featureEnabled bool
}

func NewInsightsDataGatherObserver(kubeConfig *rest.Config,
eventRecorder events.Recorder,
configInformer configinformers.SharedInformerFactory,
featureEnabled bool) (InsightsDataGatherObserver, error) {
configInformer configinformers.SharedInformerFactory) (InsightsDataGatherObserver, error) {
inf := configInformer.Config().V1alpha1().InsightsDataGathers().Informer()
configV1Alpha1Cli, err := configCliv1alpha1.NewForConfig(kubeConfig)
if err != nil {
Expand All @@ -43,7 +41,6 @@ func NewInsightsDataGatherObserver(kubeConfig *rest.Config,
c := &insightsDataGatherController{
configV1Alpha1Cli: configV1Alpha1Cli,
listeners: make(map[chan *v1alpha1.GatherConfig]struct{}),
featureEnabled: featureEnabled,
}

insightDataGatherConf, err := c.configV1Alpha1Cli.InsightsDataGathers().Get(context.Background(), "cluster", metav1.GetOptions{})
Expand All @@ -60,12 +57,6 @@ func NewInsightsDataGatherObserver(kubeConfig *rest.Config,
}

func (i *insightsDataGatherController) sync(ctx context.Context, scx factory.SyncContext) error {
if !i.featureEnabled {
klog.Infof("Shutting down the queue and the event recorder for %s", i.Name())
scx.Queue().ShutDown()
scx.Recorder().Shutdown()
return nil
}
insightDataGatherConf, err := i.configV1Alpha1Cli.InsightsDataGathers().Get(ctx, "cluster", metav1.GetOptions{})
if err != nil {
return err
Expand Down
17 changes: 10 additions & 7 deletions pkg/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,17 @@ func (s *Operator) Run(ctx context.Context, controller *controllercmd.Controller
return fmt.Errorf("can't create --path: %v", err)
}
}
apiConfigObserver, err := configobserver.NewInsightsDataGatherObserver(gatherKubeConfig,
controller.EventRecorder, configInformers, insightsConfigAPIEnabled)
if err != nil {
return err
}
var apiConfigObserver configobserver.InsightsDataGatherObserver
if insightsConfigAPIEnabled {
apiConfigObserver, err = configobserver.NewInsightsDataGatherObserver(gatherKubeConfig,
controller.EventRecorder, configInformers)
if err != nil {
return err
}

go apiConfigObserver.Run(ctx, 1)
go configInformers.Start(ctx.Done())
go apiConfigObserver.Run(ctx, 1)
go configInformers.Start(ctx.Done())
}

// secretConfigObserver synthesizes all config into the status reporter controller
secretConfigObserver := configobserver.New(s.Controller, kubeClient)
Expand Down

0 comments on commit 86109d3

Please sign in to comment.