Skip to content
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

Add Indexed completionMode to Job API #98441

Merged
merged 1 commit into from Mar 3, 2021

Conversation

alculquicondor
Copy link
Member

@alculquicondor alculquicondor commented Jan 26, 2021

What type of PR is this?

/kind feature
/kind api-change

/sig apps
/area workload-api/job
/area batch

What this PR does / why we need it:

Add the .spec.completionMode field with accepted values NonIndexed (default) and Indexed.

Also requires a feature gate IndexedJob and the .status.completedIndexes field in Job.

Which issue(s) this PR fixes:

Ref #97169 #14188 kubernetes/enhancements#2214

Special notes for your reviewer:

This PR only contains API changes. Changes to Job controller will follow up in another PR.

Does this PR introduce a user-facing change?:

Added `.spec.completionMode` field to Job, with accepted values `NonIndexed` (default) and `Indexed`. This is an alpha field and is only honored by servers with the `IndexedJob` feature gate enabled.

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

- [KEP]: http://git.k8s.io/enhancements/keps/sig-apps/2214-indexed-job
- [Usage]: TODO

@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/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/apps Categorizes an issue or PR as relevant to SIG Apps. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/workload-api/job area/batch needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubectl sig/cli Categorizes an issue or PR as relevant to SIG CLI. labels Jan 26, 2021
@alculquicondor
Copy link
Member Author

/hold
for kubernetes/enhancements#2245 to be merged

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 26, 2021
@alculquicondor
Copy link
Member Author

/retest

@alculquicondor
Copy link
Member Author

/assign @soltysh
for sig-apps review

@alculquicondor
Copy link
Member Author

Keeping the hold until implementation PR (TODO) is also approved

@alculquicondor
Copy link
Member Author

cc @ahg-g

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 30, 2021
@alculquicondor alculquicondor force-pushed the array-job-api branch 2 times, most recently from 447128f to 0ee7ce4 Compare February 1, 2021 21:41
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 1, 2021
// CompletionMode specifies how Pod completions of a Job are tracked.
type CompletionMode string

const (
Copy link
Member

Choose a reason for hiding this comment

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

Interesting that the comment describes completion from the pod perspective. Since the mode is a job level parameter, it might be clearer if we describe it from the job perspective?

Copy link
Member Author

Choose a reason for hiding this comment

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

Any suggested wording?

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps:

NonIndexedMode: a job is completed when the number of successfully completed pods is equal to Completions, if completions is nil, then the success of any pod signals the success of the job.

IndexedMode: a job is completed when at least one pod for each unique index between 0 to Completions - 1 successfully completed.

When we start describing the mode from the perspective of the job, I think it becomes more important to document the restrictions on Completions/Parallelism values here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sadly, comments for constants don't make it to the reference documentation https://kubernetes.io/docs/reference/kubernetes-api/

So leaving the comments here lean and putting all details in the field.

Copy link
Member

Choose a reason for hiding this comment

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

oh, that is bad!

NonIndexedCompletion CompletionMode = "NonIndexed"

// IndexedCompletion means that each Pod completion of a Job is tracked
// individually, being associated to a completion index.
Copy link
Member

Choose a reason for hiding this comment

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

are there restrictions on what values Parallelism and Completions can take when using this mode?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but I'm keeping them in the field, as that's where people will take a look first.

Copy link
Member

Choose a reason for hiding this comment

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

may be not in this case, but a field can exist in multiple places, and so we wouldn't repeat the description of each value on each field. The documentation is for the type, not really for the field.

// more consecutive numbers are compressed and represented by the first and
// last element of the series, separated by a hyphen.
// For example, if the completed indexes are 1, 3, 4, 5 and 7, they are
// represented as "1,3-5,7".
Copy link
Member

Choose a reason for hiding this comment

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

mention the limit on this field if there is one.

Copy link
Member Author

Choose a reason for hiding this comment

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

There is no limit here. It's just bounded by parallelism.

//
// This field is alpha-level and is only honored by servers that enable the
// IndexedJob feature gate. More completion modes can be added in the future.
// If the Job controller observes a mode that it doesn't recognize, it manages
Copy link
Member

Choose a reason for hiding this comment

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

why not reject it at validation?

Copy link
Member Author

Choose a reason for hiding this comment

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

We do reject it at validation. But an apiserver can temporarily be at a newer version than the controller. Then the controller might see a mode that it doesn't recognize.

This note is a safeguard to allow the addition of new modes in the future. In production clusters, the situation described wouldn't happen, as we first release new modes with a disabled feture gate.

But actually, it's safer to skip the sync. Changing.

@@ -31,6 +31,8 @@ import (
apivalidation "k8s.io/kubernetes/pkg/apis/core/validation"
)

const maxParallelismForIndexedJob = 100000
Copy link
Member

Choose a reason for hiding this comment

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

add a comment explaining why parallelism is now capped.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@ahg-g
Copy link
Member

ahg-g commented Feb 5, 2021

looks good to me

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 19, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 19, 2021
@alculquicondor
Copy link
Member Author

/retest

@alculquicondor
Copy link
Member Author

/retest

@ahg-g
Copy link
Member

ahg-g commented Mar 2, 2021

/retest

1 similar comment
@ahg-g
Copy link
Member

ahg-g commented Mar 2, 2021

/retest

@lavalamp
Copy link
Member

lavalamp commented Mar 2, 2021

/approve
for pkg/registry

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor, erictune, lavalamp, soltysh

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 Mar 2, 2021
@ahg-g
Copy link
Member

ahg-g commented Mar 3, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 3, 2021
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@ahg-g
Copy link
Member

ahg-g commented Mar 3, 2021

/retest

1 similar comment
@ahg-g
Copy link
Member

ahg-g commented Mar 3, 2021

/retest

And IndexedJob feature gate, disabled by default.
Update JobDescriber
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 3, 2021
@alculquicondor
Copy link
Member Author

/retest

@ahg-g
Copy link
Member

ahg-g commented Mar 3, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 3, 2021
@k8s-ci-robot k8s-ci-robot merged commit 6059a67 into kubernetes:master Mar 3, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Mar 3, 2021
@liggitt liggitt moved this from Assigned to API review completed, 1.21 in API Reviews Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review Categorizes an issue or PR as actively needing an API review. approved Indicates a PR has been approved by an approver from all required OWNERS files. area/batch area/kubectl area/workload-api/job cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/backlog Higher priority than priority/awaiting-more-evidence. 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/cli Categorizes an issue or PR as relevant to SIG CLI. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Status: API review completed, 1.21
Development

Successfully merging this pull request may close these issues.

None yet

7 participants