Skip to content

Commit

Permalink
improve concurrent node bucket workers configuration (#2065)
Browse files Browse the repository at this point in the history
  • Loading branch information
rambohe-ch authored Jun 7, 2024
1 parent 7fff3ca commit e8444c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
5 changes: 4 additions & 1 deletion cmd/yurt-manager/app/options/nodebucketcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ type NodeBucketControllerOptions struct {
func NewNodeBucketControllerOptions() *NodeBucketControllerOptions {
return &NodeBucketControllerOptions{
&config.NodeBucketControllerConfiguration{
MaxNodesPerBucket: 100,
MaxNodesPerBucket: 100,
ConcurrentNodeBucketWorkers: 3,
},
}
}
Expand All @@ -43,6 +44,7 @@ func (n *NodeBucketControllerOptions) AddFlags(fs *pflag.FlagSet) {
}

fs.Int32Var(&n.MaxNodesPerBucket, "max-nodes-per-bucket", n.MaxNodesPerBucket, "The maximum number of nodes that will be added to a NodeBucket. More nodes per bucket will result in less node buckets, but larger resources. Defaults to 100.")
fs.Int32Var(&n.ConcurrentNodeBucketWorkers, "concurrent-node-bucket-workers", n.ConcurrentNodeBucketWorkers, "The number of nodebucket objects that are allowed to reconcile concurrently. Larger number = more responsive nodebuckets, but more CPU (and network) load")
}

// ApplyTo fills up nodebucket config with options.
Expand All @@ -52,6 +54,7 @@ func (o *NodeBucketControllerOptions) ApplyTo(cfg *config.NodeBucketControllerCo
}

cfg.MaxNodesPerBucket = o.MaxNodesPerBucket
cfg.ConcurrentNodeBucketWorkers = o.ConcurrentNodeBucketWorkers

return nil
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/yurtmanager/controller/nodebucket/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ package config

// NodeBucketControllerConfiguration contains elements describing NodeBucketController.
type NodeBucketControllerConfiguration struct {
MaxNodesPerBucket int32
MaxNodesPerBucket int32
ConcurrentNodeBucketWorkers int32
}
11 changes: 3 additions & 8 deletions pkg/yurtmanager/controller/nodebucket/nodebucket_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package nodebucket

import (
"context"
"flag"
"fmt"
"sort"

Expand All @@ -45,13 +44,8 @@ import (
"github.com/openyurtio/openyurt/pkg/projectinfo"
)

func init() {
flag.IntVar(&concurrentReconciles, "nodebucket-workers", concurrentReconciles, "Max concurrent workers for NodeBucket controller.")
}

var (
concurrentReconciles = 3
controllerResource = appsv1alpha1.SchemeGroupVersion.WithResource("nodebuckets")
controllerResource = appsv1alpha1.SchemeGroupVersion.WithResource("nodebuckets")
)

const (
Expand All @@ -74,7 +68,8 @@ func Add(_ context.Context, cfg *appconfig.CompletedConfig, mgr manager.Manager)

// Create a new controller
c, err := controller.New(names.NodeBucketController, mgr, controller.Options{
Reconciler: r, MaxConcurrentReconciles: concurrentReconciles,
Reconciler: r,
MaxConcurrentReconciles: int(cfg.ComponentConfig.NodeBucketController.ConcurrentNodeBucketWorkers),
})
if err != nil {
return err
Expand Down

0 comments on commit e8444c0

Please sign in to comment.