Merge pull request #111113 from mimowo/retriable-pod-failures-job-controller

Support handling of pod failures with respect to the configured rules

Kubernetes-commit: eefcf6aa801c5db48b564d0464470d623b8bfb79
This commit is contained in:
Kubernetes Publisher 2022-08-04 13:35:46 -07:00
commit f10f16e029
9 changed files with 308 additions and 11 deletions

View File

@ -21,7 +21,7 @@ package v1
import (
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/client-go/applyconfigurations/core/v1"
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
metav1 "k8s.io/client-go/applyconfigurations/meta/v1"
)
// JobSpecApplyConfiguration represents an declarative configuration of the JobSpec type for use
@ -30,8 +30,9 @@ type JobSpecApplyConfiguration struct {
Parallelism *int32 `json:"parallelism,omitempty"`
Completions *int32 `json:"completions,omitempty"`
ActiveDeadlineSeconds *int64 `json:"activeDeadlineSeconds,omitempty"`
PodFailurePolicy *PodFailurePolicyApplyConfiguration `json:"podFailurePolicy,omitempty"`
BackoffLimit *int32 `json:"backoffLimit,omitempty"`
Selector *v1.LabelSelectorApplyConfiguration `json:"selector,omitempty"`
Selector *metav1.LabelSelectorApplyConfiguration `json:"selector,omitempty"`
ManualSelector *bool `json:"manualSelector,omitempty"`
Template *corev1.PodTemplateSpecApplyConfiguration `json:"template,omitempty"`
TTLSecondsAfterFinished *int32 `json:"ttlSecondsAfterFinished,omitempty"`
@ -69,6 +70,14 @@ func (b *JobSpecApplyConfiguration) WithActiveDeadlineSeconds(value int64) *JobS
return b
}
// WithPodFailurePolicy sets the PodFailurePolicy field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the PodFailurePolicy field is set to the value of the last call.
func (b *JobSpecApplyConfiguration) WithPodFailurePolicy(value *PodFailurePolicyApplyConfiguration) *JobSpecApplyConfiguration {
b.PodFailurePolicy = value
return b
}
// WithBackoffLimit sets the BackoffLimit field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the BackoffLimit field is set to the value of the last call.
@ -80,7 +89,7 @@ func (b *JobSpecApplyConfiguration) WithBackoffLimit(value int32) *JobSpecApplyC
// WithSelector sets the Selector field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Selector field is set to the value of the last call.
func (b *JobSpecApplyConfiguration) WithSelector(value *v1.LabelSelectorApplyConfiguration) *JobSpecApplyConfiguration {
func (b *JobSpecApplyConfiguration) WithSelector(value *metav1.LabelSelectorApplyConfiguration) *JobSpecApplyConfiguration {
b.Selector = value
return b
}

View File

@ -0,0 +1,44 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1
// PodFailurePolicyApplyConfiguration represents an declarative configuration of the PodFailurePolicy type for use
// with apply.
type PodFailurePolicyApplyConfiguration struct {
Rules []PodFailurePolicyRuleApplyConfiguration `json:"rules,omitempty"`
}
// PodFailurePolicyApplyConfiguration constructs an declarative configuration of the PodFailurePolicy type for use with
// apply.
func PodFailurePolicy() *PodFailurePolicyApplyConfiguration {
return &PodFailurePolicyApplyConfiguration{}
}
// WithRules adds the given value to the Rules field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the Rules field.
func (b *PodFailurePolicyApplyConfiguration) WithRules(values ...*PodFailurePolicyRuleApplyConfiguration) *PodFailurePolicyApplyConfiguration {
for i := range values {
if values[i] == nil {
panic("nil value passed to WithRules")
}
b.Rules = append(b.Rules, *values[i])
}
return b
}

View File

@ -0,0 +1,63 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1
import (
v1 "k8s.io/api/batch/v1"
)
// PodFailurePolicyOnExitCodesRequirementApplyConfiguration represents an declarative configuration of the PodFailurePolicyOnExitCodesRequirement type for use
// with apply.
type PodFailurePolicyOnExitCodesRequirementApplyConfiguration struct {
ContainerName *string `json:"containerName,omitempty"`
Operator *v1.PodFailurePolicyOnExitCodesOperator `json:"operator,omitempty"`
Values []int32 `json:"values,omitempty"`
}
// PodFailurePolicyOnExitCodesRequirementApplyConfiguration constructs an declarative configuration of the PodFailurePolicyOnExitCodesRequirement type for use with
// apply.
func PodFailurePolicyOnExitCodesRequirement() *PodFailurePolicyOnExitCodesRequirementApplyConfiguration {
return &PodFailurePolicyOnExitCodesRequirementApplyConfiguration{}
}
// WithContainerName sets the ContainerName field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the ContainerName field is set to the value of the last call.
func (b *PodFailurePolicyOnExitCodesRequirementApplyConfiguration) WithContainerName(value string) *PodFailurePolicyOnExitCodesRequirementApplyConfiguration {
b.ContainerName = &value
return b
}
// WithOperator sets the Operator field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Operator field is set to the value of the last call.
func (b *PodFailurePolicyOnExitCodesRequirementApplyConfiguration) WithOperator(value v1.PodFailurePolicyOnExitCodesOperator) *PodFailurePolicyOnExitCodesRequirementApplyConfiguration {
b.Operator = &value
return b
}
// WithValues adds the given value to the Values field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the Values field.
func (b *PodFailurePolicyOnExitCodesRequirementApplyConfiguration) WithValues(values ...int32) *PodFailurePolicyOnExitCodesRequirementApplyConfiguration {
for i := range values {
b.Values = append(b.Values, values[i])
}
return b
}

View File

@ -0,0 +1,52 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1
import (
v1 "k8s.io/api/core/v1"
)
// PodFailurePolicyOnPodConditionsPatternApplyConfiguration represents an declarative configuration of the PodFailurePolicyOnPodConditionsPattern type for use
// with apply.
type PodFailurePolicyOnPodConditionsPatternApplyConfiguration struct {
Type *v1.PodConditionType `json:"type,omitempty"`
Status *v1.ConditionStatus `json:"status,omitempty"`
}
// PodFailurePolicyOnPodConditionsPatternApplyConfiguration constructs an declarative configuration of the PodFailurePolicyOnPodConditionsPattern type for use with
// apply.
func PodFailurePolicyOnPodConditionsPattern() *PodFailurePolicyOnPodConditionsPatternApplyConfiguration {
return &PodFailurePolicyOnPodConditionsPatternApplyConfiguration{}
}
// WithType sets the Type field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Type field is set to the value of the last call.
func (b *PodFailurePolicyOnPodConditionsPatternApplyConfiguration) WithType(value v1.PodConditionType) *PodFailurePolicyOnPodConditionsPatternApplyConfiguration {
b.Type = &value
return b
}
// WithStatus sets the Status field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Status field is set to the value of the last call.
func (b *PodFailurePolicyOnPodConditionsPatternApplyConfiguration) WithStatus(value v1.ConditionStatus) *PodFailurePolicyOnPodConditionsPatternApplyConfiguration {
b.Status = &value
return b
}

View File

@ -0,0 +1,66 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1
import (
v1 "k8s.io/api/batch/v1"
)
// PodFailurePolicyRuleApplyConfiguration represents an declarative configuration of the PodFailurePolicyRule type for use
// with apply.
type PodFailurePolicyRuleApplyConfiguration struct {
Action *v1.PodFailurePolicyAction `json:"action,omitempty"`
OnExitCodes *PodFailurePolicyOnExitCodesRequirementApplyConfiguration `json:"onExitCodes,omitempty"`
OnPodConditions []PodFailurePolicyOnPodConditionsPatternApplyConfiguration `json:"onPodConditions,omitempty"`
}
// PodFailurePolicyRuleApplyConfiguration constructs an declarative configuration of the PodFailurePolicyRule type for use with
// apply.
func PodFailurePolicyRule() *PodFailurePolicyRuleApplyConfiguration {
return &PodFailurePolicyRuleApplyConfiguration{}
}
// WithAction sets the Action field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Action field is set to the value of the last call.
func (b *PodFailurePolicyRuleApplyConfiguration) WithAction(value v1.PodFailurePolicyAction) *PodFailurePolicyRuleApplyConfiguration {
b.Action = &value
return b
}
// WithOnExitCodes sets the OnExitCodes field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the OnExitCodes field is set to the value of the last call.
func (b *PodFailurePolicyRuleApplyConfiguration) WithOnExitCodes(value *PodFailurePolicyOnExitCodesRequirementApplyConfiguration) *PodFailurePolicyRuleApplyConfiguration {
b.OnExitCodes = value
return b
}
// WithOnPodConditions adds the given value to the OnPodConditions field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the OnPodConditions field.
func (b *PodFailurePolicyRuleApplyConfiguration) WithOnPodConditions(values ...*PodFailurePolicyOnPodConditionsPatternApplyConfiguration) *PodFailurePolicyRuleApplyConfiguration {
for i := range values {
if values[i] == nil {
panic("nil value passed to WithOnPodConditions")
}
b.OnPodConditions = append(b.OnPodConditions, *values[i])
}
return b
}

View File

@ -3041,6 +3041,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: parallelism
type:
scalar: numeric
- name: podFailurePolicy
type:
namedType: io.k8s.api.batch.v1.PodFailurePolicy
- name: selector
type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector
@ -3098,6 +3101,58 @@ var schemaYAML = typed.YAMLObject(`types:
type:
namedType: io.k8s.api.batch.v1.JobSpec
default: {}
- name: io.k8s.api.batch.v1.PodFailurePolicy
map:
fields:
- name: rules
type:
list:
elementType:
namedType: io.k8s.api.batch.v1.PodFailurePolicyRule
elementRelationship: atomic
- name: io.k8s.api.batch.v1.PodFailurePolicyOnExitCodesRequirement
map:
fields:
- name: containerName
type:
scalar: string
- name: operator
type:
scalar: string
default: ""
- name: values
type:
list:
elementType:
scalar: numeric
elementRelationship: associative
- name: io.k8s.api.batch.v1.PodFailurePolicyOnPodConditionsPattern
map:
fields:
- name: status
type:
scalar: string
default: ""
- name: type
type:
scalar: string
default: ""
- name: io.k8s.api.batch.v1.PodFailurePolicyRule
map:
fields:
- name: action
type:
scalar: string
default: ""
- name: onExitCodes
type:
namedType: io.k8s.api.batch.v1.PodFailurePolicyOnExitCodesRequirement
- name: onPodConditions
type:
list:
elementType:
namedType: io.k8s.api.batch.v1.PodFailurePolicyOnPodConditionsPattern
elementRelationship: atomic
- name: io.k8s.api.batch.v1.UncountedTerminatedPods
map:
fields:

View File

@ -447,6 +447,14 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
return &applyconfigurationsbatchv1.JobStatusApplyConfiguration{}
case batchv1.SchemeGroupVersion.WithKind("JobTemplateSpec"):
return &applyconfigurationsbatchv1.JobTemplateSpecApplyConfiguration{}
case batchv1.SchemeGroupVersion.WithKind("PodFailurePolicy"):
return &applyconfigurationsbatchv1.PodFailurePolicyApplyConfiguration{}
case batchv1.SchemeGroupVersion.WithKind("PodFailurePolicyOnExitCodesRequirement"):
return &applyconfigurationsbatchv1.PodFailurePolicyOnExitCodesRequirementApplyConfiguration{}
case batchv1.SchemeGroupVersion.WithKind("PodFailurePolicyOnPodConditionsPattern"):
return &applyconfigurationsbatchv1.PodFailurePolicyOnPodConditionsPatternApplyConfiguration{}
case batchv1.SchemeGroupVersion.WithKind("PodFailurePolicyRule"):
return &applyconfigurationsbatchv1.PodFailurePolicyRuleApplyConfiguration{}
case batchv1.SchemeGroupVersion.WithKind("UncountedTerminatedPods"):
return &applyconfigurationsbatchv1.UncountedTerminatedPodsApplyConfiguration{}

8
go.mod
View File

@ -24,8 +24,8 @@ require (
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8
google.golang.org/protobuf v1.28.0
k8s.io/api v0.0.0-20220804201334-3be517c25d08
k8s.io/apimachinery v0.0.0-20220804201133-74deb3dbf6fd
k8s.io/api v0.0.0-20220805002038-2f9e58849198
k8s.io/apimachinery v0.0.0-20220805001719-117bd9b56ec3
k8s.io/klog/v2 v2.70.1
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
@ -61,6 +61,6 @@ require (
)
replace (
k8s.io/api => k8s.io/api v0.0.0-20220804201334-3be517c25d08
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20220804201133-74deb3dbf6fd
k8s.io/api => k8s.io/api v0.0.0-20220805002038-2f9e58849198
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20220805001719-117bd9b56ec3
)

8
go.sum
View File

@ -477,10 +477,10 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
k8s.io/api v0.0.0-20220804201334-3be517c25d08 h1:GhSb7UiWlJLG12FUUz3PwSpT2FVZCbYtls4p4+3HSeQ=
k8s.io/api v0.0.0-20220804201334-3be517c25d08/go.mod h1:a3GfmLd04jiJgn/o0eLXPVt1neCVuUVj/RJzEEWOMJU=
k8s.io/apimachinery v0.0.0-20220804201133-74deb3dbf6fd h1:bTjsTSrHSYBuovT0kZTwfLlTGHzHL9POhWK2ci83fOg=
k8s.io/apimachinery v0.0.0-20220804201133-74deb3dbf6fd/go.mod h1:qMx9eAk0sZQGsXGu86fab8tZdffHbwUfsvzqKn4mfB0=
k8s.io/api v0.0.0-20220805002038-2f9e58849198 h1:1ErZhmgMp8WahOuZc3BklvUPRJLVL5QOy+2CdAwCnqk=
k8s.io/api v0.0.0-20220805002038-2f9e58849198/go.mod h1:cuE2+aKfcxEMeHx/NuUKIL3aRJhth7/K9wlCf+3Q3+s=
k8s.io/apimachinery v0.0.0-20220805001719-117bd9b56ec3 h1:Ru2oqar5qMV68dM0G6OEZs2C7qtydpReZ2dHsXpu/Kw=
k8s.io/apimachinery v0.0.0-20220805001719-117bd9b56ec3/go.mod h1:qMx9eAk0sZQGsXGu86fab8tZdffHbwUfsvzqKn4mfB0=
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
k8s.io/klog/v2 v2.70.1 h1:7aaoSdahviPmR+XkS7FyxlkkXs6tHISSG03RxleQAVQ=
k8s.io/klog/v2 v2.70.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=