Skip to content

Commit

Permalink
{miniogw, testsuite/miniogw}: rm checkBucketError from ListObjects(V2)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
amwolff committed Dec 15, 2021
1 parent 8b47051 commit 64ce02e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
10 changes: 0 additions & 10 deletions miniogw/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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, "")
Expand Down
6 changes: 6 additions & 0 deletions testsuite/miniogw/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 64ce02e

Please sign in to comment.