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

[KEP-3521] Part 1: New Pod API .spec.schedulingGates #113274

Merged
merged 2 commits into from Nov 4, 2022

Conversation

Huang-Wei
Copy link
Member

@Huang-Wei Huang-Wei commented Oct 22, 2022

What type of PR is this?

/kind feature
/sig scheduling

What this PR does / why we need it:

This is the first part of implementing KEP 3521, including:

  • Pod API definition, feature gate, codegen, validation, and drop disabled fields
  • disallow binding a Pod carrying non-nil schedulingGates
  • disallow creating a Pod with non-nil nodeName and non-nil schedulingGates
  • if needed, adds a {type:PodScheduled, reason:SchedulingGated} condition upon pod creation
  • new literal SchedulingGated in the STATUS column of k get pod

Which issue(s) this PR fixes:

Part of #113269

Special notes for your reviewer:

Get best review UX commit by commit.

Does this PR introduce a user-facing change?

New Pod API field `.spec.schedulingGates` is introduced to enable users to control when to mark a Pod as scheduling ready.

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

- [KEP]: https://github.com/kubernetes/enhancements/tree/master/keps/sig-scheduling/3521-pod-scheduling-readiness

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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/code-generation kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. labels Oct 22, 2022
@k8s-triage-robot
Copy link

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

@Huang-Wei Huang-Wei force-pushed the kep-3521-A branch 2 times, most recently from f3b90e4 to d14305f Compare October 22, 2022 05:22
@k8s-ci-robot k8s-ci-robot added area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Oct 22, 2022
@Huang-Wei
Copy link
Member Author

cc @ahg-g

There are 2 PRs upcoming: scheduler implementation and integration/e2e tests.

pkg/apis/core/types.go Outdated Show resolved Hide resolved
pkg/apis/core/types.go Outdated Show resolved Hide resolved
@@ -3017,6 +3030,13 @@ type PodOS struct {
Name OSName
}

// PodSchedulingGate is associated to a Pod to guard its scheduling.
type PodSchedulingGate struct {
Copy link
Member

Choose a reason for hiding this comment

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

do we need a struct?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I asked for it for future proofing.

pkg/apis/core/validation/validation.go Outdated Show resolved Hide resolved
pkg/apis/core/validation/validation.go Outdated Show resolved Hide resolved
pkg/registry/core/pod/strategy.go Outdated Show resolved Hide resolved
pkg/registry/core/pod/strategy.go Outdated Show resolved Hide resolved
@@ -81,6 +81,9 @@ const (

// nodeLabelRole specifies the role of a node
nodeLabelRole = "kubernetes.io/role"

// schedulingPaused indicates a Pod is gated by one or more scheduling readiness gates.
Copy link
Member

Choose a reason for hiding this comment

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

I would use blocked instead of pause.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree. Or SchedulingGated (it should be rare enough that calling it gated will help people find the field.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to schedulingGated which is more close to the new field name.

// If the Pod carries {type:PodScheduled, reason:WaitingForGates}, set reason to SchedulingPaused.
for _, condition := range pod.Status.Conditions {
if condition.Type == api.PodScheduled && condition.Reason == api.PodReasonWaitingForGates {
reason = schedulingPaused
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 use the same reason?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's b/c this "reason" is used in the output of k get pod, and thusPodReasonWaitingForGates which holds the literal "WaitingForGates" loses the context - a word describing that it's scheduling gated would be more self-descriptive.

@ahg-g
Copy link
Member

ahg-g commented Oct 27, 2022

/assign @smarterclayton

@ahg-g
Copy link
Member

ahg-g commented Oct 27, 2022

/label api-review

@k8s-ci-robot k8s-ci-robot added the api-review Categorizes an issue or PR as actively needing an API review. label Oct 27, 2022
@@ -221,6 +223,10 @@ func (r *BindingREST) setPodHostAndAnnotations(ctx context.Context, podUID types
if pod.Spec.NodeName != "" {
return nil, fmt.Errorf("pod %v is already assigned to node %q", pod.Name, pod.Spec.NodeName)
}
// Reject binding to a scheduling un-ready Pod.
if utilfeature.DefaultFeatureGate.Enabled(features.PodSchedulingReadiness) && len(pod.Spec.SchedulingGates) != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should really be in validation - a regular user can patch a pod and set spec.nodeName without binding.

Copy link
Member Author

Choose a reason for hiding this comment

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

ah, update's validation has already been covered. Here it's an additional validation for pod creation - prevent user creating a pod directly with nodeName and non-empty scheduling gates.

Copy link
Member

@kerthcet kerthcet Oct 31, 2022

Choose a reason for hiding this comment

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

But here pod.Spec.NodeName won't be empty, we returned in the above. I think we should move this ahead.

Copy link
Member Author

Choose a reason for hiding this comment

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

not quite. L223~L225 is checking whether it's updating nodeName X to Y.

Copy link
Member

Choose a reason for hiding this comment

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

prevent user creating a pod directly with nodeName and non-empty scheduling gates

I see, misunderstood the words here. Great catch.

@Huang-Wei
Copy link
Member Author

If you can change the validation string i'll approve - everything else can be improved before beta.

Thanks. Tracked in #113608

@k8s-ci-robot k8s-ci-robot added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Nov 3, 2022
@smarterclayton
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Huang-Wei, smarterclayton

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 Nov 3, 2022
- New API field .spec.schedulingGates
- Validation and drop disabled fields
- Disallow binding a Pod carrying non-nil schedulingGates
- Disallow creating a Pod with non-nil nodeName and non-nil schedulingGates
- Adds a {type:PodScheduled, reason:WaitingForGates} condition if necessary
- New literal SchedulingGated in the STATUS column of `k get pod`
@ahg-g
Copy link
Member

ahg-g commented Nov 3, 2022

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 3, 2022
@Huang-Wei
Copy link
Member Author

/hold
for CI.

@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 Nov 3, 2022
@Huang-Wei
Copy link
Member Author

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 4, 2022
@ahg-g
Copy link
Member

ahg-g commented Nov 4, 2022

/hold cancel

@k8s-ci-robot k8s-ci-robot merged commit 8c77820 into kubernetes:master Nov 4, 2022
@Huang-Wei Huang-Wei deleted the kep-3521-A branch November 4, 2022 05:06
@soltysh
Copy link
Contributor

soltysh commented Nov 4, 2022

@soltysh would you (or delegate to someone) please review the CLI changes? In particular, the status volume of k get pod will output "SchedulingGated" if the pod carries non-empty .spec.schedulingGates.

A bit late to the game, but this looks great - thx!

@fedebongio
Copy link
Contributor

/remove-sig api-machinery

@k8s-ci-robot k8s-ci-robot removed the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Nov 8, 2022
@fedebongio
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 8, 2022
@brandond
Copy link

@Huang-Wei @smarterclayton there is a typo the PR comment that made it into the CHANGELOG.

From the user-facing change section (that is scraped by the changelog generator), .spec.scheudlingGates should be .spec.schedulingGates

@Huang-Wei
Copy link
Member Author

@brandond thanks for the catch.. Rasied a PR fixing the typos: #113843

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/code-generation area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/test 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. needs-priority Indicates a PR lacks a `priority/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/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/testing Categorizes an issue or PR as relevant to SIG Testing. 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.26
Development

Successfully merging this pull request may close these issues.

None yet

10 participants