From 54a98773f87e04373124c7be0968f653fd350995 Mon Sep 17 00:00:00 2001 From: Poorna Date: Mon, 10 Jan 2022 19:06:10 -0800 Subject: [PATCH] fix: replication of tag removal (#14056) Currently tag removal leaves replication state as `PENDING` because the `HEAD` api returns just a tag count but not the actual tags, and this is treated as a no-op --- cmd/bucket-replication.go | 2 +- cmd/erasure-object.go | 1 + docs/site-replication/run-multi-site-ldap.sh | 30 +++++++++++++++++++ .../run-multi-site-minio-idp.sh | 30 +++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/cmd/bucket-replication.go b/cmd/bucket-replication.go index 90e16eae6..ebaa67be2 100644 --- a/cmd/bucket-replication.go +++ b/cmd/bucket-replication.go @@ -769,7 +769,7 @@ func getReplicationAction(oi1 ObjectInfo, oi2 minio.ObjectInfo, opType replicati } t, _ := tags.ParseObjectTags(oi1.UserTags) - if !reflect.DeepEqual(oi2.UserTags, t.ToMap()) { + if !reflect.DeepEqual(oi2.UserTags, t.ToMap()) || (oi2.UserTagCount != len(t.ToMap())) { return replicateMetadata } diff --git a/cmd/erasure-object.go b/cmd/erasure-object.go index 6b6cb721e..03a8f83e8 100644 --- a/cmd/erasure-object.go +++ b/cmd/erasure-object.go @@ -1573,6 +1573,7 @@ func (er erasureObjects) PutObjectTags(ctx context.Context, bucket, object strin filterOnlineDisksInplace(fi, metaArr, onlineDisks) fi.Metadata[xhttp.AmzObjectTagging] = tags + fi.ReplicationState = opts.PutReplicationState() for k, v := range opts.UserDefined { fi.Metadata[k] = v } diff --git a/docs/site-replication/run-multi-site-ldap.sh b/docs/site-replication/run-multi-site-ldap.sh index c438da2cc..b6f7ebda9 100755 --- a/docs/site-replication/run-multi-site-ldap.sh +++ b/docs/site-replication/run-multi-site-ldap.sh @@ -166,6 +166,36 @@ if [ $? -ne 0 ]; then exit_1; fi +vID=$(./mc stat minio2/newbucket/README.md --json | jq .versionID) +if [ $? -ne 0 ]; then + echo "expecting object to be present. exiting.." + exit_1; +fi +./mc tag set --version-id "${vID}" minio2/newbucket/README.md "k=v" +if [ $? -ne 0 ]; then + echo "expecting tag set to be successful. exiting.." + exit_1; +fi +sleep 5 + +./mc tag remove --version-id "${vID}" minio2/newbucket/README.md +if [ $? -ne 0 ]; then + echo "expecting tag removal to be successful. exiting.." + exit_1; +fi +sleep 5 + +replStatus_minio2=$(./mc stat minio2/newbucket/README.md --json | jq -r .replicationStatus) +if [ $? -ne 0 ]; then + echo "expecting object to be present. exiting.." + exit_1; +fi + +if [ ${replStatus_minio2} != "COMPLETED" ]; then + echo "expected tag removal to have replicated, exiting..." + exit_1; +fi + ./mc rm minio3/newbucket/README.md sleep 5 diff --git a/docs/site-replication/run-multi-site-minio-idp.sh b/docs/site-replication/run-multi-site-minio-idp.sh index f3edb1f1f..a9b3aa34c 100755 --- a/docs/site-replication/run-multi-site-minio-idp.sh +++ b/docs/site-replication/run-multi-site-minio-idp.sh @@ -158,6 +158,36 @@ if [ $? -ne 0 ]; then exit_1; fi +vID=$(./mc stat minio2/newbucket/README.md --json | jq .versionID) +if [ $? -ne 0 ]; then + echo "expecting object to be present. exiting.." + exit_1; +fi +./mc tag set --version-id "${vID}" minio2/newbucket/README.md "k=v" +if [ $? -ne 0 ]; then + echo "expecting tag set to be successful. exiting.." + exit_1; +fi +sleep 5 + +./mc tag remove --version-id "${vID}" minio2/newbucket/README.md +if [ $? -ne 0 ]; then + echo "expecting tag removal to be successful. exiting.." + exit_1; +fi +sleep 5 + +replStatus_minio2=$(./mc stat minio2/newbucket/README.md --json | jq -r .replicationStatus ) +if [ $? -ne 0 ]; then + echo "expecting object to be present. exiting.." + exit_1; +fi + +if [ ${replStatus_minio2} != "COMPLETED" ]; then + echo "expected tag removal to have replicated, exiting..." + exit_1; +fi + ./mc rm minio3/newbucket/README.md sleep 5