From 2e6525c5c45675304c468fc3dd4a5b713572159e Mon Sep 17 00:00:00 2001 From: fenxiong Date: Wed, 12 Feb 2020 09:41:54 -0800 Subject: [PATCH] Fix missing region error when using Firelens external config. GetBucketLocation returns null for bucket in us-east-1. Return us-east-1 instead of null in that case. --- agent/s3/factory/factory.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/agent/s3/factory/factory.go b/agent/s3/factory/factory.go index ec1531c2f9c..a62f03ff71f 100644 --- a/agent/s3/factory/factory.go +++ b/agent/s3/factory/factory.go @@ -28,7 +28,8 @@ import ( ) const ( - roundtripTimeout = 5 * time.Second + bucketLocationDefault = "us-east-1" + roundtripTimeout = 5 * time.Second ) type S3ClientCreator interface { @@ -69,6 +70,9 @@ func getRegionFromBucket(svc *s3.S3, bucket string) (string, error) { if err != nil { return "", err } + if result.LocationConstraint == nil { // GetBucketLocation returns nil for bucket in us-east-1. + return bucketLocationDefault, nil + } return aws.StringValue(result.LocationConstraint), nil }