From 0fa908bf8e0702007d53146bce495ad8bb4b6ff8 Mon Sep 17 00:00:00 2001 From: rambohe Date: Wed, 26 Jun 2024 18:01:49 +0800 Subject: [PATCH] feat: improve concurrent workers for raven controllers (#2089) --- .../app/options/gatewaydnscontroller.go | 64 +++++++++++++++++++ .../options/gatewayinternalsvccontroller.go | 64 +++++++++++++++++++ ...ntroller.go => gatewaypickupcontroller.go} | 7 +- .../app/options/gatewaypublicsvccontroller.go | 64 +++++++++++++++++++ cmd/yurt-manager/app/options/options.go | 35 ++++++++-- .../controller/apis/config/types.go | 22 +++++-- .../controller/raven/dns/config/types.go | 22 +++++++ .../raven/dns/gateway_dns_controller.go | 6 +- .../gatewayinternalservice/config/types.go | 22 +++++++ .../gateway_internal_service_controller.go | 6 +- .../raven/gatewaypickup/config/types.go | 1 + .../gateway_pickup_controller.go | 6 +- .../gatewaypublicservice/config/types.go | 22 +++++++ .../gateway_public_service_controller.go | 6 +- .../controller/raven/util/constants.go | 1 - 15 files changed, 322 insertions(+), 26 deletions(-) create mode 100644 cmd/yurt-manager/app/options/gatewaydnscontroller.go create mode 100644 cmd/yurt-manager/app/options/gatewayinternalsvccontroller.go rename cmd/yurt-manager/app/options/{gatewaycontroller.go => gatewaypickupcontroller.go} (77%) create mode 100644 cmd/yurt-manager/app/options/gatewaypublicsvccontroller.go create mode 100644 pkg/yurtmanager/controller/raven/dns/config/types.go create mode 100644 pkg/yurtmanager/controller/raven/gatewayinternalservice/config/types.go create mode 100644 pkg/yurtmanager/controller/raven/gatewaypublicservice/config/types.go diff --git a/cmd/yurt-manager/app/options/gatewaydnscontroller.go b/cmd/yurt-manager/app/options/gatewaydnscontroller.go new file mode 100644 index 00000000000..30847bc494f --- /dev/null +++ b/cmd/yurt-manager/app/options/gatewaydnscontroller.go @@ -0,0 +1,64 @@ +/* +Copyright 2023 The OpenYurt Authors. + +Licensed under the Apache License, Version 2.0 (the License); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an AS IS BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package options + +import ( + "github.com/spf13/pflag" + + "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/raven/dns/config" +) + +type GatewayDNSControllerOptions struct { + *config.GatewayDNSControllerConfiguration +} + +func NewGatewayDNSControllerOptions() *GatewayDNSControllerOptions { + return &GatewayDNSControllerOptions{ + &config.GatewayDNSControllerConfiguration{ + ConcurrentGatewayDNSWorkers: 1, + }, + } +} + +// AddFlags adds flags related to gateway for yurt-manager to the specified FlagSet. +func (g *GatewayDNSControllerOptions) AddFlags(fs *pflag.FlagSet) { + if g == nil { + return + } + + fs.Int32Var(&g.ConcurrentGatewayDNSWorkers, "concurrent-gateway-dns-workers", g.ConcurrentGatewayDNSWorkers, "The number of gateway objects that are allowed to reconcile concurrently. Larger number = more responsive gateway dns, but more CPU (and network) load") + +} + +// ApplyTo fills up gateway config with options. +func (g *GatewayDNSControllerOptions) ApplyTo(cfg *config.GatewayDNSControllerConfiguration) error { + if g == nil { + return nil + } + + cfg.ConcurrentGatewayDNSWorkers = g.ConcurrentGatewayDNSWorkers + return nil +} + +// Validate checks validation of GatewayControllerOptions. +func (g *GatewayDNSControllerOptions) Validate() []error { + if g == nil { + return nil + } + var errs []error + return errs +} diff --git a/cmd/yurt-manager/app/options/gatewayinternalsvccontroller.go b/cmd/yurt-manager/app/options/gatewayinternalsvccontroller.go new file mode 100644 index 00000000000..fa9dc67c2b0 --- /dev/null +++ b/cmd/yurt-manager/app/options/gatewayinternalsvccontroller.go @@ -0,0 +1,64 @@ +/* +Copyright 2023 The OpenYurt Authors. + +Licensed under the Apache License, Version 2.0 (the License); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an AS IS BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package options + +import ( + "github.com/spf13/pflag" + + "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/raven/gatewayinternalservice/config" +) + +type GatewayInternalSvcControllerOptions struct { + *config.GatewayInternalSvcControllerConfiguration +} + +func NewGatewayInternalSvcControllerOptions() *GatewayInternalSvcControllerOptions { + return &GatewayInternalSvcControllerOptions{ + &config.GatewayInternalSvcControllerConfiguration{ + ConcurrentGatewayInternalSvcWorkers: 1, + }, + } +} + +// AddFlags adds flags related to gateway for yurt-manager to the specified FlagSet. +func (g *GatewayInternalSvcControllerOptions) AddFlags(fs *pflag.FlagSet) { + if g == nil { + return + } + + fs.Int32Var(&g.ConcurrentGatewayInternalSvcWorkers, "concurrent-gateway-internal-svc-workers", g.ConcurrentGatewayInternalSvcWorkers, "The number of gateway objects that are allowed to reconcile concurrently. Larger number = more responsive gateway internal svc, but more CPU (and network) load") + +} + +// ApplyTo fills up gateway config with options. +func (g *GatewayInternalSvcControllerOptions) ApplyTo(cfg *config.GatewayInternalSvcControllerConfiguration) error { + if g == nil { + return nil + } + + cfg.ConcurrentGatewayInternalSvcWorkers = g.ConcurrentGatewayInternalSvcWorkers + return nil +} + +// Validate checks validation of GatewayControllerOptions. +func (g *GatewayInternalSvcControllerOptions) Validate() []error { + if g == nil { + return nil + } + var errs []error + return errs +} diff --git a/cmd/yurt-manager/app/options/gatewaycontroller.go b/cmd/yurt-manager/app/options/gatewaypickupcontroller.go similarity index 77% rename from cmd/yurt-manager/app/options/gatewaycontroller.go rename to cmd/yurt-manager/app/options/gatewaypickupcontroller.go index 68c3309f873..428d4c917c3 100644 --- a/cmd/yurt-manager/app/options/gatewaycontroller.go +++ b/cmd/yurt-manager/app/options/gatewaypickupcontroller.go @@ -28,7 +28,9 @@ type GatewayPickupControllerOptions struct { func NewGatewayPickupControllerOptions() *GatewayPickupControllerOptions { return &GatewayPickupControllerOptions{ - &config.GatewayPickupControllerConfiguration{}, + &config.GatewayPickupControllerConfiguration{ + ConcurrentGatewayPickupWorkers: 1, + }, } } @@ -38,6 +40,8 @@ func (g *GatewayPickupControllerOptions) AddFlags(fs *pflag.FlagSet) { return } + fs.Int32Var(&g.ConcurrentGatewayPickupWorkers, "concurrent-gateway-pickup-workers", g.ConcurrentGatewayPickupWorkers, "The number of gateway objects that are allowed to reconcile concurrently. Larger number = more responsive gateway pickup, but more CPU (and network) load") + } // ApplyTo fills up nodePool config with options. @@ -46,6 +50,7 @@ func (g *GatewayPickupControllerOptions) ApplyTo(cfg *config.GatewayPickupContro return nil } + cfg.ConcurrentGatewayPickupWorkers = g.ConcurrentGatewayPickupWorkers return nil } diff --git a/cmd/yurt-manager/app/options/gatewaypublicsvccontroller.go b/cmd/yurt-manager/app/options/gatewaypublicsvccontroller.go new file mode 100644 index 00000000000..aa04f4be983 --- /dev/null +++ b/cmd/yurt-manager/app/options/gatewaypublicsvccontroller.go @@ -0,0 +1,64 @@ +/* +Copyright 2023 The OpenYurt Authors. + +Licensed under the Apache License, Version 2.0 (the License); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an AS IS BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package options + +import ( + "github.com/spf13/pflag" + + "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/raven/gatewaypublicservice/config" +) + +type GatewayPublicSvcControllerOptions struct { + *config.GatewayPublicSvcControllerConfiguration +} + +func NewGatewayPublicSvcControllerOptions() *GatewayPublicSvcControllerOptions { + return &GatewayPublicSvcControllerOptions{ + &config.GatewayPublicSvcControllerConfiguration{ + ConcurrentGatewayPublicSvcWorkers: 1, + }, + } +} + +// AddFlags adds flags related to gateway for yurt-manager to the specified FlagSet. +func (g *GatewayPublicSvcControllerOptions) AddFlags(fs *pflag.FlagSet) { + if g == nil { + return + } + + fs.Int32Var(&g.ConcurrentGatewayPublicSvcWorkers, "concurrent-gateway-public-svc-workers", g.ConcurrentGatewayPublicSvcWorkers, "The number of gateway objects that are allowed to reconcile concurrently. Larger number = more responsive gateway public svc, but more CPU (and network) load") + +} + +// ApplyTo fills up gateway config with options. +func (g *GatewayPublicSvcControllerOptions) ApplyTo(cfg *config.GatewayPublicSvcControllerConfiguration) error { + if g == nil { + return nil + } + + cfg.ConcurrentGatewayPublicSvcWorkers = g.ConcurrentGatewayPublicSvcWorkers + return nil +} + +// Validate checks validation of GatewayControllerOptions. +func (g *GatewayPublicSvcControllerOptions) Validate() []error { + if g == nil { + return nil + } + var errs []error + return errs +} diff --git a/cmd/yurt-manager/app/options/options.go b/cmd/yurt-manager/app/options/options.go index 5baf5474a07..b7306677536 100644 --- a/cmd/yurt-manager/app/options/options.go +++ b/cmd/yurt-manager/app/options/options.go @@ -31,7 +31,6 @@ type YurtManagerOptions struct { DaemonPodUpdaterController *DaemonPodUpdaterControllerOptions CsrApproverController *CsrApproverControllerOptions NodePoolController *NodePoolControllerOptions - GatewayPickupController *GatewayPickupControllerOptions YurtStaticSetController *YurtStaticSetControllerOptions YurtAppSetController *YurtAppSetControllerOptions YurtAppDaemonController *YurtAppDaemonControllerOptions @@ -43,6 +42,10 @@ type YurtManagerOptions struct { EndpointSliceController *EndpointSliceControllerOptions LoadBalancerSetController *LoadBalancerSetControllerOptions YurtCoordinatorCertController *YurtCoordinatorCertControllerOptions + GatewayPickupController *GatewayPickupControllerOptions + GatewayDNSController *GatewayDNSControllerOptions + GatewayInternalSvcController *GatewayInternalSvcControllerOptions + GatewayPublicSvcController *GatewayPublicSvcControllerOptions } // NewYurtManagerOptions creates a new YurtManagerOptions with a default config. @@ -55,7 +58,6 @@ func NewYurtManagerOptions() (*YurtManagerOptions, error) { DaemonPodUpdaterController: NewDaemonPodUpdaterControllerOptions(), CsrApproverController: NewCsrApproverControllerOptions(), NodePoolController: NewNodePoolControllerOptions(), - GatewayPickupController: NewGatewayPickupControllerOptions(), YurtStaticSetController: NewYurtStaticSetControllerOptions(), YurtAppSetController: NewYurtAppSetControllerOptions(), YurtAppDaemonController: NewYurtAppDaemonControllerOptions(), @@ -67,6 +69,10 @@ func NewYurtManagerOptions() (*YurtManagerOptions, error) { EndpointSliceController: NewEndpointSliceControllerOptions(), LoadBalancerSetController: NewLoadBalancerSetControllerOptions(), YurtCoordinatorCertController: NewYurtCoordinatorCertControllerOptions(), + GatewayPickupController: NewGatewayPickupControllerOptions(), + GatewayDNSController: NewGatewayDNSControllerOptions(), + GatewayInternalSvcController: NewGatewayInternalSvcControllerOptions(), + GatewayPublicSvcController: NewGatewayPublicSvcControllerOptions(), } return &s, nil @@ -80,7 +86,6 @@ func (y *YurtManagerOptions) Flags(allControllers, disabledByDefaultControllers y.DaemonPodUpdaterController.AddFlags(fss.FlagSet("daemonpodupdater controller")) y.CsrApproverController.AddFlags(fss.FlagSet("csrapprover controller")) y.NodePoolController.AddFlags(fss.FlagSet("nodepool controller")) - y.GatewayPickupController.AddFlags(fss.FlagSet("gateway controller")) y.YurtAppSetController.AddFlags(fss.FlagSet("yurtappset controller")) y.YurtStaticSetController.AddFlags(fss.FlagSet("yurtstaticset controller")) y.YurtAppDaemonController.AddFlags(fss.FlagSet("yurtappdaemon controller")) @@ -92,6 +97,10 @@ func (y *YurtManagerOptions) Flags(allControllers, disabledByDefaultControllers y.EndpointSliceController.AddFlags(fss.FlagSet("endpointslice controller")) y.LoadBalancerSetController.AddFlags(fss.FlagSet("loadbalancerset controller")) y.YurtCoordinatorCertController.AddFlags(fss.FlagSet("yurtcoordinator cert controller")) + y.GatewayPickupController.AddFlags(fss.FlagSet("gatewaypickup controller")) + y.GatewayDNSController.AddFlags(fss.FlagSet("gatewaydns controller")) + y.GatewayInternalSvcController.AddFlags(fss.FlagSet("gatewayinternalsvc controller")) + y.GatewayPublicSvcController.AddFlags(fss.FlagSet("gatewaypublicsvc controller")) return fss } @@ -104,7 +113,6 @@ func (y *YurtManagerOptions) Validate(allControllers []string, controllerAliases errs = append(errs, y.DaemonPodUpdaterController.Validate()...) errs = append(errs, y.CsrApproverController.Validate()...) errs = append(errs, y.NodePoolController.Validate()...) - errs = append(errs, y.GatewayPickupController.Validate()...) errs = append(errs, y.YurtAppSetController.Validate()...) errs = append(errs, y.YurtStaticSetController.Validate()...) errs = append(errs, y.YurtAppDaemonController.Validate()...) @@ -116,6 +124,10 @@ func (y *YurtManagerOptions) Validate(allControllers []string, controllerAliases errs = append(errs, y.EndpointSliceController.Validate()...) errs = append(errs, y.LoadBalancerSetController.Validate()...) errs = append(errs, y.YurtCoordinatorCertController.Validate()...) + errs = append(errs, y.GatewayPickupController.Validate()...) + errs = append(errs, y.GatewayDNSController.Validate()...) + errs = append(errs, y.GatewayInternalSvcController.Validate()...) + errs = append(errs, y.GatewayPublicSvcController.Validate()...) return utilerrors.NewAggregate(errs) } @@ -154,9 +166,6 @@ func (y *YurtManagerOptions) ApplyTo(c *config.Config, controllerAliases map[str if err := y.YurtAppOverriderController.ApplyTo(&c.ComponentConfig.YurtAppOverriderController); err != nil { return err } - if err := y.GatewayPickupController.ApplyTo(&c.ComponentConfig.GatewayPickupController); err != nil { - return err - } if err := y.NodeLifeCycleController.ApplyTo(&c.ComponentConfig.NodeLifeCycleController); err != nil { return err } @@ -175,6 +184,18 @@ func (y *YurtManagerOptions) ApplyTo(c *config.Config, controllerAliases map[str if err := y.YurtCoordinatorCertController.ApplyTo(&c.ComponentConfig.YurtCoordinatorCertController); err != nil { return err } + if err := y.GatewayPickupController.ApplyTo(&c.ComponentConfig.GatewayPickupController); err != nil { + return err + } + if err := y.GatewayDNSController.ApplyTo(&c.ComponentConfig.GatewayDNSController); err != nil { + return err + } + if err := y.GatewayInternalSvcController.ApplyTo(&c.ComponentConfig.GatewayInternalSvcController); err != nil { + return err + } + if err := y.GatewayPublicSvcController.ApplyTo(&c.ComponentConfig.GatewayPublicSvcController); err != nil { + return err + } return nil } diff --git a/pkg/yurtmanager/controller/apis/config/types.go b/pkg/yurtmanager/controller/apis/config/types.go index 8162b97d921..42037b47b28 100644 --- a/pkg/yurtmanager/controller/apis/config/types.go +++ b/pkg/yurtmanager/controller/apis/config/types.go @@ -27,7 +27,10 @@ import ( nodebucketconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/nodebucket/config" nodepoolconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/nodepool/config" platformadminconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/platformadmin/config" + gatewaydnsconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/raven/dns/config" + gatewayinternalsvcconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/raven/gatewayinternalservice/config" gatewaypickupconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/raven/gatewaypickup/config" + gatewaypublicsvcconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/raven/gatewaypublicservice/config" endpointsconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/servicetopology/endpoints/config" endpointsliceconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/servicetopology/endpointslice/config" yurtappdaemonconfig "github.com/openyurtio/openyurt/pkg/yurtmanager/controller/yurtappdaemon/config" @@ -59,9 +62,6 @@ type YurtManagerConfiguration struct { // NodePoolControllerConfiguration holds configuration for NodePoolController related features. NodePoolController nodepoolconfig.NodePoolControllerConfiguration - // GatewayPickupControllerConfiguration holds configuration for GatewayController related features. - GatewayPickupController gatewaypickupconfig.GatewayPickupControllerConfiguration - // YurtAppSetControllerConfiguration holds configuration for YurtAppSetController related features. YurtAppSetController yurtappsetconfig.YurtAppSetControllerConfiguration @@ -79,7 +79,7 @@ type YurtManagerConfiguration struct { NodeLifeCycleController v1alpha1.NodeLifecycleControllerConfiguration - // NodeBucketController holds configuration for NodeBucketController related features. + // NodeBucketController holds configuration for NodeBucketController related features. NodeBucketController nodebucketconfig.NodeBucketControllerConfiguration // EndpointsController holds configuration for EndpointsController related features. @@ -88,11 +88,23 @@ type YurtManagerConfiguration struct { // EndpointSliceController holds configuration for EndpointSliceController related features. ServiceTopologyEndpointSliceController endpointsliceconfig.ServiceTopologyEndpointSliceControllerConfiguration - // LoadBalancerSetController holds configuration for LoadBalancerSetController related features. + // LoadBalancerSetController holds configuration for LoadBalancerSetController related features. LoadBalancerSetController loadbalancersetconfig.LoadBalancerSetControllerConfiguration // YurtCoordinatorCertController holds configuration for YurtCoordinatorCertController related features. YurtCoordinatorCertController coordinatorcertconfig.YurtCoordinatorCertControllerConfiguration + + // GatewayPickupControllerConfiguration holds configuration for GatewayController related features. + GatewayPickupController gatewaypickupconfig.GatewayPickupControllerConfiguration + + // GatewayDNSController holds configuration for GatewayDNSController related features. + GatewayDNSController gatewaydnsconfig.GatewayDNSControllerConfiguration + + // GatewayInternalSvcController holds configuration for GatewayInternalSvcController related features. + GatewayInternalSvcController gatewayinternalsvcconfig.GatewayInternalSvcControllerConfiguration + + // GatewayPublicSvcController holds configuration for GatewayPublicSvcController related features. + GatewayPublicSvcController gatewaypublicsvcconfig.GatewayPublicSvcControllerConfiguration } type GenericConfiguration struct { diff --git a/pkg/yurtmanager/controller/raven/dns/config/types.go b/pkg/yurtmanager/controller/raven/dns/config/types.go new file mode 100644 index 00000000000..1dc0c5b6692 --- /dev/null +++ b/pkg/yurtmanager/controller/raven/dns/config/types.go @@ -0,0 +1,22 @@ +/* +Copyright 2024 The OpenYurt Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package config + +// GatewayDNSControllerConfiguration contains elements describing GatewayDNSController. +type GatewayDNSControllerConfiguration struct { + ConcurrentGatewayDNSWorkers int32 +} diff --git a/pkg/yurtmanager/controller/raven/dns/gateway_dns_controller.go b/pkg/yurtmanager/controller/raven/dns/gateway_dns_controller.go index a0841f019da..ca3fa1dc5bb 100644 --- a/pkg/yurtmanager/controller/raven/dns/gateway_dns_controller.go +++ b/pkg/yurtmanager/controller/raven/dns/gateway_dns_controller.go @@ -53,7 +53,7 @@ func Format(format string, args ...interface{}) string { // Add creates a new Ravendns Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller // and Start it when the Manager is Started. func Add(ctx context.Context, c *appconfig.CompletedConfig, mgr manager.Manager) error { - return add(mgr, newReconciler(mgr)) + return add(mgr, c, newReconciler(mgr)) } var _ reconcile.Reconciler = &ReconcileDns{} @@ -74,10 +74,10 @@ func newReconciler(mgr manager.Manager) reconcile.Reconciler { } // 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.GatewayDNSController, mgr, controller.Options{ - Reconciler: r, MaxConcurrentReconciles: util.ConcurrentReconciles, + Reconciler: r, MaxConcurrentReconciles: int(cfg.ComponentConfig.GatewayDNSController.ConcurrentGatewayDNSWorkers), }) if err != nil { return err diff --git a/pkg/yurtmanager/controller/raven/gatewayinternalservice/config/types.go b/pkg/yurtmanager/controller/raven/gatewayinternalservice/config/types.go new file mode 100644 index 00000000000..e6f0ba358bc --- /dev/null +++ b/pkg/yurtmanager/controller/raven/gatewayinternalservice/config/types.go @@ -0,0 +1,22 @@ +/* +Copyright 2024 The OpenYurt Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package config + +// GatewayInternalSvcControllerConfiguration contains elements describing GatewayInternalServiceController. +type GatewayInternalSvcControllerConfiguration struct { + ConcurrentGatewayInternalSvcWorkers int32 +} diff --git a/pkg/yurtmanager/controller/raven/gatewayinternalservice/gateway_internal_service_controller.go b/pkg/yurtmanager/controller/raven/gatewayinternalservice/gateway_internal_service_controller.go index 3e29834567a..84a4b226308 100644 --- a/pkg/yurtmanager/controller/raven/gatewayinternalservice/gateway_internal_service_controller.go +++ b/pkg/yurtmanager/controller/raven/gatewayinternalservice/gateway_internal_service_controller.go @@ -62,7 +62,7 @@ func Format(format string, args ...interface{}) string { // Add creates a new Service Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller // and Start it when the Manager is Started. func Add(ctx context.Context, c *appconfig.CompletedConfig, mgr manager.Manager) error { - return add(mgr, newReconciler(c, mgr)) + return add(mgr, c, newReconciler(c, mgr)) } var _ reconcile.Reconciler = &ReconcileService{} @@ -84,10 +84,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.GatewayInternalServiceController, mgr, controller.Options{ - Reconciler: r, MaxConcurrentReconciles: util.ConcurrentReconciles, + Reconciler: r, MaxConcurrentReconciles: int(cfg.ComponentConfig.GatewayInternalSvcController.ConcurrentGatewayInternalSvcWorkers), }) if err != nil { return err diff --git a/pkg/yurtmanager/controller/raven/gatewaypickup/config/types.go b/pkg/yurtmanager/controller/raven/gatewaypickup/config/types.go index ee7572d6aef..36cde38861f 100644 --- a/pkg/yurtmanager/controller/raven/gatewaypickup/config/types.go +++ b/pkg/yurtmanager/controller/raven/gatewaypickup/config/types.go @@ -18,4 +18,5 @@ package config // GatewayPickupControllerConfiguration contains elements describing GatewayPickController. type GatewayPickupControllerConfiguration struct { + ConcurrentGatewayPickupWorkers int32 } diff --git a/pkg/yurtmanager/controller/raven/gatewaypickup/gateway_pickup_controller.go b/pkg/yurtmanager/controller/raven/gatewaypickup/gateway_pickup_controller.go index 86b98fe5ac0..421a87cb708 100644 --- a/pkg/yurtmanager/controller/raven/gatewaypickup/gateway_pickup_controller.go +++ b/pkg/yurtmanager/controller/raven/gatewaypickup/gateway_pickup_controller.go @@ -73,7 +73,7 @@ func Add(ctx context.Context, c *appconfig.CompletedConfig, mgr manager.Manager) return err } klog.Infof("raven-gateway-controller add controller %s", controllerResource.String()) - return add(mgr, newReconciler(c, mgr)) + return add(mgr, c, newReconciler(c, mgr)) } var _ reconcile.Reconciler = &ReconcileGateway{} @@ -97,10 +97,10 @@ func newReconciler(c *appconfig.CompletedConfig, mgr manager.Manager) reconcile. } // add is used to add a new Controller to mgr -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.GatewayPickupController, mgr, controller.Options{ - Reconciler: r, MaxConcurrentReconciles: util.ConcurrentReconciles, + Reconciler: r, MaxConcurrentReconciles: int(cfg.ComponentConfig.GatewayPickupController.ConcurrentGatewayPickupWorkers), }) if err != nil { return err diff --git a/pkg/yurtmanager/controller/raven/gatewaypublicservice/config/types.go b/pkg/yurtmanager/controller/raven/gatewaypublicservice/config/types.go new file mode 100644 index 00000000000..3d1d0e4f0d3 --- /dev/null +++ b/pkg/yurtmanager/controller/raven/gatewaypublicservice/config/types.go @@ -0,0 +1,22 @@ +/* +Copyright 2024 The OpenYurt Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package config + +// GatewayPublicSvcControllerConfiguration contains elements describing GatewayPublicServiceController. +type GatewayPublicSvcControllerConfiguration struct { + ConcurrentGatewayPublicSvcWorkers int32 +} diff --git a/pkg/yurtmanager/controller/raven/gatewaypublicservice/gateway_public_service_controller.go b/pkg/yurtmanager/controller/raven/gatewaypublicservice/gateway_public_service_controller.go index ff205047ec9..8a823d85764 100644 --- a/pkg/yurtmanager/controller/raven/gatewaypublicservice/gateway_public_service_controller.go +++ b/pkg/yurtmanager/controller/raven/gatewaypublicservice/gateway_public_service_controller.go @@ -59,7 +59,7 @@ func Format(format string, args ...interface{}) string { // Add creates a new Service Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller // and Start it when the Manager is Started. func Add(ctx context.Context, c *appconfig.CompletedConfig, mgr manager.Manager) error { - return add(mgr, newReconciler(mgr)) + return add(mgr, c, newReconciler(mgr)) } var _ reconcile.Reconciler = &ReconcileService{} @@ -96,10 +96,10 @@ func newReconciler(mgr manager.Manager) reconcile.Reconciler { } // 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.GatewayPublicServiceController, mgr, controller.Options{ - Reconciler: r, MaxConcurrentReconciles: util.ConcurrentReconciles, + Reconciler: r, MaxConcurrentReconciles: int(cfg.ComponentConfig.GatewayPublicSvcController.ConcurrentGatewayPublicSvcWorkers), }) if err != nil { return err diff --git a/pkg/yurtmanager/controller/raven/util/constants.go b/pkg/yurtmanager/controller/raven/util/constants.go index ccacc39b9d1..ff4aca72928 100644 --- a/pkg/yurtmanager/controller/raven/util/constants.go +++ b/pkg/yurtmanager/controller/raven/util/constants.go @@ -17,7 +17,6 @@ limitations under the License. package util const ( - ConcurrentReconciles = 1 WorkingNamespace = "kube-system" RavenGlobalConfig = "raven-cfg" RavenAgentConfig = "raven-agent-config"