Skip to content

Commit

Permalink
feat: improve concurrent workers for raven controllers (openyurtio#2089)
Browse files Browse the repository at this point in the history
  • Loading branch information
rambohe-ch authored Jun 26, 2024
1 parent 293ef12 commit 0fa908b
Showing 15 changed files with 322 additions and 26 deletions.
64 changes: 64 additions & 0 deletions cmd/yurt-manager/app/options/gatewaydnscontroller.go
Original file line number Diff line number Diff line change
@@ -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
}
64 changes: 64 additions & 0 deletions cmd/yurt-manager/app/options/gatewayinternalsvccontroller.go
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
}

64 changes: 64 additions & 0 deletions cmd/yurt-manager/app/options/gatewaypublicsvccontroller.go
Original file line number Diff line number Diff line change
@@ -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
}
35 changes: 28 additions & 7 deletions cmd/yurt-manager/app/options/options.go
Original file line number Diff line number Diff line change
@@ -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
}

22 changes: 17 additions & 5 deletions pkg/yurtmanager/controller/apis/config/types.go
Original file line number Diff line number Diff line change
@@ -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 {
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

0 comments on commit 0fa908b

Please sign in to comment.