From b023c13dde74ff91d42ce0d0bcb99030878d5d32 Mon Sep 17 00:00:00 2001 From: Jiazhen Xu <12321223@zju.edu.cn> Date: Tue, 9 Apr 2024 22:40:12 +0800 Subject: [PATCH 1/2] feat: improve configuration of concurrent platform administration workers --- .../app/options/platformadmincontroller.go | 2 ++ .../controller/platformadmin/config/config.go | 2 ++ .../platformadmin/platformadmin_controller.go | 12 +++--------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/cmd/yurt-manager/app/options/platformadmincontroller.go b/cmd/yurt-manager/app/options/platformadmincontroller.go index a77a3c231fb..43daa07e603 100644 --- a/cmd/yurt-manager/app/options/platformadmincontroller.go +++ b/cmd/yurt-manager/app/options/platformadmincontroller.go @@ -39,6 +39,8 @@ func (n *PlatformAdminControllerOptions) AddFlags(fs *pflag.FlagSet) { if n == nil { return } + + fs.Int32Var(&n.ConcurrentPlatformAdminWorkers, "concurrent-platform-administrator-workers", n.ConcurrentPlatformAdminWorkers, "Max concurrent workers for PlatformAdmin controller.") } // ApplyTo fills up nodePool config with options. diff --git a/pkg/yurtmanager/controller/platformadmin/config/config.go b/pkg/yurtmanager/controller/platformadmin/config/config.go index bc067613b48..77b25592a50 100644 --- a/pkg/yurtmanager/controller/platformadmin/config/config.go +++ b/pkg/yurtmanager/controller/platformadmin/config/config.go @@ -93,6 +93,7 @@ type PlatformAdminControllerConfiguration struct { NoSectyComponents map[string][]*Component SecurityConfigMaps map[string][]corev1.ConfigMap NoSectyConfigMaps map[string][]corev1.ConfigMap + ConcurrentPlatformAdminWorkers int32 } func NewPlatformAdminControllerConfiguration() *PlatformAdminControllerConfiguration { @@ -105,6 +106,7 @@ func NewPlatformAdminControllerConfiguration() *PlatformAdminControllerConfigura NoSectyComponents: make(map[string][]*Component), SecurityConfigMaps: make(map[string][]corev1.ConfigMap), NoSectyConfigMaps: make(map[string][]corev1.ConfigMap), + ConcurrentPlatformAdminWorkers: 3, } ) diff --git a/pkg/yurtmanager/controller/platformadmin/platformadmin_controller.go b/pkg/yurtmanager/controller/platformadmin/platformadmin_controller.go index cac721d0e63..06ced80c624 100644 --- a/pkg/yurtmanager/controller/platformadmin/platformadmin_controller.go +++ b/pkg/yurtmanager/controller/platformadmin/platformadmin_controller.go @@ -19,7 +19,6 @@ package platformadmin import ( "context" "encoding/json" - "flag" "fmt" "time" @@ -54,17 +53,12 @@ import ( util "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/platformadmin/utils" ) -func init() { - flag.IntVar(&concurrentReconciles, "platformadmin-workers", concurrentReconciles, "Max concurrent workers for PlatformAdmin controller.") -} - func Format(format string, args ...interface{}) string { s := fmt.Sprintf(format, args...) return fmt.Sprintf("%s: %s", names.PlatformAdminController, s) } var ( - concurrentReconciles = 3 controllerResource = iotv1alpha2.SchemeGroupVersion.WithResource("platformadmins") ) @@ -126,7 +120,7 @@ func Add(ctx context.Context, c *appconfig.CompletedConfig, mgr manager.Manager) } klog.Infof("platformadmin-controller add controller %s", controllerResource.String()) - return add(mgr, newReconciler(c, mgr)) + return add(mgr, c, newReconciler(c, mgr)) } // newReconciler returns a new reconcile.Reconciler @@ -141,10 +135,10 @@ func newReconciler(c *appconfig.CompletedConfig, mgr manager.Manager) reconcile. } // add adds a new Controller to mgr with r as the reconcile.Reconciler -func add(mgr manager.Manager, r reconcile.Reconciler) error { +func add(mgr manager.Manager, cfg *appconfig.CompletedConfig, r reconcile.Reconciler) error { // Create a new controller c, err := controller.New(names.PlatformAdminController, mgr, controller.Options{ - Reconciler: r, MaxConcurrentReconciles: concurrentReconciles, + Reconciler: r, MaxConcurrentReconciles: int(cfg.ComponentConfig.PlatformAdminController.ConcurrentPlatformAdminWorkers), }) if err != nil { return err From e01441bb6df858f90e7651ec55adac9fed21b7fb Mon Sep 17 00:00:00 2001 From: Jiazhen Xu <12321223@zju.edu.cn> Date: Tue, 9 Apr 2024 22:48:54 +0800 Subject: [PATCH 2/2] feat: improve configuration of concurrent platform administration workers --- .../controller/platformadmin/config/config.go | 20 +++++++++---------- .../platformadmin/platformadmin_controller.go | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/yurtmanager/controller/platformadmin/config/config.go b/pkg/yurtmanager/controller/platformadmin/config/config.go index 77b25592a50..378082d0b7c 100644 --- a/pkg/yurtmanager/controller/platformadmin/config/config.go +++ b/pkg/yurtmanager/controller/platformadmin/config/config.go @@ -88,11 +88,11 @@ func ExtractRequiredComponentsName(manifest *Manifest, versionName string) sets. // PlatformAdminControllerConfiguration contains elements describing PlatformAdminController. type PlatformAdminControllerConfiguration struct { - Manifest Manifest - SecurityComponents map[string][]*Component - NoSectyComponents map[string][]*Component - SecurityConfigMaps map[string][]corev1.ConfigMap - NoSectyConfigMaps map[string][]corev1.ConfigMap + Manifest Manifest + SecurityComponents map[string][]*Component + NoSectyComponents map[string][]*Component + SecurityConfigMaps map[string][]corev1.ConfigMap + NoSectyConfigMaps map[string][]corev1.ConfigMap ConcurrentPlatformAdminWorkers int32 } @@ -101,11 +101,11 @@ func NewPlatformAdminControllerConfiguration() *PlatformAdminControllerConfigura edgexconfig = EdgeXConfig{} edgexnosectyconfig = EdgeXConfig{} conf = PlatformAdminControllerConfiguration{ - Manifest: Manifest{}, - SecurityComponents: make(map[string][]*Component), - NoSectyComponents: make(map[string][]*Component), - SecurityConfigMaps: make(map[string][]corev1.ConfigMap), - NoSectyConfigMaps: make(map[string][]corev1.ConfigMap), + Manifest: Manifest{}, + SecurityComponents: make(map[string][]*Component), + NoSectyComponents: make(map[string][]*Component), + SecurityConfigMaps: make(map[string][]corev1.ConfigMap), + NoSectyConfigMaps: make(map[string][]corev1.ConfigMap), ConcurrentPlatformAdminWorkers: 3, } ) diff --git a/pkg/yurtmanager/controller/platformadmin/platformadmin_controller.go b/pkg/yurtmanager/controller/platformadmin/platformadmin_controller.go index 06ced80c624..fbec9a2d8cb 100644 --- a/pkg/yurtmanager/controller/platformadmin/platformadmin_controller.go +++ b/pkg/yurtmanager/controller/platformadmin/platformadmin_controller.go @@ -59,7 +59,7 @@ func Format(format string, args ...interface{}) string { } var ( - controllerResource = iotv1alpha2.SchemeGroupVersion.WithResource("platformadmins") + controllerResource = iotv1alpha2.SchemeGroupVersion.WithResource("platformadmins") ) const (