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
|
package options
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
cronjobconfig "k8s.io/kubernetes/pkg/controller/cronjob/config"
|
cronjobconfig "k8s.io/kubernetes/pkg/controller/cronjob/config"
|
||||||
@ -32,6 +34,8 @@ func (o *CronJobControllerOptions) AddFlags(fs *pflag.FlagSet) {
|
|||||||
if o == nil {
|
if o == nil {
|
||||||
return
|
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.
|
// ApplyTo fills up JobController config with options.
|
||||||
@ -52,5 +56,9 @@ func (o *CronJobControllerOptions) Validate() []error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
errs := []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
|
return errs
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,7 @@ var args = []string{
|
|||||||
"--concurrent-gc-syncs=30",
|
"--concurrent-gc-syncs=30",
|
||||||
"--concurrent-namespace-syncs=20",
|
"--concurrent-namespace-syncs=20",
|
||||||
"--concurrent-job-syncs=10",
|
"--concurrent-job-syncs=10",
|
||||||
|
"--concurrent-cron-job-syncs=10",
|
||||||
"--concurrent-replicaset-syncs=10",
|
"--concurrent-replicaset-syncs=10",
|
||||||
"--concurrent-resource-quota-syncs=10",
|
"--concurrent-resource-quota-syncs=10",
|
||||||
"--concurrent-service-syncs=2",
|
"--concurrent-service-syncs=2",
|
||||||
@ -325,7 +326,7 @@ func TestAddFlags(t *testing.T) {
|
|||||||
},
|
},
|
||||||
CronJobController: &CronJobControllerOptions{
|
CronJobController: &CronJobControllerOptions{
|
||||||
&cronjobconfig.CronJobControllerConfiguration{
|
&cronjobconfig.CronJobControllerConfiguration{
|
||||||
ConcurrentCronJobSyncs: 5,
|
ConcurrentCronJobSyncs: 10,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
NamespaceController: &NamespaceControllerOptions{
|
NamespaceController: &NamespaceControllerOptions{
|
||||||
@ -574,7 +575,7 @@ func TestApplyTo(t *testing.T) {
|
|||||||
ConcurrentJobSyncs: 10,
|
ConcurrentJobSyncs: 10,
|
||||||
},
|
},
|
||||||
CronJobController: cronjobconfig.CronJobControllerConfiguration{
|
CronJobController: cronjobconfig.CronJobControllerConfiguration{
|
||||||
ConcurrentCronJobSyncs: 5,
|
ConcurrentCronJobSyncs: 10,
|
||||||
},
|
},
|
||||||
NamespaceController: namespaceconfig.NamespaceControllerConfiguration{
|
NamespaceController: namespaceconfig.NamespaceControllerConfiguration{
|
||||||
NamespaceSyncPeriod: metav1.Duration{Duration: 10 * time.Minute},
|
NamespaceSyncPeriod: metav1.Duration{Duration: 10 * time.Minute},
|
||||||
@ -1087,13 +1088,23 @@ func TestValidateControllersOptions(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}).Validate,
|
}).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 */
|
/* empty errs */
|
||||||
{
|
{
|
||||||
name: "CronJobControllerOptions",
|
name: "CronJobControllerOptions",
|
||||||
expectErrors: false,
|
expectErrors: false,
|
||||||
validate: (&CronJobControllerOptions{
|
validate: (&CronJobControllerOptions{
|
||||||
&cronjobconfig.CronJobControllerConfiguration{
|
&cronjobconfig.CronJobControllerConfiguration{
|
||||||
ConcurrentCronJobSyncs: 5,
|
ConcurrentCronJobSyncs: 10,
|
||||||
},
|
},
|
||||||
}).Validate,
|
}).Validate,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user