-
Notifications
You must be signed in to change notification settings - Fork 526
Improve Input Validation of Networking-related Shoot
fields
#12539
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
Improve Input Validation of Networking-related Shoot
fields
#12539
Conversation
The value is used as part of a label name. Hence, it can only contain certain characters and has a limited length.
The common suffixes used for DNS rewriting should resemble domain names and follow the corresponding rules.
The load balancer source ranges should be valid CIDRs.
Validating the actual content of the config map values is difficult because there are a lot of potential valid values and checking them thoroughly would also cause maintenance effort for each new nginx controller release as they might change. Therefore, this first just checks whether the keys are correct and the size is not too large.
resource. The validation of `ExposureClass` was missing. It is now implemented and forces stricter restrictions on the name of an `ExposureClass`.
ee4b6a7
to
a1f1fe9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for improving the input validation of networking-related fields in the Shoot
spec!
The PR is nicely structured with the commit descriptions 👏
/lgtm
if len(ptr.Deref(networking.Type, "")) == 0 { | ||
allErrs = append(allErrs, field.Required(fldPath.Child("type"), "networking type must be provided")) | ||
allErrs = append(allErrs, field.Required(path, "networking type must be provided")) | ||
} else if len(metav1validation.ValidateLabelName(v1beta1constants.LabelExtensionNetworkingTypePrefix+ptr.Deref(networking.Type, ""), path)) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ptr.Deref(networking.Type, "")
could be extracted into a variable before the if-else
LGTM label has been added. Git tree hash: 90998fa8a07fd141b2119959bda9f2349c5e1e1e
|
/assign |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: marc1404 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…er#12539) * Validate `spec.networking.type` The value is used as part of a label name. Hence, it can only contain certain characters and has a limited length. * Validate `spec.systemComponents.coreDNS.rewriting.commonSuffixes` The common suffixes used for DNS rewriting should resemble domain names and follow the corresponding rules. * Validate `spec.addons.nginxIngress.loadBalancerSourceRanges` The load balancer source ranges should be valid CIDRs. * Validate `spec.addons.nginxIngress.config` Validating the actual content of the config map values is difficult because there are a lot of potential valid values and checking them thoroughly would also cause maintenance effort for each new nginx controller release as they might change. Therefore, this first just checks whether the keys are correct and the size is not too large. * Validate `spec.exposureClassName` and `ObjectMeta` of ExposureClass resource. The validation of `ExposureClass` was missing. It is now implemented and forces stricter restrictions on the name of an `ExposureClass`.
How to categorize this PR?
/area networking
/area quality
/area robustness
/area security
/kind enhancement
What this PR does / why we need it:
Validating the input provided for
Shoot
resources and returning errors early helps cluster owners understand the issues better. Some of the networking-relatedShoot
fields lacked proper validation so that a user received an early error. Most of the issues addressed in this pull request would have led to errors duringShoot
reconciliation later on, but the error messages might not have been good. Therefore, it is better to check properly during admission and return understandable errors related to the corresponding input.The following
Shoot
fields have more validation with this change:spec.networking.type
spec.systemComponents.coreDNS.rewriting.commonSuffixes
spec.addons.nginxIngress.loadBalancerSourceRanges
spec.addons.nginxIngress.config
spec.exposureClassName
In addition to that,
ObjectMeta
ofExposureClass
resource is now checked properly.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
The additional validation of
ExposureClass
is potentially more breaking than the other validations. However, it is considered to be very unlikely that it will actually cause any issues as theExposureClass
feature is not widely used.Release note: