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
Changes from 2 commits
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/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/google/wire"
"go.opencensus.io/trace"
"go.uber.org/zap"
"google.golang.org/api/support/bundler"
grpccode "google.golang.org/grpc/codes"
grpcstatus "google.golang.org/grpc/status"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -174,6 +175,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, bundler.ErrOverflow):
statusCode = nethttp.StatusTooManyRequests
case grpcstatus.Code(res) == grpccode.PermissionDenied:
nethttp.Error(response, deniedErrMsg, statusCode)
return
Expand Down