Skip to content

Commit 51f76fe

Browse files
authored
Merge pull request kubernetes#127402 from mimowo/managed-by-beta-update
Graduate JobManagedBy to Beta in 1.32
2 parents c5a85ab + ec983bd commit 51f76fe

File tree

12 files changed

+145
-10
lines changed

12 files changed

+145
-10
lines changed

api/openapi-spec/swagger.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/openapi-spec/v3/apis__batch__v1_openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@
345345
"type": "integer"
346346
},
347347
"managedBy": {
348-
"description": "ManagedBy field indicates the controller that manages a Job. The k8s Job controller reconciles jobs which don't have this field at all or the field value is the reserved string `kubernetes.io/job-controller`, but skips reconciling Jobs with a custom value for this field. The value must be a valid domain-prefixed path (e.g. acme.io/foo) - all characters before the first \"/\" must be a valid subdomain as defined by RFC 1123. All characters trailing the first \"/\" must be valid HTTP Path characters as defined by RFC 3986. The value cannot exceed 63 characters. This field is immutable.\n\nThis field is alpha-level. The job controller accepts setting the field when the feature gate JobManagedBy is enabled (disabled by default).",
348+
"description": "ManagedBy field indicates the controller that manages a Job. The k8s Job controller reconciles jobs which don't have this field at all or the field value is the reserved string `kubernetes.io/job-controller`, but skips reconciling Jobs with a custom value for this field. The value must be a valid domain-prefixed path (e.g. acme.io/foo) - all characters before the first \"/\" must be a valid subdomain as defined by RFC 1123. All characters trailing the first \"/\" must be valid HTTP Path characters as defined by RFC 3986. The value cannot exceed 63 characters. This field is immutable.\n\nThis field is beta-level. The job controller accepts setting the field when the feature gate JobManagedBy is enabled (enabled by default).",
349349
"type": "string"
350350
},
351351
"manualSelector": {

pkg/apis/batch/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,8 @@ type JobSpec struct {
477477
// characters as defined by RFC 3986. The value cannot exceed 63 characters.
478478
// This field is immutable.
479479
//
480-
// This field is alpha-level. The job controller accepts setting the field
481-
// when the feature gate JobManagedBy is enabled (disabled by default).
480+
// This field is beta-level. The job controller accepts setting the field
481+
// when the feature gate JobManagedBy is enabled (enabled by default).
482482
// +optional
483483
ManagedBy *string
484484
}

pkg/controller/job/job_controller_test.go

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3087,6 +3087,7 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
30873087

30883088
testCases := map[string]struct {
30893089
enableJobPodReplacementPolicy bool
3090+
enableJobManagedBy bool
30903091
job batch.Job
30913092
pods []v1.Pod
30923093
wantConditions []batch.JobCondition
@@ -3420,6 +3421,56 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
34203421
wantStatusFailed: 2,
34213422
wantStatusSucceeded: 0,
34223423
},
3424+
"fail job with multiple pods; JobManagedBy enabled delays setting terminal condition": {
3425+
enableJobManagedBy: true,
3426+
job: batch.Job{
3427+
TypeMeta: metav1.TypeMeta{Kind: "Job"},
3428+
ObjectMeta: validObjectMeta,
3429+
Spec: batch.JobSpec{
3430+
Selector: validSelector,
3431+
Template: validTemplate,
3432+
Parallelism: ptr.To[int32](2),
3433+
Completions: ptr.To[int32](2),
3434+
BackoffLimit: ptr.To[int32](6),
3435+
PodFailurePolicy: &batch.PodFailurePolicy{
3436+
Rules: onExitCodeRules,
3437+
},
3438+
},
3439+
},
3440+
pods: []v1.Pod{
3441+
{
3442+
Status: v1.PodStatus{
3443+
Phase: v1.PodRunning,
3444+
},
3445+
},
3446+
{
3447+
Status: v1.PodStatus{
3448+
Phase: v1.PodFailed,
3449+
ContainerStatuses: []v1.ContainerStatus{
3450+
{
3451+
Name: "main-container",
3452+
State: v1.ContainerState{
3453+
Terminated: &v1.ContainerStateTerminated{
3454+
ExitCode: 5,
3455+
},
3456+
},
3457+
},
3458+
},
3459+
},
3460+
},
3461+
},
3462+
wantConditions: []batch.JobCondition{
3463+
{
3464+
Type: batch.JobFailureTarget,
3465+
Status: v1.ConditionTrue,
3466+
Reason: batch.JobReasonPodFailurePolicy,
3467+
Message: "Container main-container for pod default/mypod-1 failed with exit code 5 matching FailJob rule at index 1",
3468+
},
3469+
},
3470+
wantStatusActive: 0,
3471+
wantStatusFailed: 2,
3472+
wantStatusSucceeded: 0,
3473+
},
34233474
"fail indexed job based on OnExitCodes": {
34243475
job: batch.Job{
34253476
TypeMeta: metav1.TypeMeta{Kind: "Job"},
@@ -3759,6 +3810,56 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
37593810
wantStatusFailed: 1,
37603811
wantStatusSucceeded: 0,
37613812
},
3813+
"default job based on OnExitCodes; JobManagedBy enabled triggers adding interim condition": {
3814+
enableJobManagedBy: true,
3815+
job: batch.Job{
3816+
TypeMeta: metav1.TypeMeta{Kind: "Job"},
3817+
ObjectMeta: validObjectMeta,
3818+
Spec: batch.JobSpec{
3819+
Selector: validSelector,
3820+
Template: validTemplate,
3821+
Parallelism: ptr.To[int32](1),
3822+
Completions: ptr.To[int32](1),
3823+
BackoffLimit: ptr.To[int32](0),
3824+
PodFailurePolicy: &batch.PodFailurePolicy{
3825+
Rules: onExitCodeRules,
3826+
},
3827+
},
3828+
},
3829+
pods: []v1.Pod{
3830+
{
3831+
Status: v1.PodStatus{
3832+
Phase: v1.PodFailed,
3833+
ContainerStatuses: []v1.ContainerStatus{
3834+
{
3835+
State: v1.ContainerState{
3836+
Terminated: &v1.ContainerStateTerminated{
3837+
ExitCode: 10,
3838+
},
3839+
},
3840+
},
3841+
},
3842+
},
3843+
},
3844+
},
3845+
wantConditions: []batch.JobCondition{
3846+
{
3847+
Type: batch.JobFailureTarget,
3848+
Status: v1.ConditionTrue,
3849+
Reason: batch.JobReasonBackoffLimitExceeded,
3850+
Message: "Job has reached the specified backoff limit",
3851+
},
3852+
{
3853+
Type: batch.JobFailed,
3854+
Status: v1.ConditionTrue,
3855+
Reason: batch.JobReasonBackoffLimitExceeded,
3856+
Message: "Job has reached the specified backoff limit",
3857+
},
3858+
},
3859+
wantStatusActive: 0,
3860+
wantStatusFailed: 1,
3861+
wantStatusSucceeded: 0,
3862+
},
37623863
"count pod failure based on OnExitCodes; both rules are matching, the first is executed only": {
37633864
job: batch.Job{
37643865
TypeMeta: metav1.TypeMeta{Kind: "Job"},
@@ -4057,6 +4158,7 @@ func TestSyncJobWithJobPodFailurePolicy(t *testing.T) {
40574158
for name, tc := range testCases {
40584159
t.Run(name, func(t *testing.T) {
40594160
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodReplacementPolicy, tc.enableJobPodReplacementPolicy)
4161+
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobManagedBy, tc.enableJobManagedBy)
40604162

40614163
if tc.job.Spec.PodReplacementPolicy == nil {
40624164
tc.job.Spec.PodReplacementPolicy = podReplacementPolicy(batch.Failed)

pkg/features/kube_features.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ const (
264264

265265
// owner: @mimowo
266266
// kep: https://kep.k8s.io/4368
267+
// alpha: v1.30
268+
// beta: v1.32
267269
//
268270
// Allows to delegate reconciliation of a Job object to an external controller.
269271
JobManagedBy featuregate.Feature = "JobManagedBy"

pkg/features/versioned_kube_features.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
392392

393393
JobManagedBy: {
394394
{Version: version.MustParse("1.30"), Default: false, PreRelease: featuregate.Alpha},
395+
{Version: version.MustParse("1.32"), Default: true, PreRelease: featuregate.Beta},
395396
},
396397

397398
JobPodFailurePolicy: {

pkg/generated/openapi/zz_generated.openapi.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/api/batch/v1/generated.proto

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/api/batch/v1/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,8 @@ type JobSpec struct {
480480
// characters as defined by RFC 3986. The value cannot exceed 63 characters.
481481
// This field is immutable.
482482
//
483-
// This field is alpha-level. The job controller accepts setting the field
484-
// when the feature gate JobManagedBy is enabled (disabled by default).
483+
// This field is beta-level. The job controller accepts setting the field
484+
// when the feature gate JobManagedBy is enabled (enabled by default).
485485
// +optional
486486
ManagedBy *string `json:"managedBy,omitempty" protobuf:"bytes,15,opt,name=managedBy"`
487487
}

staging/src/k8s.io/api/batch/v1/types_swagger_doc_generated.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)