mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
Added ActiveDeadlineSeconds to jobs, allowing failing a job after
exceeding allowed time.
This commit is contained in:
@@ -338,6 +338,9 @@ func ValidateJobSpec(spec *extensions.JobSpec, fldPath *field.Path) field.ErrorL
|
||||
if spec.Completions != nil {
|
||||
allErrs = append(allErrs, apivalidation.ValidatePositiveField(int64(*spec.Completions), fldPath.Child("completions"))...)
|
||||
}
|
||||
if spec.ActiveDeadlineSeconds != nil {
|
||||
allErrs = append(allErrs, apivalidation.ValidatePositiveField(int64(*spec.ActiveDeadlineSeconds), fldPath.Child("activeDeadlineSeconds"))...)
|
||||
}
|
||||
if spec.Selector == nil {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("selector")))
|
||||
} else {
|
||||
|
||||
@@ -839,6 +839,7 @@ func TestValidateJob(t *testing.T) {
|
||||
}
|
||||
}
|
||||
negative := -1
|
||||
negative64 := int64(-1)
|
||||
errorCases := map[string]extensions.Job{
|
||||
"spec.parallelism:must be non-negative": {
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
@@ -862,6 +863,17 @@ func TestValidateJob(t *testing.T) {
|
||||
Template: validPodTemplateSpec,
|
||||
},
|
||||
},
|
||||
"spec.activeDeadlineSeconds:must be non-negative": {
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "myjob",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: extensions.JobSpec{
|
||||
ActiveDeadlineSeconds: &negative64,
|
||||
Selector: validSelector,
|
||||
Template: validPodTemplateSpec,
|
||||
},
|
||||
},
|
||||
"spec.selector:required value": {
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "myjob",
|
||||
|
||||
Reference in New Issue
Block a user