Skip to content
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

feat: validate HTTPRoute features #5312

Merged
merged 2 commits into from
Dec 12, 2023
Merged

Conversation

randmonkey
Copy link
Contributor

@randmonkey randmonkey commented Dec 8, 2023

What this PR does / why we need it:

Validate features in spec of HTTPRoute and reject the HTTPRoutes using unspported features.

Which issue this PR fixes:

fixes #5253

Special notes for your reviewer:

PR Readiness Checklist:

Complete these before marking the PR as ready to review:

  • the CHANGELOG.md release notes have been updated to reflect any significant (and particularly user-facing) changes introduced by this PR

@randmonkey randmonkey requested a review from a team as a code owner December 8, 2023 03:37
@randmonkey randmonkey marked this pull request as draft December 8, 2023 03:38
@randmonkey randmonkey added the work in progress Work In Progress label Dec 8, 2023
@randmonkey randmonkey added this to the KIC v3.1.x milestone Dec 8, 2023
Copy link

codecov bot commented Dec 8, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (00b12e1) 75.9% compared to head (9ea2db1) 76.0%.

Files Patch % Lines
internal/admission/validation/gateway/httproute.go 92.0% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #5312   +/-   ##
=====================================
  Coverage   75.9%   76.0%           
=====================================
  Files        170     170           
  Lines      19549   19589   +40     
=====================================
+ Hits       14845   14894   +49     
+ Misses      3865    3858    -7     
+ Partials     839     837    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@randmonkey randmonkey force-pushed the feat/validate_httproute_features branch from 27bfcd8 to a20e8a5 Compare December 8, 2023 08:45
@randmonkey randmonkey marked this pull request as ready for review December 8, 2023 08:50
@randmonkey randmonkey removed the work in progress Work In Progress label Dec 8, 2023
@randmonkey randmonkey changed the title [WIP] feat: validate HTTPRoute features feat: validate HTTPRoute features Dec 8, 2023
@randmonkey randmonkey self-assigned this Dec 8, 2023
Copy link
Member

@mlavacca mlavacca left a comment

Choose a reason for hiding this comment

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

I left some comments in the PR. In addition to them, I'd suggest that we keep the validateHTTPRouteFeatures function for real features validation (timeouts, filters, etc.) and we extract parentRefs group/kind and backendRefs group/kind validation into proper functions, as I do not think they are not proper "features", but instead accepted values for specific fields. What do you think?

internal/admission/handler.go Outdated Show resolved Hide resolved
internal/admission/validation/gateway/httproute.go Outdated Show resolved Hide resolved
internal/admission/validation/gateway/httproute.go Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
@randmonkey
Copy link
Contributor Author

I left some comments in the PR. In addition to them, I'd suggest that we keep the validateHTTPRouteFeatures function for real features validation (timeouts, filters, etc.) and we extract parentRefs group/kind and backendRefs group/kind validation into proper functions, as I do not think they are not proper "features", but instead accepted values for specific fields. What do you think?

I prefer to extract the validation of ParentRefs in HTTPRoutes out because this should be validated before we fetch the gateway from parentRefs. So we have the reason to extract it out and run it before validating process reaches validateHTTPRouteFeatures which is run after we found the gateway to attach to.

But I think supported kinds of backend is also a "feature". Consider that in some future versions we also support KongServiceFacade or other kinds of backends, I think we should put the validation of supported backend kinds in validating features. Also, we have a rule that filters in backendRefs is not supported, which should also be checked in validating features. Extracting checking of group/kinds will run 2 loops on checking each backendRefs, which does not simplify the validation process.

@randmonkey randmonkey merged commit 9982654 into main Dec 12, 2023
47 checks passed
@randmonkey randmonkey deleted the feat/validate_httproute_features branch December 12, 2023 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate all HTTPRoute features
3 participants