From 62aa42cccf39c8b08f394c0d27fb5e2db33f49b6 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 8 May 2022 16:50:31 -0700 Subject: [PATCH] avoid replication proxy on version excluded paths (#14878) no need to attempt proxying objects that were never replicated, but do have local `null` versions on them. --- cmd/bucket-replication.go | 6 +++++- cmd/object-api-options.go | 1 + cmd/object-handlers.go | 4 ++-- docs/bucket/versioning/README.md | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/bucket-replication.go b/cmd/bucket-replication.go index 731fb7678..1674f5981 100644 --- a/cmd/bucket-replication.go +++ b/cmd/bucket-replication.go @@ -1600,7 +1600,11 @@ func proxyGetToReplicationTarget(ctx context.Context, bucket, object string, rs return reader, proxyResult{Proxy: true}, nil } -func getproxyTargets(ctx context.Context, bucket, object string, opts ObjectOptions) (tgts *madmin.BucketTargets) { +func getProxyTargets(ctx context.Context, bucket, object string, opts ObjectOptions) (tgts *madmin.BucketTargets) { + if opts.VersionSuspended { + return &madmin.BucketTargets{} + } + cfg, err := getReplicationConfig(ctx, bucket) if err != nil || cfg == nil { return &madmin.BucketTargets{} diff --git a/cmd/object-api-options.go b/cmd/object-api-options.go index 7c2c83fc5..a7aeb40ee 100644 --- a/cmd/object-api-options.go +++ b/cmd/object-api-options.go @@ -157,6 +157,7 @@ func getOpts(ctx context.Context, r *http.Request, bucket, object string) (Objec } } } + opts.VersionSuspended = globalBucketVersioningSys.PrefixSuspended(bucket, object) return opts, nil } diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index d46146d90..8de0fa2b6 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -425,7 +425,7 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj proxy proxyResult perr error ) - proxytgts := getproxyTargets(ctx, bucket, object, opts) + proxytgts := getProxyTargets(ctx, bucket, object, opts) if !proxytgts.Empty() { // proxy to replication target if active-active replication is in place. reader, proxy, perr = proxyGetToReplicationTarget(ctx, bucket, object, rs, r.Header, opts, proxytgts) @@ -662,7 +662,7 @@ func (api objectAPIHandlers) headObjectHandler(ctx context.Context, objectAPI Ob oi ObjectInfo ) // proxy HEAD to replication target if active-active replication configured on bucket - proxytgts := getproxyTargets(ctx, bucket, object, opts) + proxytgts := getProxyTargets(ctx, bucket, object, opts) if !proxytgts.Empty() { if rangeHeader != "" { rs, _ = parseRequestRangeSpec(rangeHeader) diff --git a/docs/bucket/versioning/README.md b/docs/bucket/versioning/README.md index 6b4a1e0c6..6f20618fc 100644 --- a/docs/bucket/versioning/README.md +++ b/docs/bucket/versioning/README.md @@ -93,7 +93,7 @@ To exclude objects under a list of prefix (glob) patterns from being versioned, ### Features - Objects matching these prefixes will behave as though versioning were suspended. These objects **will not** be replicated if bucket has replication configured. -- Objects matching these prefixes will also not leave delete markers, dramatically reduces namespace pollution while keeping the benefits of replication. +- Objects matching these prefixes will also not leave `null` delete markers, dramatically reduces namespace pollution while keeping the benefits of replication. - Users with explicit permissions or the root credential can configure the versioning state of any bucket. ## Examples of enabling bucket versioning using MinIO Java SDK