Skip to content

Commit e8444c0

Browse files
author
rambohe
authored
improve concurrent node bucket workers configuration (#2065)
1 parent 7fff3ca commit e8444c0

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

cmd/yurt-manager/app/options/nodebucketcontroller.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ type NodeBucketControllerOptions struct {
3131
func NewNodeBucketControllerOptions() *NodeBucketControllerOptions {
3232
return &NodeBucketControllerOptions{
3333
&config.NodeBucketControllerConfiguration{
34-
MaxNodesPerBucket: 100,
34+
MaxNodesPerBucket: 100,
35+
ConcurrentNodeBucketWorkers: 3,
3536
},
3637
}
3738
}
@@ -43,6 +44,7 @@ func (n *NodeBucketControllerOptions) AddFlags(fs *pflag.FlagSet) {
4344
}
4445

4546
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.")
47+
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")
4648
}
4749

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

5456
cfg.MaxNodesPerBucket = o.MaxNodesPerBucket
57+
cfg.ConcurrentNodeBucketWorkers = o.ConcurrentNodeBucketWorkers
5558

5659
return nil
5760
}

pkg/yurtmanager/controller/nodebucket/config/types.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ package config
1818

1919
// NodeBucketControllerConfiguration contains elements describing NodeBucketController.
2020
type NodeBucketControllerConfiguration struct {
21-
MaxNodesPerBucket int32
21+
MaxNodesPerBucket int32
22+
ConcurrentNodeBucketWorkers int32
2223
}

pkg/yurtmanager/controller/nodebucket/nodebucket_controller.go

+3-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package nodebucket
1818

1919
import (
2020
"context"
21-
"flag"
2221
"fmt"
2322
"sort"
2423

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

48-
func init() {
49-
flag.IntVar(&concurrentReconciles, "nodebucket-workers", concurrentReconciles, "Max concurrent workers for NodeBucket controller.")
50-
}
51-
5247
var (
53-
concurrentReconciles = 3
54-
controllerResource = appsv1alpha1.SchemeGroupVersion.WithResource("nodebuckets")
48+
controllerResource = appsv1alpha1.SchemeGroupVersion.WithResource("nodebuckets")
5549
)
5650

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

7569
// Create a new controller
7670
c, err := controller.New(names.NodeBucketController, mgr, controller.Options{
77-
Reconciler: r, MaxConcurrentReconciles: concurrentReconciles,
71+
Reconciler: r,
72+
MaxConcurrentReconciles: int(cfg.ComponentConfig.NodeBucketController.ConcurrentNodeBucketWorkers),
7873
})
7974
if err != nil {
8075
return err

0 commit comments

Comments
 (0)