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

Add support for redirect filters #249

Merged
merged 5 commits into from
Sep 7, 2022

Conversation

AliceProxy
Copy link
Member

@AliceProxy AliceProxy commented Aug 25, 2022

Adds support for gateway API Redirect Filters.
This is my first PR to the repo so feedback is greatly appreciated .

Fixes: #159

@AliceProxy AliceProxy requested a review from a team as a code owner August 25, 2022 21:23
@codecov-commenter
Copy link

codecov-commenter commented Aug 25, 2022

Codecov Report

Merging #249 (8b52e35) into main (a958828) will increase coverage by 1.22%.
The diff coverage is 63.66%.

@@            Coverage Diff             @@
##             main     #249      +/-   ##
==========================================
+ Coverage   58.12%   59.34%   +1.22%     
==========================================
  Files          31       32       +1     
  Lines        2832     3215     +383     
==========================================
+ Hits         1646     1908     +262     
- Misses       1087     1199     +112     
- Partials       99      108       +9     
Impacted Files Coverage Δ
internal/ir/zz_generated.deepcopy.go 0.00% <0.00%> (ø)
internal/gatewayapi/translator.go 84.36% <79.54%> (-1.08%) ⬇️
internal/xds/translator/route.go 46.37% <90.19%> (+22.20%) ⬆️
internal/ir/xds.go 83.08% <100.00%> (+7.04%) ⬆️
internal/infrastructure/kubernetes/infra.go 52.23% <0.00%> (-6.10%) ⬇️
internal/gatewayapi/contexts.go 76.77% <0.00%> (-1.52%) ⬇️
internal/provider/kubernetes/gatewayclass.go 67.54% <0.00%> (-1.37%) ⬇️
internal/utils/env/env.go 100.00% <0.00%> (ø)
internal/infrastructure/kubernetes/deployment.go 83.24% <0.00%> (+1.07%) ⬆️
... and 3 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@AliceProxy AliceProxy force-pushed the alicewasko/dev/support-redirects branch from 91a8d4b to c6ac729 Compare August 25, 2022 22:12
@AliceProxy AliceProxy changed the title [WIP] Add support for redirect filters Add support for redirect filters Aug 26, 2022
@danehans
Copy link
Contributor

@AliceProxy please rebase when you have a moment.

@AliceProxy AliceProxy force-pushed the alicewasko/dev/support-redirects branch 2 times, most recently from 5805f4e to af23eca Compare August 30, 2022 20:08
@danehans danehans added the area/translator Issues related to Gateway's translation service, e.g. translating Gateway APIs into the IR. label Aug 30, 2022
@danehans danehans added this to the 0.2.0-rc2 milestone Aug 30, 2022
@skriss skriss self-requested a review August 30, 2022 22:11
@AliceProxy AliceProxy force-pushed the alicewasko/dev/support-redirects branch 2 times, most recently from bc7d2b7 to 3a6b523 Compare August 30, 2022 23:50
@AliceProxy
Copy link
Member Author

Sorry about the recent pushes. I thought I was done with this but realized there were some problems that I needed to fix and I added some better test coverage.

@danehans
Copy link
Contributor

@skriss do you mind reviewing since you have a good understanding of this code?

@danehans
Copy link
Contributor

danehans commented Sep 1, 2022

@AliceProxy can you investigate the CI failure?

@skriss
Copy link
Contributor

skriss commented Sep 1, 2022

Yep it's on my list to review, just need to find some time!

@AliceProxy
Copy link
Member Author

@AliceProxy can you investigate the CI failure?

@danehans The most recent commit should resolve the CI failure.

@AliceProxy AliceProxy force-pushed the alicewasko/dev/support-redirects branch from 940c169 to 037147f Compare September 1, 2022 22:25
internal/ir/xds.go Outdated Show resolved Hide resolved
Copy link
Contributor

@skriss skriss left a comment

Choose a reason for hiding this comment

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

Thanks @AliceProxy, overall this looks great! Had a few initial comments, still looking through the test cases.

internal/gatewayapi/translator.go Outdated Show resolved Hide resolved
internal/gatewayapi/translator.go Outdated Show resolved Hide resolved
internal/gatewayapi/translator.go Outdated Show resolved Hide resolved
internal/gatewayapi/translator.go Outdated Show resolved Hide resolved
internal/gatewayapi/translator.go Outdated Show resolved Hide resolved
internal/ir/xds.go Outdated Show resolved Hide resolved
@skriss
Copy link
Contributor

skriss commented Sep 6, 2022

One other note, just for future reference - our initial goal for EG is to meet "core" Gateway API conformance. As such, I think it'd be fine to start by only implementing the parts of these filters that are required for core conformance, and save "extended" features for later (that's the approach that's been taken with most of the existing Gateway API code). It might help keep the PRs a bit smaller.

Comment on lines 649 to 650
redirectPort := uint32(*redirect.Port)
irRedirect.Port = &redirectPort
Copy link
Contributor

Choose a reason for hiding this comment

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

We're ending up with a lot of silly code that looks like this. Perhaps we should add a utility function

func ptrTo[T any](x T) *T {
    return &x
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Very true, but I kind of feel like this should be a separate PR after this just to keep the logical size smaller.

@arkodg
Copy link
Contributor

arkodg commented Sep 6, 2022

@AliceProxy thanks for adding the tests in the IR and xDS libs ! LGTM from my end wrt code in those libs, hoping others can review the gatewayapi/translator diffs

Signed-off-by: AliceProxy <alicewasko@datawire.io>
Signed-off-by: AliceProxy <alicewasko@datawire.io>
Signed-off-by: AliceProxy <alicewasko@datawire.io>
Signed-off-by: AliceProxy <alicewasko@datawire.io>
Signed-off-by: AliceProxy <alicewasko@datawire.io>
Copy link
Contributor

@skriss skriss left a comment

Choose a reason for hiding this comment

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

LGTM! Will leave for other reviewers to merge when ready.

Comment on lines +84 to +85
# I believe the correct way to handle an invalid filter should be to allow the HTTPRoute to function
# normally but leave out the filter config and set the status, but this behaviour can be changed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think the expected behavior here is unclear in the Gateway API spec -- we can drive some clarity upstream, but doesn't need to block this PR now.

@AliceProxy AliceProxy requested review from arkodg and LukeShu and removed request for arkodg and LukeShu September 7, 2022 20:56
@arkodg arkodg merged commit b0920a6 into envoyproxy:main Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/translator Issues related to Gateway's translation service, e.g. translating Gateway APIs into the IR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add support for request redirect filter
6 participants