From: Yehuda Sadeh Date: Wed, 12 Apr 2017 23:45:55 +0000 (-0700) Subject: rgw: don't pass sync module to rest filter in creation X-Git-Tag: ses5-milestone6~9^2~3^2~26 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1ca77abeb5a32458a7daee1bd128511ba2d801fd;p=ceph.git rgw: don't pass sync module to rest filter in creation sync module instance might change due to reconfiguration. Pass it into the handler when executing op. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_sync_module_es.cc b/src/rgw/rgw_sync_module_es.cc index 40459864c39..7c80a3177ee 100644 --- a/src/rgw/rgw_sync_module_es.cc +++ b/src/rgw/rgw_sync_module_es.cc @@ -566,7 +566,7 @@ RGWRESTMgr *RGWElasticSyncModuleInstance::get_rest_filter(int dialect, RGWRESTMg if (dialect != RGW_REST_S3) { return orig; } - return new RGWRESTMgr_MDSearch_S3(this); + return new RGWRESTMgr_MDSearch_S3(); } int RGWElasticSyncModule::create_instance(CephContext *cct, map& config, RGWSyncModuleInstanceRef *instance) { diff --git a/src/rgw/rgw_sync_module_es_rest.cc b/src/rgw/rgw_sync_module_es_rest.cc index fec51040298..a7bc7f3b4ce 100644 --- a/src/rgw/rgw_sync_module_es_rest.cc +++ b/src/rgw/rgw_sync_module_es_rest.cc @@ -111,6 +111,7 @@ struct es_search_response { }; class RGWMetadataSearchOp : public RGWOp { + RGWSyncModuleInstanceRef sync_module_ref; RGWElasticSyncModuleInstance *es_module; protected: string expression; @@ -126,7 +127,9 @@ protected: es_search_response response; public: - RGWMetadataSearchOp(RGWElasticSyncModuleInstance *_es_module) : es_module(_es_module) {} + RGWMetadataSearchOp(const RGWSyncModuleInstanceRef& sync_module) : sync_module_ref(sync_module) { + es_module = static_cast(sync_module_ref.get()); + } int verify_permission() { return 0; @@ -254,7 +257,7 @@ void RGWMetadataSearchOp::execute() class RGWMetadataSearch_ObjStore_S3 : public RGWMetadataSearchOp { public: - RGWMetadataSearch_ObjStore_S3(RGWElasticSyncModuleInstance *_es_module) : RGWMetadataSearchOp(_es_module) { + RGWMetadataSearch_ObjStore_S3(const RGWSyncModuleInstanceRef& _sync_module) : RGWMetadataSearchOp(_sync_module) { custom_prefix = "x-amz-meta-"; } @@ -346,11 +349,10 @@ public: }; class RGWHandler_REST_MDSearch_S3 : public RGWHandler_REST_S3 { - RGWElasticSyncModuleInstance *es_module; protected: RGWOp *op_get() { if (s->info.args.exists("query")) { - return new RGWMetadataSearch_ObjStore_S3(es_module); + return new RGWMetadataSearch_ObjStore_S3(store->get_sync_module()); } if (!s->init_state.url_bucket.empty() && s->info.args.exists("mdsearch")) { @@ -365,8 +367,7 @@ protected: return nullptr; } public: - RGWHandler_REST_MDSearch_S3(const rgw::auth::StrategyRegistry& auth_registry, - RGWElasticSyncModuleInstance *_es_module) : RGWHandler_REST_S3(auth_registry), es_module(_es_module) {} + RGWHandler_REST_MDSearch_S3(const rgw::auth::StrategyRegistry& auth_registry) : RGWHandler_REST_S3(auth_registry) {} virtual ~RGWHandler_REST_MDSearch_S3() {} }; @@ -386,7 +387,7 @@ RGWHandler_REST* RGWRESTMgr_MDSearch_S3::get_handler(struct req_state* const s, return nullptr; } - RGWHandler_REST *handler = new RGWHandler_REST_MDSearch_S3(auth_registry, es_module); + RGWHandler_REST *handler = new RGWHandler_REST_MDSearch_S3(auth_registry); ldout(s->cct, 20) << __func__ << " handler=" << typeid(*handler).name() << dendl; diff --git a/src/rgw/rgw_sync_module_es_rest.h b/src/rgw/rgw_sync_module_es_rest.h index 7578b81273f..4dd0698f235 100644 --- a/src/rgw/rgw_sync_module_es_rest.h +++ b/src/rgw/rgw_sync_module_es_rest.h @@ -6,9 +6,8 @@ class RGWElasticSyncModuleInstance; class RGWRESTMgr_MDSearch_S3 : public RGWRESTMgr { - RGWElasticSyncModuleInstance *es_module; public: - explicit RGWRESTMgr_MDSearch_S3(RGWElasticSyncModuleInstance *_es_module) : es_module(_es_module) {} + explicit RGWRESTMgr_MDSearch_S3() {} RGWHandler_REST *get_handler(struct req_state* s, const rgw::auth::StrategyRegistry& auth_registry,