Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3: Handle errors returned by MinIO Client ListObjects #22

Merged
merged 4 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions backends/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"time"

"github.com/PowerDNS/go-tlsconfig"
"github.com/minio/minio-go/v7"
"github.com/go-logr/logr"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"

"github.com/PowerDNS/simpleblob"
Expand Down Expand Up @@ -117,7 +117,7 @@ func (b *Backend) List(ctx context.Context, prefix string) (simpleblob.BlobList,
m, err := b.Load(ctx, UpdateMarkerFilename)
exists := !errors.Is(err, os.ErrNotExist)
if err != nil && exists {
return nil, err
return nil, err
}
upstreamMarker := string(m)

Expand Down Expand Up @@ -155,6 +155,12 @@ func (b *Backend) doList(ctx context.Context, prefix string) (simpleblob.BlobLis
Recursive: false,
})
for obj := range objCh {
// Handle error returned by MinIO client
if err := convertMinioError(obj.Err); err != nil {
nvaatstra marked this conversation as resolved.
Show resolved Hide resolved
metricCallErrors.WithLabelValues("list").Inc()
return nil, err
}

metricCalls.WithLabelValues("list").Inc()
metricLastCallTimestamp.WithLabelValues("list").SetToCurrentTime()
if obj.Key == UpdateMarkerFilename {
Expand Down
3 changes: 1 addition & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ if [ -z "$SIMPLEBLOB_TEST_S3_CONFIG" ]; then

# Fetch minio if not found
if ! command -v minio >/dev/null; then
source <(go env)
dst="$GOBIN/minio"
curl -v -o "$dst" "https://dl.min.io/server/minio/release/$GOOS-$GOARCH/minio"
curl -v -o "$dst" "https://dl.min.io/server/minio/release/$(go env GOOS)-$(go env GOARCH)/minio"
chmod u+x "$dst"
fi

Expand Down
5 changes: 5 additions & 0 deletions tester/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func DoBackendTests(t *testing.T, b simpleblob.Interface) {
assert.NoError(t, err)
assert.Equal(t, ls.Names(), []string{"bar-1", "bar-2"}) // sorted

// List with non-existing prefix
ls, err = b.List(ctx, "does-not-exist-")
assert.NoError(t, err)
assert.Nil(t, ls.Names())

// Load
data, err := b.Load(ctx, "foo-1")
assert.NoError(t, err)
Expand Down