From 9881bc2845b4dcf95e974aa7c16c7c614c650b96 Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Tue, 15 Dec 2020 09:37:20 +0100 Subject: [PATCH] Use ListObjects V1 fallback for GCS S3 endpoints As GCP's S3 interoperability does not implement the ListObjectsV2 implementation. Ref: https://cloud.google.com/storage/docs/interoperability > Note: While most actions are interoperable with the Amazon S3 V2 SDK, > listing objects can only be performed using the Amazon S3 V1 list > objects method. Signed-off-by: Hidde Beydals --- controllers/bucket_controller.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/controllers/bucket_controller.go b/controllers/bucket_controller.go index 7000c30e..e8d879b7 100644 --- a/controllers/bucket_controller.go +++ b/controllers/bucket_controller.go @@ -30,6 +30,7 @@ import ( "github.com/go-logr/logr" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" + "github.com/minio/minio-go/v7/pkg/s3utils" corev1 "k8s.io/api/core/v1" apimeta "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -201,7 +202,10 @@ func (r *BucketReconciler) reconcile(ctx context.Context, bucket sourcev1.Bucket } // download bucket content - for object := range s3Client.ListObjects(ctxTimeout, bucket.Spec.BucketName, minio.ListObjectsOptions{Recursive: true}) { + for object := range s3Client.ListObjects(ctxTimeout, bucket.Spec.BucketName, minio.ListObjectsOptions{ + Recursive: true, + UseV1: s3utils.IsGoogleEndpoint(*s3Client.EndpointURL()), + }) { if object.Err != nil { err = fmt.Errorf("listing objects from bucket '%s' failed: %w", bucket.Spec.BucketName, object.Err) return sourcev1.BucketNotReady(bucket, sourcev1.BucketOperationFailedReason, err.Error()), err