From 79f9b5f92c63604e1ded0997d5539bcf26d0d52a Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Mon, 21 Jul 2025 22:20:37 -0700 Subject: [PATCH] Add AWS_DEBUG env variable for debugging S3 in Workhorse This helped troubleshoot S3 compatibility issues for https://gitlab.com/gitlab-org/gitlab/-/merge_requests/198371. Changelog: added --- .../internal/upload/destination/objectstore/s3_client.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/workhorse/internal/upload/destination/objectstore/s3_client.go b/workhorse/internal/upload/destination/objectstore/s3_client.go index ca8e05c5feb2ba..210504ad396b29 100644 --- a/workhorse/internal/upload/destination/objectstore/s3_client.go +++ b/workhorse/internal/upload/destination/objectstore/s3_client.go @@ -2,6 +2,7 @@ package objectstore import ( "context" + "os" "sync" "time" @@ -39,6 +40,7 @@ var ( // hours. To be safe, refresh AWS clients every 10 minutes. clientExpiration = 10 * time.Minute clientCache = &s3ClientCache{clients: make(map[config.S3Config]*s3Client)} + awsDebugEnabled = os.Getenv("AWS_DEBUG") == "1" ) func (c *s3Client) isExpired() bool { @@ -72,6 +74,10 @@ func setupS3Client(s3Credentials config.S3Credentials, s3Config config.S3Config) ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) // lint:allow context.Background defer cancel() + if awsDebugEnabled { + options = append(options, awsConfig.WithClientLogMode(aws.LogRetries|aws.LogRequest|aws.LogResponse)) + } + cfg, err := awsConfig.LoadDefaultConfig(ctx, options...) if err != nil { return nil, err -- GitLab