Skip to content

compute-domain: validate the workload ResourceClaimTemplate name - #1651

Open
shivamerla wants to merge 1 commit into
kubernetes-sigs:mainfrom
shivamerla:fix/cd-rct-name-validation
Open

shivamerla wants to merge 1 commit into
kubernetes-sigs:mainfrom
shivamerla:fix/cd-rct-name-validation

Conversation

@shivamerla

@shivamerla shivamerla commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

The CRD now requires the name to be a DNS-1123 subdomain. The controller validates it before rendering and rejects any rendered template whose namespace or name differs from the requested one.

Which issue(s) this PR is related to:

Fixes #1649

Special notes for your reviewer:

Does this PR introduce a user-facing change?


Additional documentation (design docs, usage docs, etc.):


Checklist

  • make check test passes locally
  • make check-generate passes if api/ changed (CRDs, deepcopy, informers, listers, clientset)
  • make check-modules passes if go.mod / go.sum changed
  • Tests added or updated for the change
  • Helm chart (deployments/helm) updated if flags, RBAC, or defaults changed

@netlify

netlify Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

👷 Deploy request for dra-driver-nvidia-gpu pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 6d4d29f

@kubernetes-prow kubernetes-prow Bot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Nov 22, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: shivamerla

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

@kubernetes-prow kubernetes-prow Bot added needs-kind Indicates a PR lacks a `kind/foo` label and requires one. approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 22, 2026
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

The ComputeDomain API now validates the generated ResourceClaimTemplate name as a DNS-1123 subdomain. The controller validates the name before rendering and checks that the rendered object's namespace and name match the requested values before creation. It records the created object in the mutation cache. Tests cover valid rendering, invalid names, and a namespace mismatch.

Severity of issue fixed: Low

Merge Risk: Low · up to 4ac28

The change adds DNS-1123 validation for the workload ResourceClaimTemplate name and an identity check before creation. The import formatting must be fixed to pass CI, and the API validation tests should be added. Otherwise the risk is low.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: validation of the workload ResourceClaimTemplate name in the compute-domain controller. The raw summary shows the DNS-1123 subdomain validation in the CRD markers and …
Linked Issues check Passed [#1649] Objectives:

1. CRD name validation. api/nvidia.com/resource/v1beta1/computedomain.go adds validation markers to ComputeDomainResourceClaimTemplate.Name: length 1-253 and a DNS-1123 subdomain …
Out of Scope Changes check Passed Changed files in the whole-PR diff (mergeBase 44cf296 to head 4ac28e0):
- api/nvidia.com/resource/v1beta1/computedomain.go: validation markers for the requested name (+4). Directly serves #1649.
- cmd…
Description check Passed The description states the PR's purpose: the CRD now requires the workload ResourceClaimTemplate name to be a DNS-1123 subdomain, and the controller validates the name before rendering and rejects ren…
Full details: Title check

Explanation

The title names the main change: validation of the workload ResourceClaimTemplate name in the compute-domain controller. The raw summary shows the DNS-1123 subdomain validation in the CRD markers and in the controller's Create path, so the title matches the changeset.

Full details: Linked Issues check

Explanation

[#1649] Objectives:

  1. CRD name validation. api/nvidia.com/resource/v1beta1/computedomain.go adds validation markers to ComputeDomainResourceClaimTemplate.Name: length 1-253 and a DNS-1123 subdomain pattern. The generated CRD YAML (deployments/helm/dra-driver-nvidia-gpu/crds/resource.nvidia.com_computedomains.yaml) is in ignored_files and was not inspected. This objective rests on the source markers. The author reports make check-generate passes.

  2. Controller validation before rendering. cmd/compute-domain-controller/resourceclaimtemplate.go: BaseResourceClaimTemplateManager.Create renders the template first. Rendering validates the requested name as a DNS-1123 subdomain. This covers ComputeDomains created before the CRD change.

  3. Namespace and name check before creation. The same render step rejects a rendered object whose namespace or name differs from the requested values. The object is created only after this check.

Tests in cmd/compute-domain-controller/resourceclaimtemplate_test.go cover rendered namespace and name, and reject injected YAML, uppercase, empty, overlong, trailing-whitespace, and flow-mapping names. A namespace mismatch test checks the error text.

No unmet coding requirement found in the evidence. Non-coding items: none.

Full details: Out of Scope Changes check

Explanation

Changed files in the whole-PR diff (mergeBase 44cf296 to head 4ac28e0):

  • api/nvidia.com/resource/v1beta1/computedomain.go: validation markers for the requested name (+4). Directly serves #1649.
  • cmd/compute-domain-controller/resourceclaimtemplate.go: render-before-create, name validation, namespace and name mismatch check (+30/-8). Directly serves #1649.
  • cmd/compute-domain-controller/resourceclaimtemplate_test.go: tests for the new validation (+55). Supporting tests for #1649.

The generated CRD YAML under deployments/helm is excluded from review. It is a generated artifact of the API markers, so it is not a separate out-of-scope change. No change was found that lacks a connection to #1649.

Full details: Description check

Explanation

The description states the PR's purpose: the CRD now requires the workload ResourceClaimTemplate name to be a DNS-1123 subdomain, and the controller validates the name before rendering and rejects rendered templates whose namespace or name differs. It also links Fixes #1649 and lists the test and generate checks. This matches the changeset in api/nvidia.com/resource/v1beta1/computedomain.go, cmd/compute-domain-controller/resourceclaimtemplate.go, and its test file.

Finishing Touches

Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

The CRD now requires the name to be a DNS-1123 subdomain. The controller
validates it before rendering and rejects any rendered template whose
namespace or name differs from the requested one.
@shivamerla
shivamerla force-pushed the fix/cd-rct-name-validation branch from 4ac28e0 to 6d4d29f Compare November 22, 2026 17:56

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

Other comments: 2

cmd/compute-domain-controller/resourceclaimtemplate.go: 1

23-23: Minor · Maintainability & Code Quality · Quick win

Correct the import block to restore the check job.

The supplied basic / golang / check result fails at Line 23 with File is not properly formatted (goimports). Group the validation import with the other Kubernetes imports, then rerun make check. That target includes golangci-lint. (raw.githubusercontent.com)

Source: Pipeline failures

api/nvidia.com/resource/v1beta1/computedomain.go: 1

109-111: Minor · Maintainability & Code Quality · Heavy lift

Add accept and reject tests for the workload ResourceClaimTemplate name constraints.

The new name markers on ComputeDomainResourceClaimTemplate have no table-driven test in the API package. The path guideline for this package requires one for new validation. Without it, a change to the pattern or the 253-character limit can ship unnoticed.

Add computedomain_test.go with a table-driven test. Include these cases:

  • Accept: a, a.b, and a 253-character lowercase name.
  • Reject: an empty name, Upper, a..b, and a 254-character name.

The test can check the marker pattern and length through the generated schema or through a validator. The choice of mechanism is open.

Source: Path instructions

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 44cf296 and 4ac28e0.

Files ignored due to path filters: 1

  • deployments/helm/dra-driver-nvidia-gpu/crds/resource.nvidia.com_computedomains.yaml is excluded by !deployments/helm/dra-driver-nvidia-gpu/crds/**
Files selected for processing: 3

  • api/nvidia.com/resource/v1beta1/computedomain.go
  • cmd/compute-domain-controller/resourceclaimtemplate.go
  • cmd/compute-domain-controller/resourceclaimtemplate_test.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@shivamerla

Copy link
Copy Markdown
Contributor Author

/kind cleanup
/release-note-none

@kubernetes-prow kubernetes-prow Bot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Nov 22, 2026
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[Feature]: ComputeDomain API: validate spec.channel.resourceClaimTemplate.name

1 participant