From 96ec8fcba1570d0c60efa77615a184b80960be64 Mon Sep 17 00:00:00 2001 From: Poorna Date: Wed, 25 Oct 2023 21:24:10 -0700 Subject: [PATCH] Preserve replica timestamps in multipart (#18318) Also a backward compatibility fix to use x-amz-replica-status if present as replication status. --- cmd/erasure-metadata.go | 5 +++++ cmd/object-multipart-handlers.go | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/erasure-metadata.go b/cmd/erasure-metadata.go index 528814f83..5cd78ee96 100644 --- a/cmd/erasure-metadata.go +++ b/cmd/erasure-metadata.go @@ -180,6 +180,11 @@ func (fi FileInfo) ToObjectInfo(bucket, object string, versioned bool) ObjectInf objInfo.ReplicationStatusInternal = fi.ReplicationState.ReplicationStatusInternal objInfo.VersionPurgeStatusInternal = fi.ReplicationState.VersionPurgeStatusInternal objInfo.ReplicationStatus = fi.ReplicationStatus() + if objInfo.ReplicationStatus.Empty() { // overlay x-amx-replication-status if present for replicas + if st, ok := fi.Metadata[xhttp.AmzBucketReplicationStatus]; ok && st == string(replication.Replica) { + objInfo.ReplicationStatus = replication.StatusType(st) + } + } objInfo.VersionPurgeStatus = fi.VersionPurgeStatus() objInfo.TransitionedObject = TransitionedObject{ diff --git a/cmd/object-multipart-handlers.go b/cmd/object-multipart-handlers.go index 922989aa5..261ef04f1 100644 --- a/cmd/object-multipart-handlers.go +++ b/cmd/object-multipart-handlers.go @@ -143,7 +143,10 @@ func (api objectAPIHandlers) NewMultipartUploadHandler(w http.ResponseWriter, r metadata[xhttp.AmzObjectTagging] = objTags } - + if r.Header.Get(xhttp.AmzBucketReplicationStatus) == replication.Replica.String() { + metadata[ReservedMetadataPrefixLower+ReplicaStatus] = replication.Replica.String() + metadata[ReservedMetadataPrefixLower+ReplicaTimestamp] = UTCNow().Format(time.RFC3339Nano) + } retPerms := isPutActionAllowed(ctx, getRequestAuthType(r), bucket, object, r, policy.PutObjectRetentionAction) holdPerms := isPutActionAllowed(ctx, getRequestAuthType(r), bucket, object, r, policy.PutObjectLegalHoldAction)