Skip to content

Conversation

ScheererJ
Copy link
Member

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-related Shoot 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 during Shoot 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 of ExposureClass 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 the ExposureClass feature is not widely used.

Release note:

The name of `ExposureClass` resources is now properly checked to be compliant to the DNS label rules.
`spec.networking.type` is now validated as being a label name.
`spec.systemComponents.coreDNS.rewriting.commonSuffixes` are now validated against DNS rules.
`spec.addons.nginxIngress.loadBalancerSourceRanges` are now validated as CIDRs.
`spec.addons.nginxIngress.config` is now validated as conforming to config map data rules.

The value is used as part of a label name. Hence, it can only contain
certain characters and has a limited length.
@gardener-prow gardener-prow bot added the area/networking Networking related label Jul 16, 2025
@gardener-prow gardener-prow bot requested review from LucaBernstein and timuthy July 16, 2025 08:17
@gardener-prow gardener-prow bot added area/quality Output qualification (tests, checks, scans, automation in general, etc.) related area/robustness Robustness, reliability, resilience related area/security Security related kind/enhancement Enhancement, improvement, extension cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 16, 2025
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`.
@ScheererJ ScheererJ force-pushed the enhancement/networking-input-validation branch from ee4b6a7 to a1f1fe9 Compare July 16, 2025 09:12
Copy link
Member

@marc1404 marc1404 left a 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

Comment on lines 959 to +961
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 {
Copy link
Member

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

@gardener-prow gardener-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jul 16, 2025
Copy link
Contributor

gardener-prow bot commented Jul 16, 2025

LGTM label has been added.

Git tree hash: 90998fa8a07fd141b2119959bda9f2349c5e1e1e

@oliver-goetz
Copy link
Member

/assign

Copy link
Member

@marc1404 marc1404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

Copy link
Contributor

gardener-prow bot commented Aug 5, 2025

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gardener-prow gardener-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 5, 2025
@gardener-prow gardener-prow bot merged commit 01ce1f0 into gardener:master Aug 5, 2025
19 checks passed
Duciwuci pushed a commit to stackitcloud/gardener that referenced this pull request Sep 1, 2025
…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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/networking Networking related area/quality Output qualification (tests, checks, scans, automation in general, etc.) related area/robustness Robustness, reliability, resilience related area/security Security related cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. kind/enhancement Enhancement, improvement, extension lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants