From e46577116f15ec8bd27f1b4dacf7bb57c33d6963 Mon Sep 17 00:00:00 2001 From: Poorna Krishnamoorthy Date: Tue, 7 Sep 2021 12:30:28 -0400 Subject: [PATCH] Avoid replication if remote target is offline (#13157) Co-authored-by: Poorna Krishnamoorthy --- cmd/bucket-replication.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/cmd/bucket-replication.go b/cmd/bucket-replication.go index 21770f7b7..a953f9865 100644 --- a/cmd/bucket-replication.go +++ b/cmd/bucket-replication.go @@ -263,6 +263,21 @@ func replicateDelete(ctx context.Context, dobj DeletedObjectVersionInfo, objectA }) return } + if tgt.isOffline() { + logger.LogIf(ctx, fmt.Errorf("remote target is offline for bucket:%s arn:%s", bucket, rcfg.RoleArn)) + sendEvent(eventArgs{ + BucketName: bucket, + Object: ObjectInfo{ + Bucket: bucket, + Name: dobj.ObjectName, + VersionID: versionID, + DeleteMarker: dobj.DeleteMarker, + }, + Host: "Internal: [Replication]", + EventName: event.ObjectReplicationNotTracked, + }) + return + } rmErr := tgt.RemoveObject(ctx, rcfg.GetDestination().Bucket, dobj.ObjectName, miniogo.RemoveObjectOptions{ VersionID: versionID, @@ -594,6 +609,17 @@ func replicateObject(ctx context.Context, objInfo ObjectInfo, objectAPI ObjectLa }) return } + if tgt.isOffline() { + logger.LogIf(ctx, fmt.Errorf("remote target is offline for bucket:%s arn:%s", bucket, cfg.RoleArn)) + sendEvent(eventArgs{ + EventName: event.ObjectReplicationNotTracked, + BucketName: bucket, + Object: objInfo, + Host: "Internal: [Replication]", + }) + return + } + gr, err := objectAPI.GetObjectNInfo(ctx, bucket, object, nil, http.Header{}, readLock, ObjectOptions{ VersionID: objInfo.VersionID, })