From 96481ef9a4e53b685be78cb20d41d8fb3dc2a7e5 Mon Sep 17 00:00:00 2001 From: Jiazhen Xu <12321223@zju.edu.cn> Date: Thu, 4 Apr 2024 20:40:14 +0800 Subject: [PATCH 1/4] issue #1908 --- cmd/yurt-manager/app/options/nodepoolcontroller.go | 4 +++- pkg/yurtmanager/controller/nodepool/config/types.go | 1 + pkg/yurtmanager/controller/nodepool/nodepool_controller.go | 3 +-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/yurt-manager/app/options/nodepoolcontroller.go b/cmd/yurt-manager/app/options/nodepoolcontroller.go index 373439978d6..53c195d350c 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..623f1ed1215 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..e7aaf4cebd4 100644 --- a/pkg/yurtmanager/controller/nodepool/nodepool_controller.go +++ b/pkg/yurtmanager/controller/nodepool/nodepool_controller.go @@ -40,7 +40,6 @@ import ( ) var ( - concurrentReconciles = 3 controllerResource = appsv1beta1.SchemeGroupVersion.WithResource("nodepools") ) @@ -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(cfg.config.CompletedConfig.NodePoolControllerConfiguration.ConcurrentNodepools), }) if err != nil { return err From b617205c6e7abc843f2cb833f00cef5c5d1dcaf5 Mon Sep 17 00:00:00 2001 From: Jiazhen Xu <12321223@zju.edu.cn> Date: Sat, 6 Apr 2024 15:57:44 +0800 Subject: [PATCH 2/4] update for issue #1908 --- pkg/yurtmanager/controller/nodepool/nodepool_controller.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/yurtmanager/controller/nodepool/nodepool_controller.go b/pkg/yurtmanager/controller/nodepool/nodepool_controller.go index e7aaf4cebd4..ed636872716 100644 --- a/pkg/yurtmanager/controller/nodepool/nodepool_controller.go +++ b/pkg/yurtmanager/controller/nodepool/nodepool_controller.go @@ -76,10 +76,10 @@ func Add(ctx context.Context, c *config.CompletedConfig, mgr manager.Manager) er cfg: c.ComponentConfig.NodePoolController, recorder: mgr.GetEventRecorderFor(names.NodePoolController), } - + // config.NodePoolControllerConfiguration // Create a new controller ctrl, err := controller.New(names.NodePoolController, mgr, controller.Options{ - Reconciler: r, MaxConcurrentReconciles: int(cfg.config.CompletedConfig.NodePoolControllerConfiguration.ConcurrentNodepools), + Reconciler: r, MaxConcurrentReconciles: int(c.ComponentConfig.NodePoolController.ConcurrentNodepools), }) if err != nil { return err From 45162e80d4a52541bb849cde39cda0212ab0890a Mon Sep 17 00:00:00 2001 From: Jiazhen Xu <12321223@zju.edu.cn> Date: Sat, 6 Apr 2024 15:59:12 +0800 Subject: [PATCH 3/4] update for issue #1908 --- pkg/yurtmanager/controller/nodepool/nodepool_controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/yurtmanager/controller/nodepool/nodepool_controller.go b/pkg/yurtmanager/controller/nodepool/nodepool_controller.go index ed636872716..e288bf7af50 100644 --- a/pkg/yurtmanager/controller/nodepool/nodepool_controller.go +++ b/pkg/yurtmanager/controller/nodepool/nodepool_controller.go @@ -76,7 +76,7 @@ func Add(ctx context.Context, c *config.CompletedConfig, mgr manager.Manager) er cfg: c.ComponentConfig.NodePoolController, recorder: mgr.GetEventRecorderFor(names.NodePoolController), } - // config.NodePoolControllerConfiguration + // Create a new controller ctrl, err := controller.New(names.NodePoolController, mgr, controller.Options{ Reconciler: r, MaxConcurrentReconciles: int(c.ComponentConfig.NodePoolController.ConcurrentNodepools), From 8765ca623cb52e8af66f659f3f9040585a73d905 Mon Sep 17 00:00:00 2001 From: Jiazhen Xu <12321223@zju.edu.cn> Date: Mon, 8 Apr 2024 20:49:20 +0800 Subject: [PATCH 4/4] improvement for issue #1908 --- cmd/yurt-manager/app/options/nodepoolcontroller.go | 2 +- pkg/yurtmanager/controller/nodepool/config/types.go | 2 +- pkg/yurtmanager/controller/nodepool/nodepool_controller.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/yurt-manager/app/options/nodepoolcontroller.go b/cmd/yurt-manager/app/options/nodepoolcontroller.go index 53c195d350c..263752a1bbe 100644 --- a/cmd/yurt-manager/app/options/nodepoolcontroller.go +++ b/cmd/yurt-manager/app/options/nodepoolcontroller.go @@ -30,7 +30,7 @@ func NewNodePoolControllerOptions() *NodePoolControllerOptions { return &NodePoolControllerOptions{ &config.NodePoolControllerConfiguration{ EnableSyncNodePoolConfigurations: true, - ConcurrentNodepools: 3, + ConcurrentNodepools: 3, }, } } diff --git a/pkg/yurtmanager/controller/nodepool/config/types.go b/pkg/yurtmanager/controller/nodepool/config/types.go index 623f1ed1215..0276a99c657 100644 --- a/pkg/yurtmanager/controller/nodepool/config/types.go +++ b/pkg/yurtmanager/controller/nodepool/config/types.go @@ -19,5 +19,5 @@ package config // NodePoolControllerConfiguration contains elements describing NodePoolController. type NodePoolControllerConfiguration struct { EnableSyncNodePoolConfigurations bool - ConcurrentNodepools int32 + ConcurrentNodepools int32 } diff --git a/pkg/yurtmanager/controller/nodepool/nodepool_controller.go b/pkg/yurtmanager/controller/nodepool/nodepool_controller.go index e288bf7af50..9e8a4436370 100644 --- a/pkg/yurtmanager/controller/nodepool/nodepool_controller.go +++ b/pkg/yurtmanager/controller/nodepool/nodepool_controller.go @@ -40,7 +40,7 @@ import ( ) var ( - controllerResource = appsv1beta1.SchemeGroupVersion.WithResource("nodepools") + controllerResource = appsv1beta1.SchemeGroupVersion.WithResource("nodepools") ) func Format(format string, args ...interface{}) string {