From a921d266c8c8f52713d9b634d8834db9eae4a973 Mon Sep 17 00:00:00 2001 From: jojohappy Date: Wed, 12 Sep 2018 16:48:51 +0800 Subject: [PATCH 1/2] Fixed catch the error when failed to list objects for s3 Signed-off-by: jojohappy --- pkg/objstore/s3/s3.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/objstore/s3/s3.go b/pkg/objstore/s3/s3.go index 1e54812c64..574f879ca1 100644 --- a/pkg/objstore/s3/s3.go +++ b/pkg/objstore/s3/s3.go @@ -196,6 +196,10 @@ func (b *Bucket) Iter(ctx context.Context, dir string, f func(string) error) err } for object := range b.client.ListObjects(b.bucket, dir, false, ctx.Done()) { + // catch the error when failed to list objects + if object.Err != nil { + return object.Err + } // this sometimes happens with empty buckets if object.Key == "" { continue From 58fcbe1a57a987ac2864fa9512775de75ff6f3cc Mon Sep 17 00:00:00 2001 From: jojohappy Date: Thu, 13 Sep 2018 06:42:57 +0800 Subject: [PATCH 2/2] To make comment full sentence. --- pkg/objstore/s3/s3.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/objstore/s3/s3.go b/pkg/objstore/s3/s3.go index 574f879ca1..9678cd288b 100644 --- a/pkg/objstore/s3/s3.go +++ b/pkg/objstore/s3/s3.go @@ -196,11 +196,11 @@ func (b *Bucket) Iter(ctx context.Context, dir string, f func(string) error) err } for object := range b.client.ListObjects(b.bucket, dir, false, ctx.Done()) { - // catch the error when failed to list objects + // Catch the error when failed to list objects. if object.Err != nil { return object.Err } - // this sometimes happens with empty buckets + // This sometimes happens with empty buckets. if object.Key == "" { continue }