diff --git a/cmd/rollouts-controller/main.go b/cmd/rollouts-controller/main.go index bc478740a8..768fc416cd 100644 --- a/cmd/rollouts-controller/main.go +++ b/cmd/rollouts-controller/main.go @@ -38,6 +38,9 @@ func newCommand() *cobra.Command { logLevel string glogLevel int metricsPort int + rolloutThreads int + experimentThreads int + serviceThreads int ) var command = cobra.Command{ Use: cliName, @@ -90,7 +93,7 @@ func newCommand() *cobra.Command { kubeInformerFactory.Start(stopCh) argoRolloutsInformerFactory.Start(stopCh) - if err = cm.Run(1, 1, 1, stopCh); err != nil { + if err = cm.Run(rolloutThreads, serviceThreads, experimentThreads, stopCh); err != nil { glog.Fatalf("Error running controller: %s", err.Error()) } return nil @@ -101,6 +104,9 @@ func newCommand() *cobra.Command { command.Flags().StringVar(&logLevel, "loglevel", "info", "Set the logging level. One of: debug|info|warn|error") command.Flags().IntVar(&glogLevel, "gloglevel", 0, "Set the glog logging level") command.Flags().IntVar(&metricsPort, "metricsport", controller.DefaultMetricsPort, "Set the port the metrics endpoint should be exposed over") + command.Flags().IntVar(&rolloutThreads, "rollout-threads", controller.DefaultRolloutThreads, "Set the number of worker threads for the Rollout controller") + command.Flags().IntVar(&experimentThreads, "experiment-threads", controller.DefaultExperimentThreads, "Set the number of worker threads for the Experimentd controller") + command.Flags().IntVar(&serviceThreads, "service-threads", controller.DefaultServiceThreads, "Set the number of worker threads for the Service controller") return &command } diff --git a/controller/controller.go b/controller/controller.go index f73cc48f8e..af40c3cb43 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -36,6 +36,15 @@ const ( // DefaultMetricsPort Default port to expose the metrics endpoint DefaultMetricsPort = 8090 + + // DefaultRolloutThreads Default numnber of worker threads to start with the controller + DefaultRolloutThreads = 1 + + // DefaultRolloutThreads Default numnber of worker threads to start with the controller + DefaultExperimentThreads = 1 + + // DefaultRolloutThreads Default numnber of worker threads to start with the controller + DefaultServiceThreads = 1 ) // Manager is the controller implementation for Argo-Rollout resources diff --git a/experiments/controller.go b/experiments/controller.go index ff495574ef..392741219e 100644 --- a/experiments/controller.go +++ b/experiments/controller.go @@ -1,13 +1,15 @@ package experiments import ( - "time" "fmt" + "time" log "github.com/sirupsen/logrus" appsv1 "k8s.io/api/apps/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/apimachinery/pkg/util/wait" appsinformers "k8s.io/client-go/informers/apps/v1" "k8s.io/client-go/kubernetes" appslisters "k8s.io/client-go/listers/apps/v1" @@ -15,8 +17,6 @@ import ( "k8s.io/client-go/tools/record" "k8s.io/client-go/util/workqueue" "k8s.io/kubernetes/pkg/controller" - "k8s.io/apimachinery/pkg/util/runtime" - "k8s.io/apimachinery/pkg/util/wait" "github.com/argoproj/argo-rollouts/controller/metrics" "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1" @@ -25,7 +25,6 @@ import ( listers "github.com/argoproj/argo-rollouts/pkg/client/listers/rollouts/v1alpha1" controllerutil "github.com/argoproj/argo-rollouts/utils/controller" logutil "github.com/argoproj/argo-rollouts/utils/log" - ) // ExperimentController is the controller implementation for Experiment resources