Skip to content

Commit 6795dba

Browse files
authored
Merge pull request #5809 from CharlesQQ/introduce-flag-dependencies-distributor
feat(dependenciesdistributor): introduce --concurrent-dependent-resource-syncs flag
2 parents 526ed37 + 066eec0 commit 6795dba

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

cmd/controller-manager/app/controllermanager.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -773,13 +773,14 @@ func setupControllers(mgr controllerruntime.Manager, opts *options.Options, stop
773773
}
774774
if features.FeatureGate.Enabled(features.PropagateDeps) {
775775
dependenciesDistributor := &dependenciesdistributor.DependenciesDistributor{
776-
Client: mgr.GetClient(),
777-
DynamicClient: dynamicClientSet,
778-
InformerManager: controlPlaneInformerManager,
779-
ResourceInterpreter: resourceInterpreter,
780-
RESTMapper: mgr.GetRESTMapper(),
781-
EventRecorder: mgr.GetEventRecorderFor("dependencies-distributor"),
782-
RateLimiterOptions: opts.RateLimiterOpts,
776+
Client: mgr.GetClient(),
777+
DynamicClient: dynamicClientSet,
778+
InformerManager: controlPlaneInformerManager,
779+
ResourceInterpreter: resourceInterpreter,
780+
RESTMapper: mgr.GetRESTMapper(),
781+
EventRecorder: mgr.GetEventRecorderFor("dependencies-distributor"),
782+
RateLimiterOptions: opts.RateLimiterOpts,
783+
ConcurrentDependentResourceSyncs: opts.ConcurrentDependentResourceSyncs,
783784
}
784785
if err := dependenciesDistributor.SetupWithManager(mgr); err != nil {
785786
klog.Fatalf("Failed to setup dependencies distributor: %v", err)

cmd/controller-manager/app/options/options.go

+3
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ type Options struct {
128128
ConcurrentClusterPropagationPolicySyncs int
129129
// ConcurrentResourceTemplateSyncs is the number of resource templates that are allowed to sync concurrently.
130130
ConcurrentResourceTemplateSyncs int
131+
// ConcurrentDependentResourceSyncs is the number of dependent resource that are allowed to sync concurrently.
132+
ConcurrentDependentResourceSyncs int
131133
// If set to true enables NoExecute Taints and will evict all not-tolerating
132134
// objects propagating on Clusters tainted with this kind of Taints.
133135
EnableTaintManager bool
@@ -219,6 +221,7 @@ func (o *Options) AddFlags(flags *pflag.FlagSet, allControllers, disabledByDefau
219221
flags.IntVar(&o.ConcurrentPropagationPolicySyncs, "concurrent-propagation-policy-syncs", 1, "The number of PropagationPolicy that are allowed to sync concurrently.")
220222
flags.IntVar(&o.ConcurrentClusterPropagationPolicySyncs, "concurrent-cluster-propagation-policy-syncs", 1, "The number of ClusterPropagationPolicy that are allowed to sync concurrently.")
221223
flags.IntVar(&o.ConcurrentResourceTemplateSyncs, "concurrent-resource-template-syncs", 5, "The number of resource templates that are allowed to sync concurrently.")
224+
flags.IntVar(&o.ConcurrentDependentResourceSyncs, "concurrent-dependent-resource-syncs", 2, "The number of dependent resource that are allowed to sync concurrently.")
222225
flags.BoolVar(&o.EnableTaintManager, "enable-taint-manager", true, "If set to true enables NoExecute Taints and will evict all not-tolerating objects propagating on Clusters tainted with this kind of Taints.")
223226
flags.DurationVar(&o.GracefulEvictionTimeout.Duration, "graceful-eviction-timeout", 10*time.Minute, "Specifies the timeout period waiting for the graceful-eviction-controller performs the final removal since the workload(resource) has been moved to the graceful eviction tasks.")
224227
flags.BoolVar(&o.EnableClusterResourceModeling, "enable-cluster-resource-modeling", true, "Enable means controller would build resource modeling for each cluster by syncing Nodes and Pods resources.\n"+

pkg/dependenciesdistributor/dependencies_distributor.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ type DependenciesDistributor struct {
110110
resourceProcessor util.AsyncWorker
111111
genericEvent chan event.TypedGenericEvent[*workv1alpha2.ResourceBinding]
112112
stopCh <-chan struct{}
113+
// ConcurrentDependentResourceSyncs is the number of dependent resource that are allowed to sync concurrently.
114+
ConcurrentDependentResourceSyncs int
113115
}
114116

115117
// Check if our DependenciesDistributor implements necessary interfaces
@@ -615,7 +617,7 @@ func (d *DependenciesDistributor) Start(ctx context.Context) error {
615617
}
616618
d.eventHandler = fedinformer.NewHandlerOnEvents(d.OnAdd, d.OnUpdate, d.OnDelete)
617619
d.resourceProcessor = util.NewAsyncWorker(resourceWorkerOptions)
618-
d.resourceProcessor.Run(2, d.stopCh)
620+
d.resourceProcessor.Run(d.ConcurrentDependentResourceSyncs, d.stopCh)
619621
<-d.stopCh
620622

621623
klog.Infof("Stopped as stopCh closed.")

0 commit comments

Comments
 (0)