Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
cmd: start autoupdate ctrl by default
  • Loading branch information
abhinavdahiya committed Aug 27, 2018
commit 437d5a37023e6cbb629f95d6f49746e2eb664639
18 changes: 16 additions & 2 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/golang/glog"
"github.com/google/uuid"
"github.com/openshift/cluster-version-operator/pkg/autoupdate"
"github.com/openshift/cluster-version-operator/pkg/cvo"
clientset "github.com/openshift/cluster-version-operator/pkg/generated/clientset/versioned"
informers "github.com/openshift/cluster-version-operator/pkg/generated/informers/externalversions"
Expand Down Expand Up @@ -46,13 +47,16 @@ var (
startOpts struct {
kubeconfig string
nodeName string

enableAutoUpdate bool
}
)

func init() {
rootCmd.AddCommand(startCmd)
startCmd.PersistentFlags().StringVar(&startOpts.kubeconfig, "kubeconfig", "", "Kubeconfig file to access a remote cluster (testing only)")
startCmd.PersistentFlags().StringVar(&startOpts.nodeName, "node-name", "", "kubernetes node name CVO is scheduled on.")
startCmd.PersistentFlags().BoolVar(&startOpts.enableAutoUpdate, "enable-auto-update", true, "Enables the autoupdate controller.")
}

func runStartCmd(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -203,13 +207,13 @@ func createControllerContext(cb *clientBuilder, stop <-chan struct{}) *controlle
kubeClient := cb.KubeClientOrDie("kube-shared-informer")
apiExtClient := cb.APIExtClientOrDie("apiext-shared-informer")

sharedNamespacedInformers := informers.NewSharedInformerFactory(client, resyncPeriod()())
sharedInformers := informers.NewSharedInformerFactory(client, resyncPeriod()())
kubeSharedInformer := kubeinformers.NewSharedInformerFactory(kubeClient, resyncPeriod()())
apiExtSharedInformer := apiextinformers.NewSharedInformerFactory(apiExtClient, resyncPeriod()())

return &controllerContext{
ClientBuilder: cb,
InformerFactory: sharedNamespacedInformers,
InformerFactory: sharedInformers,
KubeInformerFactory: kubeSharedInformer,
APIExtInformerFactory: apiExtSharedInformer,
Stop: stop,
Expand All @@ -232,5 +236,15 @@ func startControllers(ctx *controllerContext) error {
ctx.ClientBuilder.APIExtClientOrDie(componentName),
).Run(2, ctx.Stop)

if startOpts.enableAutoUpdate {
go autoupdate.New(
componentNamespace, componentName,
ctx.InformerFactory.Clusterversion().V1().CVOConfigs(),
ctx.InformerFactory.Clusterversion().V1().OperatorStatuses(),
ctx.ClientBuilder.ClientOrDie(componentName),
ctx.ClientBuilder.KubeClientOrDie(componentName),
).Run(2, ctx.Stop)
}

return nil
}