From 7198be5be96a6cc6de97a21f54c85550776629cb Mon Sep 17 00:00:00 2001 From: Poorna Date: Fri, 18 Nov 2022 01:39:05 -0800 Subject: [PATCH] bucket resync: persist reset id to bucket metadata (#16088) --- cmd/bucket-replication-handlers.go | 15 +++++++++++++++ cmd/site-replication-utils.go | 3 +++ 2 files changed, 18 insertions(+) diff --git a/cmd/bucket-replication-handlers.go b/cmd/bucket-replication-handlers.go index ab5ef6c3a..9cf092c39 100644 --- a/cmd/bucket-replication-handlers.go +++ b/cmd/bucket-replication-handlers.go @@ -321,6 +321,21 @@ func (api objectAPIHandlers) ResetBucketReplicationStartHandler(w http.ResponseW writeErrorResponseJSON(ctx, w, toAPIError(ctx, err), r.URL) } } + targets, err := globalBucketTargetSys.ListBucketTargets(ctx, bucket) + if err != nil { + writeErrorResponseJSON(ctx, w, toAPIError(ctx, err), r.URL) + return + } + tgtBytes, err := json.Marshal(&targets) + if err != nil { + writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErrWithErr(ErrAdminConfigBadJSON, err), r.URL) + return + } + if _, err = globalBucketMetadataSys.Update(ctx, bucket, bucketTargetsFile, tgtBytes); err != nil { + writeErrorResponseJSON(ctx, w, toAPIError(ctx, err), r.URL) + return + } + if err := globalReplicationPool.resyncer.start(ctx, objectAPI, resyncOpts{ bucket: bucket, arn: arn, diff --git a/cmd/site-replication-utils.go b/cmd/site-replication-utils.go index b8af49aa0..6bb7a2c95 100644 --- a/cmd/site-replication-utils.go +++ b/cmd/site-replication-utils.go @@ -221,6 +221,9 @@ func (sm *siteResyncMetrics) incBucket(o resyncOpts, bktStatus ResyncStatusType) defer sm.Unlock() st, ok := sm.resyncStatus[o.resyncID] if ok { + if st.BucketStatuses == nil { + st.BucketStatuses = map[string]ResyncStatusType{} + } switch bktStatus { case ResyncCompleted: st.BucketStatuses[o.bucket] = ResyncCompleted