Skip to content

Create Workload API v1alpha2#136976

Merged
k8s-ci-robot merged 5 commits intokubernetes:masterfrom
tosi3k:was-alpha-v2
Mar 10, 2026
Merged

Create Workload API v1alpha2#136976
k8s-ci-robot merged 5 commits intokubernetes:masterfrom
tosi3k:was-alpha-v2

Conversation

@tosi3k
Copy link
Copy Markdown
Member

@tosi3k tosi3k commented Feb 12, 2026

What type of PR is this?

/kind feature
/kind api-change

What this PR does / why we need it:

This PR creates v1alpha2 version of the Workload API (and, at the same time, deletes the old version of that API, v1alpha1) and introduces a brand new v1alpha2 PodGroup API. It also replaces WorkloadRef field in the Pod API with the SchedulingGroup field that refers to the new PodGroup API.

This is basically a lion share of the work related to decoupling the PodGroups from Workloads as a separate API which is described in KEP: kubernetes/enhancements#5832.

Which issue(s) this PR is related to:

KEP: kubernetes/enhancements#4671
KEP: kubernetes/enhancements#5832

Special notes for your reviewer:

/sig scheduling

Does this PR introduce a user-facing change?

Introduced scheduling.k8s.io/v1alpha2 Workload and PodGroup API to allow for expressing workload-level scheduling requirements and let kube-scheduler act on those. Removed scheduling.k8s.io/v1alpha1 Workload API.

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

- [KEP]: https://github.com/kubernetes/enhancements/issues/4671
- [KEP]: https://github.com/kubernetes/enhancements/issues/5832

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. labels Feb 12, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in SIG Scheduling Feb 12, 2026
@k8s-ci-robot k8s-ci-robot added 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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 12, 2026
@tosi3k
Copy link
Copy Markdown
Member Author

tosi3k commented Feb 12, 2026

/cc @mm4tt
/cc @wojtek-t

@k8s-ci-robot k8s-ci-robot added the sig/apps Categorizes an issue or PR as relevant to SIG Apps. label Feb 12, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in SIG Apps Feb 12, 2026
@tosi3k tosi3k marked this pull request as draft February 12, 2026 08:35
Copy link
Copy Markdown
Contributor

@mm4tt mm4tt left a comment

Choose a reason for hiding this comment

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

Thanks, first round of comments

Comment thread pkg/apis/core/types.go Outdated
Comment thread pkg/apis/core/types.go Outdated
Comment thread pkg/apis/core/types.go Outdated
Comment thread pkg/apis/core/types.go
Comment thread staging/src/k8s.io/api/scheduling/v1alpha2/register.go Outdated
Comment thread staging/src/k8s.io/api/scheduling/v1alpha2/register.go Outdated
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. area/apiserver area/code-generation area/kubectl area/test sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 12, 2026
@kannon92
Copy link
Copy Markdown
Contributor

kannon92 commented Mar 7, 2026

The linter failures do look like it's due to your code.

@tosi3k
Copy link
Copy Markdown
Member Author

tosi3k commented Mar 7, 2026

The linter failures do look like it's due to your code.

Go version got upgraded in k/k just recently - and with it, the linters, including one that enforces using new instead of ptr.To in the new code.

Fixed.

Comment thread staging/src/k8s.io/api/scheduling/v1alpha2/types.go Outdated
Comment thread pkg/scheduler/schedule_one_podgroup.go
Copy link
Copy Markdown
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

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

Almost there - unclear about why we are leaving immutable marked as alpha?

Was this guidance from DV team (@yongruilin) ?

Comment thread staging/src/k8s.io/api/core/v1/types.go Outdated
//
// +optional
// +k8s:optional
// +k8s:alpha(since:"1.36")=+k8s:immutable
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I thought we decided that the +k8s:alpha prefix was not needed, but I still see it here. I know the transition to DV is a little complicated (sorry) - am I missing a reason why this needs to stay alpha?

I think it can be removed for ALL of these DV tags since there is no equivalent handwritten logic?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Contrary to e.g. k8s:optional, k8s:immutable hasn't reached the GA stability level - codegen opposed dropping the alpha prefix when I tried to do so.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This also mimics what we had proposed in tosi3k#1.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+k8s:immutable is not yet promoted to stable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@yongruilin -- I think that resources which are new (alpha), which are not doing new handwritten code, do we still need to do this "it's not stable" dance?

On one hand, the whole apigroup is alpha, so I don't care that the tag is not stable. I don't want to read handwritten code.

On the other hand, we can't let the API go to GA while the tag is still alpha.

Is this the best we can do? It's not terrible since it's 1:1 with a handwritten function, but play it out in the future.

A new API is being built. It needs a new tag. We add a new tag, but it is not stable. Does this mean we have to write handwritten code for the new tag-equivalent? That doesn't seem to mitigate any risk, which is why we need pre-stable tags in the first place.

How could we avoid needing new handwritten?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Under current implementation, we can add // +k8s:validation-gen-nolint to the new type to bypass the lint check for this new API type. So that we can benefit from the pre-stable tags. And in the following release, when API is ready for GA, we should be able to promote the pre-stable tags to stable while dropping the validation-gen-nolint.

Comment thread staging/src/k8s.io/api/scheduling/v1alpha2/types.go
// +required
// +listType=map
// +listMapKey=name
// +k8s:required
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Bringing back a lost comment:

Given the discussion around the meaning of required WRT openapi vs. k8s, perhaps this should ALSO specify minItems=1. Right now "required" implies that, but openapi would allow podGroupTemplates=[] (since that satisfies openapi "required"). We don't actually have a minItems tag yet, but it's trivial to add and when we do it would apply to this.

@lalitc375 what do you think? Worthwhile or redundant?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Lalit is OOO until next Monday, unfortunately :(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this ends up as the last comment, it could be a followup.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread staging/src/k8s.io/api/scheduling/v1alpha2/types.go
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why no DV tags for this? +k8s:listType=map etc

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it because we still need to manually call the ValidateConditions(), which causes dup errors? If so, maybe a comment here?

Copy link
Copy Markdown
Member Author

@tosi3k tosi3k Mar 9, 2026

Choose a reason for hiding this comment

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

Is it because we still need to manually call the ValidateConditions(), which causes dup errors?

Exactly.

If so, maybe a comment here?

Hmm, on one hand I agree such comment would bring about more clarity, on the other hand:

  • IIUC it's preferable to have matching comments in the internal and the external API definitions - and we don't use the DV tags in the internal type definitions, so having that comment in the internal type would be confusing.
  • Other APIs that use metav1.Condition in their status do not document that either - so it's more of a systemic problem rather than the problem with this particular API.

Would an appropriate comment in pkg/apis/scheduling/validation/validation.go instead (above the line where we use metav1validation.ValidateConditions) make more sense?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's only a "problem" in that adding DV to metav1.Condition would generate DV for ~every type, which is only a "problem" because we haven't spent time to fix that :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@aaron-prindle @yongruilin @lalitc375

Gut-check time: What if we actually started enabling deeper DV? When will we feel comfortable doing this?

Comment thread pkg/registry/scheduling/podgroup/declarative_validation_test.go
Comment thread pkg/apis/scheduling/validation/validation.go
@tosi3k
Copy link
Copy Markdown
Member Author

tosi3k commented Mar 9, 2026

/test pull-kubernetes-unit

@thockin
Copy link
Copy Markdown
Member

thockin commented Mar 9, 2026

/approve for API

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dom4ha, macsko, thockin, tosi3k, wojtek-t

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

The pull request process is described here

Details 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

@kannon92
Copy link
Copy Markdown
Contributor

/retest

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

k8s-ci-robot commented Mar 10, 2026

@tosi3k: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-apidiff-client-go 9c1e30d link false /test pull-kubernetes-apidiff-client-go
pull-kubernetes-linter-hints 9c1e30d link false /test pull-kubernetes-linter-hints

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

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. I understand the commands that are listed here.

@kannon92
Copy link
Copy Markdown
Contributor

/lgtm

Based on all the approvers I think this can merge.

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: e2393388dac61a91f5644d2bc73ad6e84ada373d

@lmktfy
Copy link
Copy Markdown
Member

lmktfy commented Mar 17, 2026

BTW, is there an associated docs PR?

@macsko
Copy link
Copy Markdown
Member

macsko commented Mar 17, 2026

BTW, is there an associated docs PR?

Yes, kubernetes/website#54490

Comment thread test/e2e/scheduling/workload.go
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/apiserver area/code-generation area/kubectl area/provider/gcp Issues or PRs related to gcp provider area/test area/workload-aware Categorizes an issue or PR as relevant to Workload-aware and Topology-aware scheduling subprojects. 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/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. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/etcd Categorizes an issue or PR as relevant to SIG Etcd. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Projects

Archived in project
Archived in project
Archived in project
Archived in project

Development

Successfully merging this pull request may close these issues.