From 4afa554f6555620991c9cc41c45391485cc66aa2 Mon Sep 17 00:00:00 2001 From: Antoni Zawodny Date: Wed, 30 Oct 2024 11:11:27 +0100 Subject: [PATCH] Add `--concurrent-daemonset-syncs` flag to kube-controller-manager --- .../app/options/daemonsetcontroller.go | 7 +++++++ .../app/options/options_test.go | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cmd/kube-controller-manager/app/options/daemonsetcontroller.go b/cmd/kube-controller-manager/app/options/daemonsetcontroller.go index 8506f8ec05c..0f7c9e98cde 100644 --- a/cmd/kube-controller-manager/app/options/daemonsetcontroller.go +++ b/cmd/kube-controller-manager/app/options/daemonsetcontroller.go @@ -17,6 +17,8 @@ limitations under the License. package options import ( + "fmt" + "github.com/spf13/pflag" daemonconfig "k8s.io/kubernetes/pkg/controller/daemon/config" @@ -32,6 +34,8 @@ func (o *DaemonSetControllerOptions) AddFlags(fs *pflag.FlagSet) { if o == nil { return } + + fs.Int32Var(&o.ConcurrentDaemonSetSyncs, "concurrent-daemonset-syncs", o.ConcurrentDaemonSetSyncs, "The number of daemonset objects that are allowed to sync concurrently. Larger number = more responsive daemonsets, but more CPU (and network) load") } // ApplyTo fills up DaemonSetController config with options. @@ -52,5 +56,8 @@ func (o *DaemonSetControllerOptions) Validate() []error { } errs := []error{} + if o.ConcurrentDaemonSetSyncs < 1 { + errs = append(errs, fmt.Errorf("concurrent-daemonset-syncs must be greater than 0, but got %d", o.ConcurrentDaemonSetSyncs)) + } return errs } diff --git a/cmd/kube-controller-manager/app/options/options_test.go b/cmd/kube-controller-manager/app/options/options_test.go index 8dd14340811..c2235a9c082 100644 --- a/cmd/kube-controller-manager/app/options/options_test.go +++ b/cmd/kube-controller-manager/app/options/options_test.go @@ -98,6 +98,7 @@ var args = []string{ "--cluster-signing-legacy-unknown-cert-file=/cluster-signing-legacy-unknown/cert-file", "--cluster-signing-legacy-unknown-key-file=/cluster-signing-legacy-unknown/key-file", "--concurrent-deployment-syncs=10", + "--concurrent-daemonset-syncs=10", "--concurrent-horizontal-pod-autoscaler-syncs=10", "--concurrent-statefulset-syncs=15", "--concurrent-endpoint-syncs=10", @@ -264,7 +265,7 @@ func TestAddFlags(t *testing.T) { }, DaemonSetController: &DaemonSetControllerOptions{ &daemonconfig.DaemonSetControllerConfiguration{ - ConcurrentDaemonSetSyncs: 2, + ConcurrentDaemonSetSyncs: 10, }, }, DeploymentController: &DeploymentControllerOptions{ @@ -514,6 +515,13 @@ func TestValidateFlags(t *testing.T) { }, wantErr: true, }, + { + name: "concurrent daemonset syncs set to 0", + flags: []string{ + "--concurrent-daemonset-syncs=0", + }, + wantErr: true, + }, } for _, tc := range testcases { @@ -609,7 +617,7 @@ func TestApplyTo(t *testing.T) { }, }, DaemonSetController: daemonconfig.DaemonSetControllerConfiguration{ - ConcurrentDaemonSetSyncs: 2, + ConcurrentDaemonSetSyncs: 10, }, DeploymentController: deploymentconfig.DeploymentControllerConfiguration{ ConcurrentDeploymentSyncs: 10,