mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 13:55:41 +00:00
add --concurrent-cron-job-syncs flag
This commit is contained in:
parent
08755fe249
commit
f9bab9a60b
@ -17,6 +17,8 @@ limitations under the License.
|
||||
package options
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
cronjobconfig "k8s.io/kubernetes/pkg/controller/cronjob/config"
|
||||
@ -32,6 +34,8 @@ func (o *CronJobControllerOptions) AddFlags(fs *pflag.FlagSet) {
|
||||
if o == nil {
|
||||
return
|
||||
}
|
||||
|
||||
fs.Int32Var(&o.ConcurrentCronJobSyncs, "concurrent-cron-job-syncs", o.ConcurrentCronJobSyncs, "The number of cron 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.
|
||||
@ -52,5 +56,9 @@ func (o *CronJobControllerOptions) Validate() []error {
|
||||
}
|
||||
|
||||
errs := []error{}
|
||||
if o.ConcurrentCronJobSyncs < 1 {
|
||||
errs = append(errs, fmt.Errorf("concurrent-cron-job-syncs must be greater than 0, but got %d", o.ConcurrentCronJobSyncs))
|
||||
}
|
||||
|
||||
return errs
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ var args = []string{
|
||||
"--concurrent-gc-syncs=30",
|
||||
"--concurrent-namespace-syncs=20",
|
||||
"--concurrent-job-syncs=10",
|
||||
"--concurrent-cron-job-syncs=10",
|
||||
"--concurrent-replicaset-syncs=10",
|
||||
"--concurrent-resource-quota-syncs=10",
|
||||
"--concurrent-service-syncs=2",
|
||||
@ -325,7 +326,7 @@ func TestAddFlags(t *testing.T) {
|
||||
},
|
||||
CronJobController: &CronJobControllerOptions{
|
||||
&cronjobconfig.CronJobControllerConfiguration{
|
||||
ConcurrentCronJobSyncs: 5,
|
||||
ConcurrentCronJobSyncs: 10,
|
||||
},
|
||||
},
|
||||
NamespaceController: &NamespaceControllerOptions{
|
||||
@ -574,7 +575,7 @@ func TestApplyTo(t *testing.T) {
|
||||
ConcurrentJobSyncs: 10,
|
||||
},
|
||||
CronJobController: cronjobconfig.CronJobControllerConfiguration{
|
||||
ConcurrentCronJobSyncs: 5,
|
||||
ConcurrentCronJobSyncs: 10,
|
||||
},
|
||||
NamespaceController: namespaceconfig.NamespaceControllerConfiguration{
|
||||
NamespaceSyncPeriod: metav1.Duration{Duration: 10 * time.Minute},
|
||||
@ -1087,13 +1088,23 @@ func TestValidateControllersOptions(t *testing.T) {
|
||||
},
|
||||
}).Validate,
|
||||
},
|
||||
{
|
||||
name: "CronJobControllerOptions ConcurrentCronJobSyncs equal 0",
|
||||
expectErrors: true,
|
||||
expectedErrorSubString: "concurrent-cron-job-syncs must be greater than 0",
|
||||
validate: (&CronJobControllerOptions{
|
||||
&cronjobconfig.CronJobControllerConfiguration{
|
||||
ConcurrentCronJobSyncs: 0,
|
||||
},
|
||||
}).Validate,
|
||||
},
|
||||
/* empty errs */
|
||||
{
|
||||
name: "CronJobControllerOptions",
|
||||
expectErrors: false,
|
||||
validate: (&CronJobControllerOptions{
|
||||
&cronjobconfig.CronJobControllerConfiguration{
|
||||
ConcurrentCronJobSyncs: 5,
|
||||
ConcurrentCronJobSyncs: 10,
|
||||
},
|
||||
}).Validate,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user