design: Kubernetes name length enforcement for Velero-created objects (#8815)#9770
design: Kubernetes name length enforcement for Velero-created objects (#8815)#9770kaovilai wants to merge 1 commit into
Conversation
…-io#8815) Audit found 12 name-length bugs across 5 categories and 3 GenerateName sites missing CreateRetryGenerateName. Design covers new helper functions GetValidGenerateName and GetValidObjectName, all fix sites, compatibility analysis, and alignment with KEP 4420 retry behavior. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering> Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Adds a design document proposing a consistent approach for preventing Velero-created Kubernetes objects (and labels/selectors) from exceeding Kubernetes name/label length limits, including refactoring/centralizing name truncation logic and enumerating affected call sites.
Changes:
- Introduces a design doc for issue #8815 describing name-length enforcement across multiple object/label patterns.
- Proposes new helper APIs (
GetValidGenerateName,GetValidObjectName) built on a shared implementation alongsideGetValidName. - Catalogs impacted call sites (name-length fixes +
CreateRetryGenerateNameconsistency) and outlines an implementation/test plan.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Any Velero deployment that encountered these bugs received a Kubernetes API error at object creation time and the backup or restore operation failed. | ||
| No such object was ever persisted in etcd because Kubernetes itself enforces name limits at admission. | ||
| There are therefore no existing objects to migrate. |
There was a problem hiding this comment.
The “Objects that previously failed to create” compatibility claim is too broad: the Category E RestoreNameLabel selector mismatch can occur even when object creation succeeds (label value is hashed to ≤63), leaving persisted objects that are just not found by the current selector. Consider narrowing this section to only the admission-rejected cases (name/label values exceeding max length) and explicitly calling out that Category E is a lookup bug against existing objects rather than a creation failure.
| Any Velero deployment that encountered these bugs received a Kubernetes API error at object creation time and the backup or restore operation failed. | |
| No such object was ever persisted in etcd because Kubernetes itself enforces name limits at admission. | |
| There are therefore no existing objects to migrate. | |
| For the admission-rejected cases in this design—object names, `GenerateName` prefixes, or raw label values that exceed Kubernetes maximum lengths—Velero receives a Kubernetes API error at object creation time and the backup or restore operation fails. | |
| In those cases, no such object is ever persisted in etcd because Kubernetes enforces these limits at admission, so there are no admission-rejected objects to migrate. | |
| Category E is different: it is a lookup bug against existing objects, where creation can succeed because the persisted `RestoreNameLabel` value is already bounded (for example, hashed to fit within 63 characters) but the current selector does not match that stored value. |
Summary
CreateRetryGenerateNamecollision-retry wrapper.GetValidGenerateName,GetValidObjectName) that delegate to a shared privategetValidNameWithMaxLen, refactoring the existingGetValidNameto use the same helper. All affected call sites are enumerated with before/after.Design highlights
GetValidName) preserves uniqueness for distinct long names.crClient.Createtoveleroclient.CreateRetryGenerateName, aligning with KEP 4420 intent.Test plan
design/8815-kubernetes-name-length-enforcement_design.mdNote
Responses generated with Claude