Skip to content

Commit

Permalink
proxy: add last route id to the 'max loopbacks reached' error (#2894)
Browse files Browse the repository at this point in the history
Keep `max loopbacks reached` part of the error message intact in case
someone greps logs for it.

Signed-off-by: Alexander Yastrebov <[email protected]>
  • Loading branch information
AlexanderYastrebov authored Jan 29, 2024
1 parent 178b97d commit f4db475
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,16 @@ type Params struct {
}

type (
maxLoopbackError string
ratelimitError string
routeLookupError string
)

func (e maxLoopbackError) Error() string { return string(e) }
func (e ratelimitError) Error() string { return string(e) }
func (e routeLookupError) Error() string { return string(e) }

const (
errMaxLoopbacksReached = maxLoopbackError("max loopbacks reached")
errRatelimit = ratelimitError("ratelimited")
errRouteLookup = routeLookupError("route lookup failed")
errRatelimit = ratelimitError("ratelimited")
errRouteLookup = routeLookupError("route lookup failed")
)

var (
Expand Down Expand Up @@ -1052,8 +1049,11 @@ func (p *Proxy) do(ctx *context, parentSpan ot.Span) (err error) {

if ctx.executionCounter > p.maxLoops {
// TODO(sszuecs): think about setting status code to 463 or 465 (check what AWS ALB sets for redirect loop) or similar
p.makeErrorResponse(ctx, &proxyError{err: errMaxLoopbacksReached})
return errMaxLoopbacksReached
perr := &proxyError{
err: fmt.Errorf("max loopbacks reached after route %s", ctx.route.Id),
}
p.makeErrorResponse(ctx, perr)
return perr
}

// proxy global setting
Expand Down

0 comments on commit f4db475

Please sign in to comment.