-
Notifications
You must be signed in to change notification settings - Fork 389
fix: proxy filter panics did not run applyFiltersOnError #3969
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -906,7 +906,7 @@ func WithParams(p Params) *Proxy { | |
| } | ||
|
|
||
| // applies filters to a request | ||
| func (p *Proxy) applyFiltersToRequest(f []*routing.RouteFilter, ctx *context) []*routing.RouteFilter { | ||
| func (p *Proxy) applyFiltersToRequest(f []*routing.RouteFilter, ctx *context, counter *int) []*routing.RouteFilter { | ||
| if len(f) == 0 { | ||
| return f | ||
| } | ||
|
|
@@ -927,6 +927,7 @@ func (p *Proxy) applyFiltersToRequest(f []*routing.RouteFilter, ctx *context) [] | |
| ctx.request = ctx.request.WithContext(labelCtx) | ||
|
|
||
| fi.Request(ctx) | ||
| (*counter)++ | ||
|
|
||
| ctx.request = ctx.request.WithContext(parentCtx) | ||
| pprof.SetGoroutineLabels(parentCtx) | ||
|
|
@@ -1246,6 +1247,7 @@ func stack() []byte { | |
|
|
||
| func (p *Proxy) do(ctx *context, parentSpan ot.Span) (err error) { | ||
| var requestElapsed, responseElapsed time.Duration | ||
| processedFiltersCounter := 0 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar to the above comment, shouldn't this be something like
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, same here and "last" would be misleading |
||
|
|
||
| requestStopWatch, responseStopWatch := newStopWatch(), newStopWatch() | ||
| requestStopWatch.Start() | ||
|
|
@@ -1259,6 +1261,10 @@ func (p *Proxy) do(ctx *context, parentSpan ot.Span) (err error) { | |
| perr := &proxyError{ | ||
| err: fmt.Errorf("panic caused by: %v", r), | ||
| } | ||
|
|
||
| if processedFiltersCounter != 0 { | ||
| p.applyFiltersOnError(ctx, ctx.route.Filters[:processedFiltersCounter]) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if we have another panic in this call?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. then we likely panic |
||
| } | ||
| p.makeErrorResponse(ctx, perr) | ||
| err = perr | ||
| } | ||
|
|
@@ -1302,7 +1308,7 @@ func (p *Proxy) do(ctx *context, parentSpan ot.Span) (err error) { | |
| ctx.applyRoute(route, params, p.flags.PreserveHost()) | ||
|
|
||
| requestStopWatch.Stop() | ||
| processedFilters := p.applyFiltersToRequest(ctx.route.Filters, ctx) | ||
| processedFilters := p.applyFiltersToRequest(ctx.route.Filters, ctx, &processedFiltersCounter) | ||
| requestStopWatch.Start() | ||
|
|
||
| // not every of these branches could end up in a response to the client | ||
|
|
||
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.
shouldn't the var name be
indexinstead ofcounter?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.
No because we count number of filters executed in the request path
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.
I got this whole idea that is more like an index is with this,
https://github.com/zalando/skipper/pull/3969/changes#diff-1d74870266949f1927a500e5f0002617239d3e3cd9bcceee6be014738e5e0f2bR1266
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.
I approved the PR, if the suggestion doen't make sense, just ignore it :)