[Bug] Reserve space for service suffix so generated resource names stay within 63-char limit - #2496
Merged
Jeffwan merged 1 commit intoJul 26, 2026
Conversation
The Console Kubernetes provider generated a base resource name that could occupy the full 63-character DNS label limit, then appended "-svc" when creating the Service. The resulting Service name exceeded 63 characters, so the API server rejected it with HTTP 500 after the Deployment had already been created (the rollback removed the Deployment, but the request still failed for an otherwise valid user-facing name). generateResourceName now reserves room for the longest suffix appended to the base name (the Service's "-svc") in addition to the prefix, joining dash, and unique suffix, so every derived name stays within the limit. The magic values are extracted into named constants (maxResourceNameLength, resourceNamePrefix, resourceNameUniqueSuffixLength, serviceNameSuffix) and the "-svc" literal is replaced with serviceNameSuffix everywhere so the reservation can never drift from the actual suffix. Tests cover names below, at, and above the boundary and assert the validity of the final Service name (not just the base) using Kubernetes' own DNS label validator, plus an end-to-end Create with a 100-character name that checks the created Deployment, Service, and HPA object names. The unique suffix is preserved after truncation to keep names collision-free. Closes vllm-project#2493 Signed-off-by: addielarue <bhasmerutika@gmail.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors Kubernetes resource name generation to ensure that derived resource names, such as Services with a -svc suffix, do not exceed the 63-character Kubernetes DNS label limit. It introduces constants for name lengths, prefixes, and suffixes, and dynamically calculates the maximum base name length to reserve space for these suffixes. Additionally, unit tests are added to verify that long deployment names produce valid, within-limit resource names. I have no feedback to provide as there are no review comments.
Jeffwan
approved these changes
Jul 26, 2026
Jeffwan
left a comment
Collaborator
There was a problem hiding this comment.
overall looks good to me. thanks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request Description
Problem
The Console Kubernetes provider's
generateResourceNameallowed the base resource name to occupy the full 63-character DNS label limit. Callers then append a fixed suffix to derive related resources — most importantly the Service, namedresourceName + "-svc". When the base already filled 63 characters, the Service name reached 67 and the API server rejected it:Because the Deployment is created first, the request failed with HTTP 500 after the Deployment already existed (the rollback removed the Deployment, but the otherwise-valid user-facing request still failed).
Fix
generateResourceNamenow reserves room for the longest suffix appended to the base name (the Service's-svc) in addition to the prefix, the joining dash, and the unique suffix — so every derived name stays within the limit. To make the invariant explicit and drift-proof (the root cause was the generator not knowing about the suffix callers append), the magic values are extracted into named constants and the"-svc"literal is replaced withserviceNameSuffixat every use site:maxResourceNameLength(63),resourceNamePrefix(aibrix-),resourceNameUniqueSuffixLength(8),serviceNameSuffix(-svc)maxResourceNameLength - len(prefix) - len("-") - suffixLen - len(serviceNameSuffix)before the unique suffix is appended, and the random suffix is always preserved.Deployment and HPA names use the base name directly (no appended suffix), so they were already within the limit and remain so.
Testing
go test ./apps/console/api/deployment/provider/...,go vet,gofmt, andgo build ./apps/console/...all pass. Added two tests (verified they fail without the fix):TestGenerateResourceNameDerivedNamesStayWithinKubernetesLimit— table test over names below, at, and above the boundary (incl. the 100-char case from the report). Asserts the finalresourceName + "-svc"— not just the base — is a valid label viavalidation.IsDNS1035Label, and that the unique suffix survives truncation.TestCreateWithLongNameProducesValidKubernetesResourceNames— end-to-endCreatewith a 100-character name that asserts the actual created Deployment, Service, and HPA object names are valid DNS labels. (The fake client does not enforce API-server name validation, so names are validated explicitly, as the issue suggests.)Acceptance criteria
resourceName + "-svc", not only the base name.Related Issues
Resolves: #2493