From 33c6e09e73ca94fe2d457f9addcf639e57ecc5ee Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 26 Nov 2019 12:40:11 -0800 Subject: [PATCH] rgw: sync: object sync info oid depends on pipe The object sync info object (used in cloud sync module) depends on pipe. Different oid is crafted if source and destination buckets are not the same. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_data_sync.cc | 16 +++++++++------- src/rgw/rgw_data_sync.h | 3 ++- src/rgw/rgw_sync_module_aws.cc | 5 +++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index 03793eccb26..02cb1c5b1a2 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -2443,8 +2443,6 @@ public: RGWCoroutine *RGWDefaultDataSyncModule::sync_object(RGWDataSyncCtx *sc, rgw_bucket_sync_pipe& sync_pipe, rgw_obj_key& key, std::optional versioned_epoch, rgw_zone_set *zones_trace) { - auto sync_env = sc->env; - return new RGWObjFetchCR(sc, sync_pipe, key, std::nullopt, versioned_epoch, zones_trace); } @@ -4825,12 +4823,16 @@ string RGWBucketPipeSyncStatusManager::status_oid(const rgw_zone_id& source_zone } } -string RGWBucketPipeSyncStatusManager::obj_status_oid(const rgw_zone_id& source_zone, - const rgw_obj& obj) +string RGWBucketPipeSyncStatusManager::obj_status_oid(const rgw_bucket_sync_pipe& sync_pipe, + const rgw_zone_id& source_zone, + const rgw_obj& obj) { -#warning FIXME - return object_status_oid_prefix + "." + source_zone.id + ":" + obj.bucket.get_key() + ":" + - obj.key.name + ":" + obj.key.instance; + string prefix = object_status_oid_prefix + "." + source_zone.id + ":" + obj.bucket.get_key(); + if (sync_pipe.source_bucket_info.bucket != + sync_pipe.dest_bucket_info.bucket) { + prefix += string("/") + sync_pipe.dest_bucket_info.bucket.get_key(); + } + return prefix + ":" + obj.key.name + ":" + obj.key.instance; } class RGWCollectBucketSyncStatusCR : public RGWShardCollectCR { diff --git a/src/rgw/rgw_data_sync.h b/src/rgw/rgw_data_sync.h index a8ea0e083d1..abf112e36c0 100644 --- a/src/rgw/rgw_data_sync.h +++ b/src/rgw/rgw_data_sync.h @@ -632,7 +632,8 @@ public: int init_sync_status(); static string status_oid(const rgw_zone_id& source_zone, const rgw_bucket_sync_pair_info& bs); - static string obj_status_oid(const rgw_zone_id& source_zone, const rgw_obj& obj); /* specific source obj sync status, + static string obj_status_oid(const rgw_bucket_sync_pipe& sync_pipe, + const rgw_zone_id& source_zone, const rgw_obj& obj); /* specific source obj sync status, can be used by sync modules */ // implements DoutPrefixProvider diff --git a/src/rgw/rgw_sync_module_aws.cc b/src/rgw/rgw_sync_module_aws.cc index e479b534781..845fb74a48f 100644 --- a/src/rgw/rgw_sync_module_aws.cc +++ b/src/rgw/rgw_sync_module_aws.cc @@ -1412,6 +1412,7 @@ class RGWAWSStreamObjToCloudMultipartCR : public RGWCoroutine { public: RGWAWSStreamObjToCloudMultipartCR(RGWDataSyncCtx *_sc, + rgw_bucket_sync_pipe& _sync_pipe, AWSSyncConfig& _conf, RGWRESTConn *_source_conn, const rgw_obj& _src_obj, @@ -1431,7 +1432,7 @@ public: src_properties(_src_properties), rest_obj(_rest_obj), status_obj(sync_env->svc->zone->get_zone_params().log_pool, - RGWBucketPipeSyncStatusManager::obj_status_oid(sc->source_zone, src_obj)) { + RGWBucketPipeSyncStatusManager::obj_status_oid(_sync_pipe, sc->source_zone, src_obj)) { } @@ -1685,7 +1686,7 @@ public: ldout(sc->cct, 0) << "ERROR: failed to decode rest obj out of headers=" << headers << ", attrs=" << attrs << dendl; return set_cr_error(-EINVAL); } - call(new RGWAWSStreamObjToCloudMultipartCR(sc, instance.conf, source_conn, src_obj, + call(new RGWAWSStreamObjToCloudMultipartCR(sc, sync_pipe, instance.conf, source_conn, src_obj, target, dest_obj, size, src_properties, rest_obj)); } } -- 2.39.5