From 64ce02e48511e80642ddfa3dc44fe9e04da05bf2 Mon Sep 17 00:00:00 2001 From: "Artur M. Wolff" Date: Mon, 13 Dec 2021 19:36:47 +0100 Subject: [PATCH] {miniogw, testsuite/miniogw}: rm checkBucketError from ListObjects(V2) checkBucketError calls are no longer necessary in ListObjects/ListObjectsV2 as all code paths lead to a listing that reports bucket errors correctly. Previously, we needed them as we stopped at the prefix-optimized listing, which uses StatObject under the hood, which does not report the error correctly. Listing is now defined as falling back to the exhaustive listing if nothing in the prefix-optimized case was found, which means errors will be reported correctly. Change-Id: I8486d0ef033288fad2fb67f6016c9d8d8383be21 --- miniogw/gateway.go | 10 ---------- testsuite/miniogw/gateway_test.go | 6 ++++++ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/miniogw/gateway.go b/miniogw/gateway.go index 54fb2f1..f62611b 100644 --- a/miniogw/gateway.go +++ b/miniogw/gateway.go @@ -640,11 +640,6 @@ func (layer *gatewayLayer) ListObjects(ctx context.Context, bucket, prefix, mark return minio.ListObjectsInfo{}, err } - // TODO this should be removed and implemented on satellite side - defer func() { - err = checkBucketError(ctx, project, bucket, "", err) - }() - // For V1, marker is V2's startAfter and continuationToken does not exist. v2, err := layer.listObjectsGeneral(ctx, project, bucket, prefix, "", delimiter, maxKeys, marker) @@ -667,11 +662,6 @@ func (layer *gatewayLayer) ListObjectsV2(ctx context.Context, bucket, prefix, co return minio.ListObjectsV2Info{}, err } - // TODO this should be removed and implemented on satellite side - defer func() { - err = checkBucketError(ctx, project, bucket, "", err) - }() - result, err := layer.listObjectsGeneral(ctx, project, bucket, prefix, continuationToken, delimiter, maxKeys, startAfter) return result, convertError(err, bucket, "") diff --git a/testsuite/miniogw/gateway_test.go b/testsuite/miniogw/gateway_test.go index 7145523..61a1ef6 100644 --- a/testsuite/miniogw/gateway_test.go +++ b/testsuite/miniogw/gateway_test.go @@ -997,6 +997,12 @@ func testListObjects(t *testing.T, listObjects listObjectsFunc) { _, _, _, _, _, err = listObjects(ctx, layer, testBucket, "", "", "", 0) assert.Equal(t, minio.BucketNotFound{Bucket: testBucket}, err) + // Check the error when listing objects in a non-existing bucket. This + // time try to list with a prefix that will trigger a prefix-optimized + // listing code path. + _, _, _, _, _, err = listObjects(ctx, layer, testBucket, "p", "", "", 0) + assert.Equal(t, minio.BucketNotFound{Bucket: testBucket}, err) + // Create the bucket and files using the Uplink API testBucketInfo, err := project.CreateBucket(ctx, testBucket) require.NoError(t, err)