Skip to content

Fix validation for Job with suspend=true,completions=0 to set Complete condition #132614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 1, 2025

Conversation

mimowo
Copy link
Contributor

@mimowo mimowo commented Jun 30, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:

Which issue(s) this PR is related to:

Fixes #132144

Special notes for your reviewer:

There is an alternative solution, as proposed in #132144 (comment).

I'm ok with both approaches, but with the relaxed validation the fix is smaller in scope as it only tweaks the validation introduced in the ManagedBy feature without setting StartTime.

Does this PR introduce a user-facing change?

Fix validation for Job with suspend=true, and completions=0 to set the Complete condition.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

https://github.com/kubernetes/enhancements/tree/master/keps/sig-apps/4368-support-managed-by-for-batch-jobs

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 30, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/test sig/apps Categorizes an issue or PR as relevant to SIG Apps. labels Jun 30, 2025
@k8s-ci-robot k8s-ci-robot added the sig/testing Categorizes an issue or PR as relevant to SIG Testing. label Jun 30, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in SIG Apps Jun 30, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Jun 30, 2025
@mimowo
Copy link
Contributor Author

mimowo commented Jun 30, 2025

/sig apps

@mimowo
Copy link
Contributor Author

mimowo commented Jun 30, 2025

cc @tenzen-y @atiratree ptal

@tenzen-y
Copy link
Member

cc @tenzen-y @atiratree ptal

ACK

Copy link
Member

@tenzen-y tenzen-y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, LGTM
Thank you.

Comment on lines 2905 to 2907
// TestSuspendedJobWithZeroCompletions verifies the suspended Job with
// completions=0 is marked as Complete.
func TestSuspendedJobWithZeroCompletions(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this dedicated one, shouldn't we generalize TestSuspend and add a new case to that?

func TestSuspendJob(t *testing.T) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but it seems the pre-existing test was written with the purpose of checking how the Suspend condition changes when we update the Job, which makes it non-trivial.

Also note we have pre-existing TestSuspendJobControllerRestart. My new test seems easier to consolidate with this one. For now, I align the name of the new test to use the same prefix as the preexisting tests TestSuspendJob.

Ultimately, I see all three tests should be consolidated. Since we already have 2 different tests, I suggest adding a new one, and opening an issue to consolidate them all, wdyt? Otherwise I would probably prefer to consolidate with TestSuspendJobControllerRestart as it is less effort.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Let us work on a follow-up PR / issue.
I raised the issue: #132621

Copy link
Member

@tenzen-y tenzen-y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
/lgtm
as Job controller reviewer.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 30, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 38d14c70bff8630eb7af09d18002de4bf6e975d7

@mimowo
Copy link
Contributor Author

mimowo commented Jun 30, 2025

@tenzen-y
Copy link
Member

tenzen-y commented Jul 1, 2025

/assign @deads2k
for strategy directory.

@mimowo
Copy link
Contributor Author

mimowo commented Jul 1, 2025

@tenzen-y @atiratree @deads2k this is an edge case, but OTOH it is a regression, and the issue was opened by an end-user, see also comment.

Would you be supportive for cherry-picking to 1.32 and 1.33? If so I'm happy to prepare the PRs .

@tenzen-y
Copy link
Member

tenzen-y commented Jul 1, 2025

@tenzen-y @atiratree @deads2k this is an edge case, but OTOH it is a regression, and the issue was opened by an end-user, see also comment.

Would you be supportive for cherry-picking to 1.32 and 1.33? If so I'm happy to prepare the PRs .

IIUC, since v1.32, this Job behavior were broken user PoV. So, cherry-picking this to 1.32 and 1.33 sounds reasonable.
The discussion point is whether or not we should consider this corner case as a breaking specification change.

If a suspended Job with completions=0 is not intended for the specifications and this should be restricted in the previous k8s version (until v1.31), we can consider this PR as a feature since this PR tries to explicitly allow them to deploy suspended Job with completions=0..

@mimowo
Copy link
Contributor Author

mimowo commented Jul 1, 2025

If a suspended Job with completions=0 is not intended for the specifications and this should be restricted in the previous k8s version (until v1.31), we can consider this PR as a feature since this PR tries to explicitly allow them to deploy suspended Job with completions=0..

I'm not clear I understand this. Strengthening validation was discussed under the issue, I think the documentation is not clarifying it, but suspend=true and competitions=0 was supported for many releases prior to 1.32, so I think it makes sense to call it a bug/regression and continue supporting.

Now, if we decide this configuration should not be supported (strengthening validation), then it is different PR to prepare.

@deads2k
Copy link
Contributor

deads2k commented Jul 1, 2025

This is a bug and eligible for backport. The unit test looks correct, but have the reporter confirm the fix works prior to backporting.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, mimowo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 1, 2025
@k8s-ci-robot k8s-ci-robot merged commit d3296ea into kubernetes:master Jul 1, 2025
11 of 13 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.34 milestone Jul 1, 2025
@github-project-automation github-project-automation bot moved this from Needs Triage to Done in SIG Apps Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Job status.conditions behavior change 1.31 -> 1.32
4 participants