Skip to content

Commit

Permalink
Add flag to control the number of concurrent reconciles
Browse files Browse the repository at this point in the history
  • Loading branch information
sibucan committed Nov 6, 2024
1 parent 8850982 commit 6e303f6
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import (
"k8s.io/apimachinery/pkg/runtime"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client/config"
clientconfig "sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/config"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/manager"
Expand Down Expand Up @@ -43,6 +44,7 @@ var (
clusterID string
clusterNamespace string
argoNamespace string
workers int
timeout time.Duration
)

Expand Down Expand Up @@ -79,8 +81,11 @@ var rootCmd = &cobra.Command{
)

// Initialize controller
mgr, err := manager.New(config.GetConfigOrDie(), manager.Options{
mgr, err := manager.New(clientconfig.GetConfigOrDie(), manager.Options{
Scheme: scheme,
Controller: config.Controller{
MaxConcurrentReconciles: workers,
},
})
if err != nil {
logger.Error(err, "could not create manager")
Expand Down Expand Up @@ -113,9 +118,10 @@ func init() {
opts.BindFlags(flag.CommandLine)
rootCmd.PersistentFlags().AddGoFlagSet(flag.CommandLine)
rootCmd.Flags().StringVar(&clusterID, "id", "kind", "The name of the cluster where capargo is located.")
rootCmd.Flags().StringVar(&clusterNamespace, "cluster-namespace", "", "The namespace to watch for clusters")
rootCmd.Flags().DurationVar(&timeout, "timeout", 5*time.Minute, "The timeout period for any update action")
rootCmd.Flags().StringVar(&argoNamespace, "argo-namespace", "", "The argo namespace in which to place the secrets")
rootCmd.Flags().IntVar(&workers, "workers", 3, "The number of concurrent workers available to reconcile the state.")
rootCmd.Flags().StringVar(&clusterNamespace, "cluster-namespace", "", "The namespace to watch for clusters.")
rootCmd.Flags().DurationVar(&timeout, "timeout", 5*time.Minute, "The timeout period for any update action.")
rootCmd.Flags().StringVar(&argoNamespace, "argo-namespace", "", "The argo namespace in which to place the secrets.")
rootCmd.MarkFlagRequired("argo-namespace")
}

Expand Down

0 comments on commit 6e303f6

Please sign in to comment.