From 7fc84322eef6c9414a2ee3610d5f98331a178cc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9C=A8=E7=BA=A2=E5=B0=98=E4=B8=AD=E6=88=90=E4=BB=99?= <1178404986@qq.com> Date: Wed, 10 Apr 2024 16:47:39 +0800 Subject: [PATCH] 1908 (#2007) * fixes issue #1908 Co-authored-by: Jiazhen Xu <12321223@zju.edu.cn> --- cmd/yurt-manager/app/options/nodepoolcontroller.go | 4 +++- pkg/yurtmanager/controller/nodepool/config/types.go | 1 + pkg/yurtmanager/controller/nodepool/nodepool_controller.go | 5 ++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/yurt-manager/app/options/nodepoolcontroller.go b/cmd/yurt-manager/app/options/nodepoolcontroller.go index 373439978d6..263752a1bbe 100644 --- a/cmd/yurt-manager/app/options/nodepoolcontroller.go +++ b/cmd/yurt-manager/app/options/nodepoolcontroller.go @@ -30,6 +30,7 @@ func NewNodePoolControllerOptions() *NodePoolControllerOptions { return &NodePoolControllerOptions{ &config.NodePoolControllerConfiguration{ EnableSyncNodePoolConfigurations: true, + ConcurrentNodepools: 3, }, } } @@ -40,7 +41,7 @@ func (n *NodePoolControllerOptions) AddFlags(fs *pflag.FlagSet) { return } - fs.BoolVar(&n.EnableSyncNodePoolConfigurations, "enable-sync-nodepool-configurations", n.EnableSyncNodePoolConfigurations, "enable to sync nodepool configurations(including labels, annotations, taints in spec) to nodes in the nodepool.") + fs.Int32Var(&n.ConcurrentNodepools, "concurrent-nodepools", n.ConcurrentNodepools, "The number of node pools that are allowed to reconcile concurrently.") } // ApplyTo fills up nodePool config with options. @@ -49,6 +50,7 @@ func (o *NodePoolControllerOptions) ApplyTo(cfg *config.NodePoolControllerConfig return nil } cfg.EnableSyncNodePoolConfigurations = o.EnableSyncNodePoolConfigurations + cfg.ConcurrentNodepools = o.ConcurrentNodepools return nil } diff --git a/pkg/yurtmanager/controller/nodepool/config/types.go b/pkg/yurtmanager/controller/nodepool/config/types.go index 4ce71aa87c9..0276a99c657 100644 --- a/pkg/yurtmanager/controller/nodepool/config/types.go +++ b/pkg/yurtmanager/controller/nodepool/config/types.go @@ -19,4 +19,5 @@ package config // NodePoolControllerConfiguration contains elements describing NodePoolController. type NodePoolControllerConfiguration struct { EnableSyncNodePoolConfigurations bool + ConcurrentNodepools int32 } diff --git a/pkg/yurtmanager/controller/nodepool/nodepool_controller.go b/pkg/yurtmanager/controller/nodepool/nodepool_controller.go index bf6fa51f550..9e8a4436370 100644 --- a/pkg/yurtmanager/controller/nodepool/nodepool_controller.go +++ b/pkg/yurtmanager/controller/nodepool/nodepool_controller.go @@ -40,8 +40,7 @@ import ( ) var ( - concurrentReconciles = 3 - controllerResource = appsv1beta1.SchemeGroupVersion.WithResource("nodepools") + controllerResource = appsv1beta1.SchemeGroupVersion.WithResource("nodepools") ) func Format(format string, args ...interface{}) string { @@ -80,7 +79,7 @@ func Add(ctx context.Context, c *config.CompletedConfig, mgr manager.Manager) er // Create a new controller ctrl, err := controller.New(names.NodePoolController, mgr, controller.Options{ - Reconciler: r, MaxConcurrentReconciles: concurrentReconciles, + Reconciler: r, MaxConcurrentReconciles: int(c.ComponentConfig.NodePoolController.ConcurrentNodepools), }) if err != nil { return err