-
Notifications
You must be signed in to change notification settings - Fork 567
OCPBUGS-87991: validate additionalNetworks name format in KubeVirt NodePools #8710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,6 +169,8 @@ type KubevirtNodePoolPlatform struct { | |
| // additionalNetworks specify the extra networks attached to the nodes | ||
| // | ||
| // +optional | ||
| // +listType=map | ||
| // +listMapKey=name | ||
| // +kubebuilder:validation:MaxItems=20 | ||
| AdditionalNetworks []KubevirtNetwork `json:"additionalNetworks,omitempty"` | ||
|
|
||
|
|
@@ -198,8 +200,14 @@ type KubevirtNodePoolPlatform struct { | |
| type KubevirtNetwork struct { | ||
| // name specify the network attached to the nodes | ||
| // it is a value with the format "[namespace]/[name]" to reference the | ||
| // multus network attachment definition | ||
| // +kubebuilder:validation:MaxLength=255 | ||
| // multus network attachment definition, where namespace and name consist | ||
| // only of lowercase alphanumeric characters and hyphens, and start and | ||
| // end with alphanumeric characters | ||
| // +kubebuilder:validation:MaxLength=55 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't this regress existing clusters?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No — CRD validation ratcheting (GA since K8s 1.28; HyperShift requires ≥1.30) protects existing clusters:
The net effect is moving the failure left from silent runtime failure to clear admission rejection, with ratcheting ensuring existing deployments are unaffected on upgrade.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the explanation! |
||
| // MaxLength=55: KubeVirt requires Interface.Name to be a DNS label (max 63 chars). | ||
| // The generated name is "iface{N}_{namespace}-{name}" where N≤20 (MaxItems), | ||
| // giving a max prefix of "iface20_" (8 chars), leaving 55 chars for namespace/name. | ||
| // +kubebuilder:validation:XValidation:rule="self.matches('^[a-z0-9]([a-z0-9-]*[a-z0-9])?/[a-z0-9]([a-z0-9-]*[a-z0-9])?$')",message="name must be in the format <namespace>/<name> where namespace and name consist only of lowercase alphanumeric characters and hyphens, and start and end with alphanumeric characters" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is good, can we also get this style explanation of the format in the godoc itself so that |
||
| // +required | ||
| Name string `json:"name"` | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.