You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Drop a trailing dot when truncating generated object names - #18803
Kueue shortens long generated names by cutting a prefix to a length limit and appending -<hash>. When the cut ends on a ., the name contains .-, which is not a valid DNS subdomain, so the API server rejects the Workload or ProvisioningRequest (HTTP 422).
This adds utilstrings.TruncateNamePrefix, which cuts the prefix and then drops any trailing ., and uses it in the three sanitizers named in the issue:
GenerateWorkloadNameWithExtra (and GetWorkloadNameForVariant, which shares generateWorkloadNameWithHash); GenerateWorkloadNamePrefix uses it too, so the prefix still matches the name, and the local truncate helper is removed
limitObjectNameWithReservedSuffix (ProvisioningRequest and its PodTemplate names)
virtualPodName
flowchart TD
A[Long name cut to the length limit] --> B{Cut ends on a dot}
B -->|Before| C[Name contains dot hyphen and is rejected]
B -->|After| D[Trailing dot dropped and the name is valid]
Only a trailing . is trimmed, not a trailing -. A cut that ends on - gives --<hash>, which is valid, and Workloads and ProvisioningRequests with such names may already exist. Kueue finds them by recomputing the name (for example ProvisioningRequestName and matchesWorkloadAndCheck, or the Pod group and StatefulSet webhooks), so trimming - would rename them on upgrade. With only . trimmed, every name that changes was previously invalid, so no existing object is affected.
Out of scope: virtualGroupName already trims .- since #16904 and is unchanged. The broader unification of the sanitizers (point 2 of the issue) and the hash-length discussion in the comments are not attempted here.
Behavior
Level
Command and result
Not run and why
Workload name (including variant names) is valid when the cut ends on ., with ShortWorkloadNames on and off
unit
go test ./pkg/controller/jobframework/: ok. The 3 new cases fail on main
integration/e2e: no cluster available
ProvisioningRequest name is valid when the cut ends on ., and is still matched to its Workload and attempt
unit
go test ./pkg/controller/admissionchecks/provisioning/: ok. The new case fails on main
integration/e2e: no cluster available
Virtual Pod name is valid when the cut ends on .
unit
go test ./pkg/cache/scheduler/was/: ok. The new case fails on main
none
TruncateNamePrefix: name under the limit unchanged, cut at the limit, trailing . dropped, trailing - kept
unit
go test ./pkg/util/strings/: ok
none
All new cases are in existing unit-test packages, which make test selects (every package outside /test/). Each new case also asserts validation.IsDNS1123Subdomain on the output. The existing exact-name cases (short names, long truncated names, wl-check-1) pass unchanged.
make verify could not run here: the Makefile requires GNU sed on macOS, and shell-lint/npm-depcheck need Docker, neither of which was available. Instead I ran the repo-pinned golangci-lint v2.15.0 with .golangci.yaml on the four changed packages (0 issues), plus go vet and gofmt -l (both clean).
Narrated recording, before then after (sound on):
evidence.mp4
The commands in the video, with their output. Before, with main's sanitizers and the new tests:
The grep only hides klog's feature-gate warnings, which fill about 1,700 lines.
Edge cases and unchanged behaviour checked (all by unit tests, shown in the video's last part; nothing was run against a cluster):
A name under the limit is unchanged.
A trailing . at the cut is dropped, and a trailing - at the cut is kept.
Unchanged: the existing exact-name cases for GenerateWorkloadNameWithExtra and ProvisioningRequestName still pass, and the four packages pass in full.
AI assistance (Claude Code) was used to write this change, its tests and this description.
Release note
Workloads: Fixed a bug that caused generated Workload and ProvisioningRequest names to contain `.-` after truncation. The API server rejected these names. Now Kueue removes trailing dots from the truncated name before it appends the hash suffix.
AI summary
This PR fixes generated object names that contain .- after truncation. Such names are invalid for the Kubernetes API server.
Adds utilstrings.TruncateNamePrefix in pkg/util/strings/strings.go. It truncates a string to at most n bytes and removes trailing . characters. It keeps trailing - characters.
Uses the helper in:
GenerateWorkloadNamePrefix and generateWorkloadNameWithHash in pkg/controller/jobframework/workload_names.go. The local truncate helper is removed.
limitObjectNameWithReservedSuffix in pkg/controller/admissionchecks/provisioning/controller.go, which names ProvisioningRequests.
The virtual pod name generation in pkg/cache/scheduler/was/virtual_pods.go.
Adds tests for dot truncation in the string, jobframework, provisioning, and virtual pod packages. The tests check DNS-1123 subdomain validity of generated names.
Does not change trailing-hyphen handling, virtualGroupName, or the sanitizer structure. The linked issue #16929 proposes trimming trailing - and unifying the sanitizers. This PR does not implement those parts.
Suggested release note
Workloads: Fixed a bug that caused generated Workload and ProvisioningRequest names to contain `.-` after truncation. The API server rejected these names. Now Kueue removes trailing dots from the truncated name before it appends the hash suffix.
Workload, ProvisioningRequest, ProvisioningRequest PodTemplate and virtual
Pod names are built by truncating a prefix and appending "-<hash>". When
the cut ends on a '.', the result contains ".-", which is not a valid
DNS subdomain, so the API server rejects the Workload or
ProvisioningRequest.
Add utilstrings.TruncateNamePrefix, which truncates and then trims any
trailing '.', and use it in all three name sanitizers. A trailing '-' is
kept: "--" is valid, and trimming it would change the names of existing
objects.
Signed-off-by: burrows99 <raunakburrows@gmail.com>
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 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. 😃
kubernetes-prowBot
added
size/L
Denotes a PR that changes 100-499 lines, ignoring generated files.
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 15, 2026
I'm waiting for a kubernetes-sigs 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.
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.
Auto reviews are limited based on label configuration.
🚫 Excluded labels (none allowed): 3
needs-ok-to-test
do-not-merge/work-in-progress
cncf-cla: no
Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Name generation now uses a shared helper that truncates prefixes and removes trailing periods. Tests cover names near truncation boundaries and validate generated names as DNS-1123 subdomains.
The change prevents generated object names from ending a truncated prefix with a dot, which the API server rejects. It is narrow, covered by unit tests, and easy to revert. Merge risk is minimal. The CLA status still needs to be resolved.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: truncating generated object names now drops a trailing dot. The changeset adds TruncateNamePrefix, which removes trailing periods after truncation, and uses it in the …
Linked Issues check
Issue #16929 is the only directly linked issue, and it is open. Its reported defect is a generated name that contains .- and is rejected with HTTP 422. The PR fixes this in the three named sanitizer…
Out of Scope Changes check
All changed files relate to the linked issue. The changes are: the new TruncateNamePrefix helper and its tests (pkg/util/strings); the Workload name sanitizers and the removed local truncate helpe…
Full details: Title check
Explanation
The title names the main change: truncating generated object names now drops a trailing dot. The changeset adds TruncateNamePrefix, which removes trailing periods after truncation, and uses it in the workload, provisioning request, and virtual pod name paths. The title is specific and matches the linked issue's concern about names ending in '.-'.
Full details: Linked Issues check
Explanation
Issue #16929 is the only directly linked issue, and it is open. Its reported defect is a generated name that contains .- and is rejected with HTTP 422. The PR fixes this in the three named sanitizers. utilstrings.TruncateNamePrefix (pkg/util/strings/strings.go) drops trailing . after truncation. It is used in GenerateWorkloadNamePrefix and generateWorkloadNameWithHash (pkg/controller/jobframework/workload_names.go; the local truncate helper is removed), in limitObjectNameWithReservedSuffix (ProvisioningRequest and PodTemplate names), and in virtualPodName. New unit tests cover the cut-at-dot case and assert validation.IsDNS1123Subdomain. Expected-output tests cover the trailing-dot and trailing-hyphen cases.
Deviation from the issue text: the issue asks to strip trailing . and -. The PR strips only .. The author gives a concrete reason: a trailing - yields --<hash>, which is a valid name, and stripping it would change names that existing Workloads and ProvisioningRequests are recomputed from. This deviation does not leave the reported 422 defect open. It is treated as a justified departure.
Requirement 2 of the issue (unifying the sanitizers) is a cleanup suggestion. The PR states it is out of scope, and it is not a required outcome of the bug fix. It is not counted against this PR.
Coding evidence is from the PR summary, the diff of workload_names.go, and the head source of strings.go. Test results are as reported by the author; they were not re-run.
Full details: Out of Scope Changes check
Explanation
All changed files relate to the linked issue. The changes are: the new TruncateNamePrefix helper and its tests (pkg/util/strings); the Workload name sanitizers and the removed local truncate helper (pkg/controller/jobframework/workload_names.go and its tests); the ProvisioningRequest name function (pkg/controller/admissionchecks/provisioning/controller.go and its tests); and the virtual Pod name function (pkg/cache/scheduler/was/virtual_pods.go and its tests). Switching GenerateWorkloadNamePrefix to the helper keeps the prefix consistent with the generated name, so it supports the same fix. The PR description states that virtualGroupName and the broader sanitizer unification are not changed. No unrelated change was found in the summary.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
kubernetes-prowBot
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
Nov 15, 2026
@burrows99 nice PR! 🎉🎉
Don't forget to authorize the CNCF CLA following the steps here: #18803 (comment)
Also, for future PRs, there's no need to record/upload a video showing the tests passing as Prow runs the test suite automatically and we can see the results directly in the Commits tab
The reason will be displayed to describe this comment to others. Learn more.
Looks good. TruncateNamePrefix is the right place for this, and keeping trailing - while dropping trailing . matches the upgrade story in the description (only previously-invalid names change).
The three call sites plus the DNS1123 assertions in the new cases cover the issue well. One small follow-up that is fine as a separate cleanup: virtualGroupName still has its own trim path (#16904); not blocking.
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.
@mimowo: #18803 failed to apply on top of branch "release-0.19":
Applying: Drop a trailing dot when truncating generated object names
Using index info to reconstruct a base tree...
A pkg/cache/scheduler/was/virtual_pods.go
A pkg/cache/scheduler/was/virtual_pods_test.go
M pkg/controller/admissionchecks/provisioning/controller.go
M pkg/controller/admissionchecks/provisioning/provisioning_test.go
M pkg/controller/jobframework/workload_names.go
M pkg/util/strings/strings.go
M pkg/util/strings/strings_test.go
Falling back to patching base and 3-way merge...
CONFLICT (modify/delete): pkg/cache/scheduler/was/virtual_pods.go deleted in HEAD and modified in Drop a trailing dot when truncating generated object names. Version Drop a trailing dot when truncating generated object names of pkg/cache/scheduler/was/virtual_pods.go left in tree.
CONFLICT (modify/delete): pkg/cache/scheduler/was/virtual_pods_test.go deleted in HEAD and modified in Drop a trailing dot when truncating generated object names. Version Drop a trailing dot when truncating generated object names of pkg/cache/scheduler/was/virtual_pods_test.go left in tree.
Auto-merging pkg/controller/admissionchecks/provisioning/controller.go
Auto-merging pkg/controller/admissionchecks/provisioning/provisioning_test.go
CONFLICT (content): Merge conflict in pkg/controller/admissionchecks/provisioning/provisioning_test.go
Auto-merging pkg/controller/jobframework/workload_names.go
Auto-merging pkg/util/strings/strings.go
Auto-merging pkg/util/strings/strings_test.go
CONFLICT (content): Merge conflict in pkg/util/strings/strings_test.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Drop a trailing dot when truncating generated object names
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.
@mimowo: #18803 failed to apply on top of branch "release-0.20":
Applying: Drop a trailing dot when truncating generated object names
Using index info to reconstruct a base tree...
M pkg/cache/scheduler/was/virtual_pods.go
M pkg/cache/scheduler/was/virtual_pods_test.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/cache/scheduler/was/virtual_pods.go
CONFLICT (content): Merge conflict in pkg/cache/scheduler/was/virtual_pods.go
Auto-merging pkg/cache/scheduler/was/virtual_pods_test.go
CONFLICT (content): Merge conflict in pkg/cache/scheduler/was/virtual_pods_test.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Drop a trailing dot when truncating generated object names
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.
/set-release-note
Workloads: Fixed a bug that caused generated Workload and ProvisioningRequest names to contain .- after truncation. The API server rejected these names. Now Kueue removes trailing dots from the truncated name before it appends the hash suffix.
Workloads: Fixed a bug that caused generated Workload and ProvisioningRequest names to contain `.-` after truncation. The API server rejected these names. Now Kueue removes trailing dots from the truncated name before it appends the hash suffix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
approvedIndicates a PR has been approved by an approver from all required OWNERS files.cncf-cla: yesIndicates the PR's author has signed the CNCF CLA.kind/bugCategorizes issue or PR as related to a bug.lgtm"Looks good to me", indicates that a PR is ready to be merged.ok-to-testIndicates a non-member PR verified by an org member that is safe to test.release-noteDenotes a PR that will be considered when it comes time to generate release notes.size/LDenotes a PR that changes 100-499 lines, ignoring generated files.
6 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind bug
What this PR does / why we need it?
Kueue shortens long generated names by cutting a prefix to a length limit and appending
-<hash>. When the cut ends on a., the name contains.-, which is not a valid DNS subdomain, so the API server rejects the Workload or ProvisioningRequest (HTTP 422).This adds
utilstrings.TruncateNamePrefix, which cuts the prefix and then drops any trailing., and uses it in the three sanitizers named in the issue:GenerateWorkloadNameWithExtra(andGetWorkloadNameForVariant, which sharesgenerateWorkloadNameWithHash);GenerateWorkloadNamePrefixuses it too, so the prefix still matches the name, and the localtruncatehelper is removedlimitObjectNameWithReservedSuffix(ProvisioningRequest and its PodTemplate names)virtualPodNameflowchart TD A[Long name cut to the length limit] --> B{Cut ends on a dot} B -->|Before| C[Name contains dot hyphen and is rejected] B -->|After| D[Trailing dot dropped and the name is valid]Fixes #16929
Useful notes for your reviewer
Only a trailing
.is trimmed, not a trailing-. A cut that ends on-gives--<hash>, which is valid, and Workloads and ProvisioningRequests with such names may already exist. Kueue finds them by recomputing the name (for exampleProvisioningRequestNameandmatchesWorkloadAndCheck, or the Pod group and StatefulSet webhooks), so trimming-would rename them on upgrade. With only.trimmed, every name that changes was previously invalid, so no existing object is affected.Out of scope:
virtualGroupNamealready trims.-since #16904 and is unchanged. The broader unification of the sanitizers (point 2 of the issue) and the hash-length discussion in the comments are not attempted here.., withShortWorkloadNameson and offgo test ./pkg/controller/jobframework/: ok. The 3 new cases fail onmain., and is still matched to its Workload and attemptgo test ./pkg/controller/admissionchecks/provisioning/: ok. The new case fails onmain.go test ./pkg/cache/scheduler/was/: ok. The new case fails onmainTruncateNamePrefix: name under the limit unchanged, cut at the limit, trailing.dropped, trailing-keptgo test ./pkg/util/strings/: okAll new cases are in existing unit-test packages, which
make testselects (every package outside/test/). Each new case also assertsvalidation.IsDNS1123Subdomainon the output. The existing exact-name cases (short names, long truncated names,wl-check-1) pass unchanged.make verifycould not run here: the Makefile requires GNU sed on macOS, andshell-lint/npm-depcheckneed Docker, neither of which was available. Instead I ran the repo-pinned golangci-lint v2.15.0 with.golangci.yamlon the four changed packages (0 issues), plusgo vetandgofmt -l(both clean).Narrated recording, before then after (sound on):
evidence.mp4
The commands in the video, with their output. Before, with
main's sanitizers and the new tests:After, on this branch:
The
greponly hides klog's feature-gate warnings, which fill about 1,700 lines.Edge cases and unchanged behaviour checked (all by unit tests, shown in the video's last part; nothing was run against a cluster):
.at the cut is dropped, and a trailing-at the cut is kept.GenerateWorkloadNameWithExtraandProvisioningRequestNamestill pass, and the four packages pass in full.AI assistance (Claude Code) was used to write this change, its tests and this description.
Release note
AI summary
This PR fixes generated object names that contain
.-after truncation. Such names are invalid for the Kubernetes API server.utilstrings.TruncateNamePrefixinpkg/util/strings/strings.go. It truncates a string to at mostnbytes and removes trailing.characters. It keeps trailing-characters.GenerateWorkloadNamePrefixandgenerateWorkloadNameWithHashinpkg/controller/jobframework/workload_names.go. The localtruncatehelper is removed.limitObjectNameWithReservedSuffixinpkg/controller/admissionchecks/provisioning/controller.go, which names ProvisioningRequests.pkg/cache/scheduler/was/virtual_pods.go.virtualGroupName, or the sanitizer structure. The linked issue#16929proposes trimming trailing-and unifying the sanitizers. This PR does not implement those parts.Suggested release note