From 6e748cb1cf641c5944da4e888963011a27af1f99 Mon Sep 17 00:00:00 2001 From: Mike Ralphson Date: Mon, 17 Oct 2016 11:48:06 +0100 Subject: [PATCH] Report when invalid bucket names are skipped in FS backend. (#2947) --- cmd/fs-v1.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/fs-v1.go b/cmd/fs-v1.go index e0cc5064c..d7ed218e6 100644 --- a/cmd/fs-v1.go +++ b/cmd/fs-v1.go @@ -20,6 +20,7 @@ import ( "crypto/md5" "crypto/sha256" "encoding/hex" + "errors" "fmt" "hash" "io" @@ -151,10 +152,12 @@ func (fs fsObjects) ListBuckets() ([]BucketInfo, error) { if err != nil { return nil, toObjectErr(traceError(err)) } + var invalidBucketNames []string for _, vol := range vols { // StorageAPI can send volume names which are incompatible // with buckets, handle it and skip them. if !IsValidBucketName(vol.Name) { + invalidBucketNames = append(invalidBucketNames, vol.Name) continue } // Ignore the volume special bucket. @@ -166,6 +169,11 @@ func (fs fsObjects) ListBuckets() ([]BucketInfo, error) { Created: vol.Created, }) } + // Print a user friendly message if we indeed skipped certain folders which are + // incompatible with S3's bucket name restrictions. + if len(invalidBucketNames) > 0 { + errorIf(errors.New("One or more invalid bucket names found"), "Skipping %s", invalidBucketNames) + } sort.Sort(byBucketName(bucketInfos)) return bucketInfos, nil }