-
Notifications
You must be signed in to change notification settings - Fork 347
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
impl: custom error response #4415
impl: custom error response #4415
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4415 +/- ##
==========================================
+ Coverage 65.85% 65.97% +0.11%
==========================================
Files 202 203 +1
Lines 30679 31154 +475
==========================================
+ Hits 20205 20555 +350
- Misses 9320 9415 +95
- Partials 1154 1184 +30 ☔ View full report in Codecov by Sentry. |
fce9138
to
c0cb97e
Compare
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
51b0e4a
to
0631fa4
Compare
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
if ro.Response.Body.Type != nil && *ro.Response.Body.Type == egv1a1.ResponseValueTypeValueRef { | ||
foundCM := false | ||
for _, cm := range configMaps { | ||
if cm.Namespace == policy.Namespace && cm.Name == string(ro.Response.Body.ValueRef.Name) { |
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.
is this a ptr, will it work for default
?
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.
if *ro.Response.Body.Type == egv1a1.ResponseValueTypeValueRef, then ro.Response.Body.ValueRef is not nil, otherwise, it would be a bug in Gateway API translation.
...nal/gatewayapi/testdata/backendtrafficpolicy-with-response-override-invalid-valueref.in.yaml
Show resolved
Hide resolved
name: cel-matcher | ||
typedConfig: | ||
'@type': type.googleapis.com/xds.type.matcher.v3.CelMatcher | ||
exprMatch: |
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.
👀
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.
trusting the e2e, this API is complex, thanks for implementing this !
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.
The Envoy CEL matcher API is terrible :-) It's the AST for CEL: response.code >= 501 && response.code <= 511
.
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.
LGTM ! implementing the feature using the custom response filter doesnt look easy, thanks for building this out
@@ -124,6 +124,8 @@ type EnvoyProxySpec struct { | |||
// | |||
// - envoy.filters.http.ratelimit | |||
// | |||
// - envoy.filters.http.custom_response |
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.
is it possible to override the 429 response if we place custom response filter behind ratelimit filterm should this filter be the first one of http filters?
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.
Good point. Should we allow users to override the ratelimit response if they added a matching conditing for 429 in the ResponseOrverride
? @envoyproxy/gateway-maintainers
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.
it's not just ratelimit, does authz/authn has same problem?
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.
Yeah, the custom response filter has been added to the last because users may want to override the direct responses generated by other filters, if they explicitly adding these status codes in the matching conditions. For example, to set the response body of a denide request to a message format algined with the style of the reponses of the applications.
If we put it at the first, the users won't be able to override them even if they intend to.
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.
IMO, it's better to put it at the first but no strong option, @arkodg please chime in as API designer.
cc @envoyproxy/gateway-maintainers
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.
as a user, I would want the custom response to kick in after all filters have finished processing, to unify the way I deal with status code and error pages, so +1 to adding it to the end
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.
we can change the order in the future, maybe we can open a ticket to continue our discussion.
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.
we can change the order in the future, maybe we can open a ticket to continue our discussion.
Let's keep the custom response filter at the last since there're use cases to override the responses of other filters. Users can change the default order using EnvoyProxy
if they want to reorder the filters.
@zhaohuabing can you make CI happy? |
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
e2es are failing ... |
Implement: #4259
Issue: #1400