From ba8a8ad81823c780e1d4801b70e048fa4398f3c4 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Mon, 31 Aug 2020 20:37:31 +0100 Subject: [PATCH] ListObjectsV1 requests unnecessarily fail with offline nodes (#10386) ListObjectsV1 requests are actually redirected to a specific node, depending on the bucket name. The purpose of this behavior was to optimize listing. However, the current code sends a Bad Gateway error if the target node is offline, which is a bad behavior because it means that the list request will fail, although this is unnecessary since we can still use the current node to list as well (the default behavior without using proxying optimization) Currently, you can see mint fails when there is one offline node, after this PR, mint will always succeed. --- cmd/handler-utils.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/handler-utils.go b/cmd/handler-utils.go index a4bc7079b..d27f48b71 100644 --- a/cmd/handler-utils.go +++ b/cmd/handler-utils.go @@ -19,6 +19,7 @@ package cmd import ( "bytes" "context" + "errors" "fmt" "io" "io/ioutil" @@ -498,10 +499,9 @@ func proxyRequest(ctx context.Context, w http.ResponseWriter, r *http.Request, e RoundTripper: ep.Transport, ErrorHandler: func(w http.ResponseWriter, r *http.Request, err error) { success = false - w.WriteHeader(http.StatusBadGateway) - }, - Logger: func(err error) { - logger.LogIf(GlobalContext, err) + if err != nil && !errors.Is(err, context.Canceled) { + logger.LogIf(GlobalContext, err) + } }, })