Skip to content
This repository has been archived by the owner on Jun 19, 2022. It is now read-only.

Return 429 when ingress if sending too man messages, instead of 500 #1737

Merged
merged 5 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/broker/ingress/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ var ErrIncomplete = errors.New("incomplete config")

// ErrNotReady is the error when a broker is not ready.
var ErrNotReady = errors.New("not ready")

// ErrOverflow is the error when a broker ingress is sending too many requests to PubSub.
var ErrOverflow = errors.New("bundler reached buffered byte limit")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you import bundler.ErrOverflow rather than redefine it here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

2 changes: 2 additions & 0 deletions pkg/broker/ingress/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ func (h *Handler) ServeHTTP(response nethttp.ResponseWriter, request *nethttp.Re
statusCode = nethttp.StatusNotFound
case errors.Is(res, ErrNotReady):
statusCode = nethttp.StatusServiceUnavailable
case errors.Is(res, ErrOverflow):
statusCode = nethttp.StatusTooManyRequests
case grpcstatus.Code(res) == grpccode.PermissionDenied:
nethttp.Error(response, deniedErrMsg, statusCode)
return
Expand Down