Skip to content

DRA: migrate DeviceTaint and Conditions to declarative validation#135460

Open
dumko2001 wants to merge 12 commits into
kubernetes:masterfrom
dumko2001:dra-declarative-validation-135073
Open

DRA: migrate DeviceTaint and Conditions to declarative validation#135460
dumko2001 wants to merge 12 commits into
kubernetes:masterfrom
dumko2001:dra-declarative-validation-135073

Conversation

@dumko2001

Copy link
Copy Markdown

What type of PR is this?
/kind cleanup
/kind feature

What this PR does / why we need it:
This PR migrates the validation for Device.Taints and AllocatedDeviceStatus.Conditions from manual Go code to declarative markers, addressing items from the tracking issue #135073.

Changes:

staging/src/k8s.io/api/resource/v1/types.go:
Added // +k8s:maxItems=16 to Device.Taints.
Added // +k8s:maxItems=8, // +k8s:listType=map, and // +k8s:listMapKey=type to AllocatedDeviceStatus.Conditions.
pkg/apis/resource/validation/validation.go:
Updated validateDevice to mark Taints size as covered by declarative validation (sizeCovered).
Removed the manual length check for Conditions in validateDeviceStatus.
Ran make update to synchronize generated files (zz_generated.* and generated.proto).

Which issue(s) this PR is related to:
Fixes #135073

Special notes for your reviewer:
The tracking issue suggested adding // +k8s:unique=map for AllocatedDeviceStatus.Conditions.

I have omitted this specific tag because it causes a conflict in update-codegen:

tag "k8s:unique": unique tag may not be used with listType=set or listType=map
Since listType=map already enforces uniqueness on the key (type), the explicit unique tag is redundant.

Does this PR introduce a user-facing change?

NONE

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

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/feature Categorizes issue or PR as related to a new feature. labels Nov 26, 2025
@linux-foundation-easycla

linux-foundation-easycla Bot commented Nov 26, 2025

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Nov 26, 2025
@k8s-ci-robot

Copy link
Copy Markdown
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.

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.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 26, 2025
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Welcome @dumko2001!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Hi @dumko2001. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Nov 26, 2025
@k8s-ci-robot k8s-ci-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API wg/device-management Categorizes an issue or PR as relevant to WG Device Management. labels Nov 26, 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 Nov 26, 2025
@dumko2001 dumko2001 force-pushed the dra-declarative-validation-135073 branch from a6760d0 to 46eccab Compare November 26, 2025 14:16
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 26, 2025
@k8s-triage-robot

Copy link
Copy Markdown

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.

@pohly pohly moved this from 🆕 New to 👀 In review in Dynamic Resource Allocation Dec 1, 2025

@lalitc375 lalitc375 left a comment

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.

Thank you for the PR @dumko2001 . Totally appreciate it.

Please follow this pattern for adding tags.

The ideal PR structure for a PR contributing a DV tag migration is:

Commit # 1: IF NOT ALREADY WIRED UP FOR DV - Wire up the apigroup, add empty test and empty generated file. I don't need to review this, you know the pattern by now.

Commit # 2: Use a single DV tag on a single field. E.g. Add +k8s:required to required field. Includes generated code and robust test cases. Emphasis on test-cases -- we want enough to prove that a field is correct, but we don't want to duplicate all the per-tag tests (e.g. a k8s-short-name field has dozens of corner cases, but we really only need a few). We want each case to be as short and specific as possible, which is why the "tweak" pattern and the use of Origin for Invalid() errors is so important. Specify as little as possible to be sufficiently precise. Newcomers need guidance on this.

Commits # 3...N: Use DV tags on the same field, one per commit; repeat until that field is done or all that is left is not handled by DV yet. Includes generated code and tests for each field. (not the case for the specific examples below as they are for single tag migrations)

Commits N+1...M: Repeat the above for more fields. (not the case for the specific examples below as they are for single field migrations)

The emphasis is on lots of small commits. Maintaining commit discipline is hard but worthwhile.

If DV exposes bugs in the existing testing or the hand-written validation itself (!!), those should be fixed as a PR of its own or as commits at the front of the PR.

Comment thread pkg/apis/resource/validation/validation.go
Comment thread staging/src/k8s.io/api/resource/v1/types.go
// +optional
// +listType=atomic
// +featureGate=DRADeviceTaints
// +k8s:maxItems=16

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.

Add tests for these new validation tags in pkg/registry/resource/resourceslice/declarative_validation_test.go

@lalitc375

Copy link
Copy Markdown
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 15, 2025
dumko2001 added 10 commits May 30, 2026 12:12
- Remove invalid +k8s:validation:MinLength=1 tag from DeviceTaint.Key
- Remove redundant +k8s:validation:Enum tag from DeviceTaint.Effect
- Add missing +k8s:optional tag to AllocatedDeviceStatus.Conditions
- Applied to v1, v1beta1, and v1beta2 API versions
- Add 'valid: at limit taints' test (16 taints) for ResourceSlice
- Add 'valid: at limit conditions' test (8 conditions) for ResourceClaim
- Add 'invalid: duplicate condition type' test for +k8s:listMapKey=type
- Move ResourceVersion assignment to test loop
- Add normalization rule for conditions path matching
- Mark duplicate condition errors as covered by declarative
@dumko2001 dumko2001 force-pushed the dra-declarative-validation-135073 branch from 2aa2ff8 to e3d841f Compare May 30, 2026 10:53
@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 30, 2026
@dumko2001 dumko2001 force-pushed the dra-declarative-validation-135073 branch from e3d841f to 5ac5f9b Compare May 30, 2026 11:09
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels May 30, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dumko2001
Once this PR has been reviewed and has the lgtm label, please assign liggitt for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@dumko2001

Copy link
Copy Markdown
Author

@lalitc375 rebased PR is now green on a7b6b48f36ea.

The small follow-up in test/e2e/dra/kind.yaml was only to keep the existing DRA kind presubmits working after the rebase onto current master: kinds kubeadm.k8s.io/v1beta4 apiServer.extraArgs needed the new list form for runtime-config, otherwise the legacy DRA claim/template APIs used by those jobs were not served and the DRA kind jobs failed with 404s.

Could you please take another look when you have a moment?

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

PR needs rebase.

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.

@lalitc375

Copy link
Copy Markdown
Contributor

I just realized this has overlap with #139101 . Can you remove DV from conditions in this PR? Please also rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. wg/device-management Categorizes an issue or PR as relevant to WG Device Management.

Projects

Status: 👀 In review
Status: Archive-it

Development

Successfully merging this pull request may close these issues.

[Umbrella] DRA Declarative Validation Migration Tracking Issue

7 participants