From: Chang Liu Date: Mon, 18 Dec 2017 09:35:25 +0000 (+0800) Subject: rgw: proper error message when tier_type does not exist X-Git-Tag: v13.0.2~619^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F19575%2Fhead;p=ceph.git rgw: proper error message when tier_type does not exist at now, creating a zone does not check whether the sync module exists. we should make sure that tier_type is valid. Fixes: http://tracker.ceph.com/issues/22469 Signed-off-by: Chang Liu Signed-off-by: lvshanchun --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 3b21c8afb58a..d2ed808d87cd 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -394,6 +394,13 @@ int RGWZoneGroup::add_zone(const RGWZoneParams& zone_params, bool *is_master, bo } if (ptier_type) { zone.tier_type = *ptier_type; + if (!store->get_sync_modules_manager()->get_module(*ptier_type, nullptr)) { + ldout(cct, 0) << "ERROR: could not found sync module: " << *ptier_type + << ", valid sync modules: " + << store->get_sync_modules_manager()->get_registered_module_names() + << dendl; + return -ENOENT; + } } if (psync_from_all) { @@ -4396,6 +4403,12 @@ int RGWRados::init_complete() ret = sync_modules_manager->create_instance(cct, zone_public_config.tier_type, zone_params.tier_config, &sync_module); if (ret < 0) { lderr(cct) << "ERROR: failed to init sync module instance, ret=" << ret << dendl; + if (ret == -ENOENT) { + lderr(cct) << "ERROR: " << zone_public_config.tier_type + << " sync module does not exist. valid sync modules: " + << sync_modules_manager->get_registered_module_names() + << dendl; + } return ret; } } diff --git a/src/rgw/rgw_sync_module.h b/src/rgw/rgw_sync_module.h index cab2eb5d9bb6..be3fdc3d420e 100644 --- a/src/rgw/rgw_sync_module.h +++ b/src/rgw/rgw_sync_module.h @@ -77,7 +77,9 @@ public: if (iter == modules.end()) { return false; } - *module = iter->second; + if (module != nullptr) { + *module = iter->second; + } return true; } @@ -99,6 +101,16 @@ public: return module.get()->create_instance(cct, config, instance); } + + vector get_registered_module_names() const { + vector names; + for (auto& i: modules) { + if (!i.first.empty()) { + names.push_back(i.first); + } + } + return names; + } }; class RGWStatRemoteObjCBCR : public RGWCoroutine {