From c2f25b6f625490e9921bcc0a2633dcb4f86b0e65 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Sat, 11 Sep 2021 17:20:01 +0100 Subject: [PATCH] gateway/s3: allow tracing requests to backend service (#13189) fixes #13089 fixes #13133 Co-authored-by: Anis Elleuch Co-authored-by: Harshavardhana --- cmd/gateway-main.go | 1 - cmd/gateway/s3/gateway-s3.go | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/gateway-main.go b/cmd/gateway-main.go index 4e84ef2d1..1190572a7 100644 --- a/cmd/gateway-main.go +++ b/cmd/gateway-main.go @@ -280,7 +280,6 @@ func StartGateway(ctx *cli.Context, gw Gateway) { SecretKey: globalActiveCred.SecretKey, }) if err != nil { - globalHTTPServer.Shutdown() logger.FatalIf(err, "Unable to initialize gateway backend") } newObject = NewGatewayLayerWithLocker(newObject) diff --git a/cmd/gateway/s3/gateway-s3.go b/cmd/gateway/s3/gateway-s3.go index f5325d06f..5f0946656 100644 --- a/cmd/gateway/s3/gateway-s3.go +++ b/cmd/gateway/s3/gateway-s3.go @@ -23,6 +23,7 @@ import ( "math/rand" "net/http" "net/url" + "os" "strings" "time" @@ -34,9 +35,11 @@ import ( "github.com/minio/minio-go/v7/pkg/s3utils" "github.com/minio/minio-go/v7/pkg/tags" minio "github.com/minio/minio/cmd" + "github.com/minio/minio/internal/config" xhttp "github.com/minio/minio/internal/http" "github.com/minio/minio/internal/logger" "github.com/minio/pkg/bucket/policy" + "github.com/minio/pkg/env" ) func init() { @@ -94,12 +97,16 @@ func s3GatewayMain(ctx *cli.Context) { logger.FatalIf(minio.ValidateGatewayArguments(serverAddr, args.First()), "Invalid argument") // Start the gateway.. - minio.StartGateway(ctx, &S3{args.First()}) + minio.StartGateway(ctx, &S3{ + host: args.First(), + debug: env.Get("_MINIO_SERVER_DEBUG", config.EnableOff) == config.EnableOn, + }) } // S3 implements Gateway. type S3 struct { - host string + host string + debug bool } // Name implements Gateway interface. @@ -219,6 +226,10 @@ func (g *S3) NewGatewayLayer(creds madmin.Credentials) (minio.ObjectLayer, error return nil, err } + if g.debug { + clnt.Client.TraceOn(os.Stderr) + } + probeBucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "probe-bucket-sign-") // Check if the provided keys are valid.