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: Multiple RequestMirrors Filters per HTTPRoute Rule #1819

Merged
merged 15 commits into from
Sep 17, 2023

Conversation

Ronnie-personal
Copy link
Contributor

What type of PR is this?

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #1811

draft coding

Signed-off-by: Ronnie Personal <[email protected]>
@Ronnie-personal
Copy link
Contributor Author

@arkodg
Could you please take a quick look at this initial draft code change? Am I heading in the right direction?
I will spend more time on the testing.

@@ -76,7 +76,7 @@ func (t *Translator) ProcessHTTPFilters(parentRef *RouteParentContext,
RuleIdx: ruleIdx,
HTTPFilterIR: &HTTPFilterIR{},
}

filterIdx := 0
for i := range filters {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just use i

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why not just use i

Yes, I can use 'i' if I don't need to match the value with the index of Mirror list.

@@ -839,22 +842,26 @@ func (t *Translator) processRequestMirrorFilter(
// Only add missing mirror destinations
Copy link
Contributor

Choose a reason for hiding this comment

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

imo this entire logic of adding missing mirror destinations can be removed, and so you can simplify this logic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

imo this entire logic of adding missing mirror destinations can be removed, and so you can simplify this logic

Are we building filterContext.Mirror from scratch and there is no duplicate Endpoints?
I definitely can refactor the code based on your assessment.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes we dont need to consider the duplicate case, please go ahead and refactor

internal/ir/xds.go Outdated Show resolved Hide resolved
@arkodg
Copy link
Contributor

arkodg commented Aug 23, 2023

looks good @Ronnie-personal , added some comments, thanks for picking this one up

Signed-off-by: Ronnie Personal <[email protected]>
@codecov
Copy link

codecov bot commented Aug 25, 2023

Codecov Report

Merging #1819 (93cc046) into main (1f08e46) will decrease coverage by 0.02%.
The diff coverage is 57.44%.

@@            Coverage Diff             @@
##             main    #1819      +/-   ##
==========================================
- Coverage   66.14%   66.13%   -0.02%     
==========================================
  Files          86       86              
  Lines       12874    12868       -6     
==========================================
- Hits         8516     8510       -6     
  Misses       3830     3830              
  Partials      528      528              
Files Changed Coverage Δ
internal/ir/zz_generated.deepcopy.go 13.47% <0.00%> (-0.07%) ⬇️
internal/ir/xds.go 73.68% <40.00%> (+0.07%) ⬆️
internal/xds/translator/route.go 90.80% <69.23%> (+0.03%) ⬆️
internal/xds/translator/translator.go 79.92% <72.72%> (+0.07%) ⬆️
internal/gatewayapi/filters.go 79.90% <83.33%> (-0.40%) ⬇️
internal/gatewayapi/route.go 88.38% <100.00%> (ø)

... and 2 files with indirect coverage changes

Signed-off-by: Ronnie Personal <[email protected]>
@Ronnie-personal
Copy link
Contributor Author

/retest

1 similar comment
@Ronnie-personal
Copy link
Contributor Author

/retest

@Ronnie-personal
Copy link
Contributor Author

Can anyone help me to understand this pipeline error at https://github.com/envoyproxy/gateway/actions/runs/5971186116/job/16224598674?pr=1819#step:6:140?

I tested 'make -k lint' locally, I don't see the error.

@arkodg
Copy link
Contributor

arkodg commented Aug 28, 2023

here is the error

./internal/xds/translator/testdata/in/xds-ir/http-route-mirror.yaml
[127](https://github.com/envoyproxy/gateway/actions/runs/5971186116/job/16224598674?pr=1819#step:6:128)
  Error: 17:7 [indentation] wrong indentation: expected 4 but found 6

@Ronnie-personal
Copy link
Contributor Author

here is the error

./internal/xds/translator/testdata/in/xds-ir/http-route-mirror.yaml
[127](https://github.com/envoyproxy/gateway/actions/runs/5971186116/job/16224598674?pr=1819#step:6:128)
  Error: 17:7 [indentation] wrong indentation: expected 4 but found 6

Thank you! I will fix it.

Signed-off-by: Ronnie Personal <[email protected]>
Signed-off-by: Ronnie Personal <[email protected]>
@Ronnie-personal
Copy link
Contributor Author

/retest

@Ronnie-personal
Copy link
Contributor Author

What's happening with the pipeline? it only executed one check.

Signed-off-by: Ronnie Personal <[email protected]>
Signed-off-by: Ronnie Personal <[email protected]>
@Ronnie-personal
Copy link
Contributor Author

/retest

@Ronnie-personal Ronnie-personal marked this pull request as ready for review September 1, 2023 00:24
@Ronnie-personal Ronnie-personal requested a review from a team as a code owner September 1, 2023 00:24
@@ -261,7 +261,7 @@ type HTTPRoute struct {
// Redirections to be returned for this route. Takes precedence over Destinations.
Redirect *Redirect `json:"redirect,omitempty" yaml:"redirect,omitempty"`
// Destination that requests to this HTTPRoute will be mirrored to
Mirror *RouteDestination `json:"mirror,omitempty" yaml:"mirror,omitempty"`
Mirror []*RouteDestination `json:"mirrors,omitempty" yaml:"mirrors,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Mirror []*RouteDestination `json:"mirrors,omitempty" yaml:"mirrors,omitempty"`
Mirrors []*RouteDestination `json:"mirrors,omitempty" yaml:"mirrors,omitempty"`

@@ -13,7 +13,10 @@ http:
endpoints:
- host: "1.2.3.4"
port: 50000
mirror:
name: "mirror-route-dest"
mirrors:
Copy link
Contributor

Choose a reason for hiding this comment

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

lets keep this example as is, and create one more test file for multiple-mirrors ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sound good, will do.

}
filterContext.Mirror = append(filterContext.Mirror, newMirror)
// Get the index of the last mirror added
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need L842-L844, can't we just assign Endpoints on L839 when creating RouteDestination ?

@Ronnie-personal Ronnie-personal marked this pull request as draft September 13, 2023 15:23
Signed-off-by: Ronnie-personal <[email protected]>
@Ronnie-personal Ronnie-personal marked this pull request as ready for review September 16, 2023 13:06
@zirain
Copy link
Contributor

zirain commented Sep 16, 2023

@Ronnie-personal can you remove following line, let's check with CI?

@Ronnie-personal
Copy link
Contributor Author

@Ronnie-personal can you remove following line, let's check with CI?

Sorry, which line do you want to remove?

@zirain
Copy link
Contributor

zirain commented Sep 16, 2023

should be

// TODO: Remove once https://github.com/envoyproxy/gateway/issues/1811 is fixed
tests.HTTPRouteRequestMultipleMirrors.ShortName,

@Ronnie-personal
Copy link
Contributor Author

should be

// TODO: Remove once https://github.com/envoyproxy/gateway/issues/1811 is fixed
tests.HTTPRouteRequestMultipleMirrors.ShortName,

Thanks, I'm working on it right now.

Do we also need to remove https://github.com/envoyproxy/gateway/blob/main/test/conformance/experimental_conformance_test.go#L96

Signed-off-by: Ronnie-personal <[email protected]>
Copy link
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

LGTM thanks !

@zirain zirain merged commit 14a395a into envoyproxy:main Sep 17, 2023
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Multiple RequestMirror filters per HTTPRoute Rule
3 participants