From ddad231921188c2424c7d212ae739076f2246b9d Mon Sep 17 00:00:00 2001 From: Poorna Date: Fri, 20 Jan 2023 18:03:04 -0800 Subject: [PATCH] replication: Avoid logging PreConditionFailed error (#16450) --- cmd/bucket-replication.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/bucket-replication.go b/cmd/bucket-replication.go index 46dfea5c9..139bf0faa 100644 --- a/cmd/bucket-replication.go +++ b/cmd/bucket-replication.go @@ -1358,13 +1358,21 @@ func (ri ReplicateObjectInfo) replicateAll(ctx context.Context, objectAPI Object if objInfo.isMultipart() { if err := replicateObjectWithMultipart(ctx, c, tgt.Bucket, object, r, objInfo, putOpts); err != nil { - rinfo.ReplicationStatus = replication.Failed - logger.LogIf(ctx, fmt.Errorf("Unable to replicate for object %s/%s(%s): %s", bucket, objInfo.Name, objInfo.VersionID, err)) + if minio.ToErrorResponse(err).Code != "PreConditionFailed" { + rinfo.ReplicationStatus = replication.Failed + logger.LogIf(ctx, fmt.Errorf("Unable to replicate for object %s/%s(%s): %s", bucket, objInfo.Name, objInfo.VersionID, err)) + } else { + rinfo.ReplicationStatus = replication.Completed + } } } else { if _, err = c.PutObject(ctx, tgt.Bucket, object, r, size, "", "", putOpts); err != nil { - rinfo.ReplicationStatus = replication.Failed - logger.LogIf(ctx, fmt.Errorf("Unable to replicate for object %s/%s(%s): %s", bucket, objInfo.Name, objInfo.VersionID, err)) + if minio.ToErrorResponse(err).Code != "PreConditionFailed" { + rinfo.ReplicationStatus = replication.Failed + logger.LogIf(ctx, fmt.Errorf("Unable to replicate for object %s/%s(%s): %s", bucket, objInfo.Name, objInfo.VersionID, err)) + } else { + rinfo.ReplicationStatus = replication.Completed + } } } }