Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --concurrent-job-syncs flag to kube-controller-manager #117138

Merged
merged 1 commit into from Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/kube-controller-manager/app/options/jobcontroller.go
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package options

import (
"fmt"

"github.com/spf13/pflag"

jobconfig "k8s.io/kubernetes/pkg/controller/job/config"
Expand All @@ -32,6 +34,8 @@ func (o *JobControllerOptions) AddFlags(fs *pflag.FlagSet) {
if o == nil {
return
}

fs.Int32Var(&o.ConcurrentJobSyncs, "concurrent-job-syncs", o.ConcurrentJobSyncs, "The number of job objects that are allowed to sync concurrently. Larger number = more responsive jobs, but more CPU (and network) load")
}

// ApplyTo fills up JobController config with options.
Expand All @@ -52,5 +56,8 @@ func (o *JobControllerOptions) Validate() []error {
}

errs := []error{}
if o.ConcurrentJobSyncs < 1 {
errs = append(errs, fmt.Errorf("concurrent-job-syncs must be greater than 0, but got %d", o.ConcurrentJobSyncs))
}
return errs
}
17 changes: 14 additions & 3 deletions cmd/kube-controller-manager/app/options/options_test.go
Expand Up @@ -94,6 +94,7 @@ var args = []string{
"--concurrent-service-endpoint-syncs=10",
"--concurrent-gc-syncs=30",
"--concurrent-namespace-syncs=20",
"--concurrent-job-syncs=10",
"--concurrent-replicaset-syncs=10",
"--concurrent-resource-quota-syncs=10",
"--concurrent-service-syncs=2",
Expand Down Expand Up @@ -319,7 +320,7 @@ func TestAddFlags(t *testing.T) {
},
JobController: &JobControllerOptions{
&jobconfig.JobControllerConfiguration{
ConcurrentJobSyncs: 5,
ConcurrentJobSyncs: 10,
},
},
CronJobController: &CronJobControllerOptions{
Expand Down Expand Up @@ -570,7 +571,7 @@ func TestApplyTo(t *testing.T) {
HorizontalPodAutoscalerTolerance: 0.1,
},
JobController: jobconfig.JobControllerConfiguration{
ConcurrentJobSyncs: 5,
ConcurrentJobSyncs: 10,
},
CronJobController: cronjobconfig.CronJobControllerConfiguration{
ConcurrentCronJobSyncs: 5,
Expand Down Expand Up @@ -1076,6 +1077,16 @@ func TestValidateControllersOptions(t *testing.T) {
},
}).Validate,
},
{
name: "JobControllerOptions ConcurrentJobSyncs equal 0",
expectErrors: true,
expectedErrorSubString: "concurrent-job-syncs must be greater than 0",
validate: (&JobControllerOptions{
&jobconfig.JobControllerConfiguration{
ConcurrentJobSyncs: 0,
},
}).Validate,
},
/* empty errs */
{
name: "CronJobControllerOptions",
Expand Down Expand Up @@ -1139,7 +1150,7 @@ func TestValidateControllersOptions(t *testing.T) {
expectErrors: false,
validate: (&JobControllerOptions{
&jobconfig.JobControllerConfiguration{
ConcurrentJobSyncs: 5,
ConcurrentJobSyncs: 10,
},
}).Validate,
},
Expand Down