]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: proper error message when tier_type does not exist 19575/head
authorChang Liu <liuchang0812@gmail.com>
Mon, 18 Dec 2017 09:35:25 +0000 (17:35 +0800)
committerChang Liu <liuchang0812@gmail.com>
Tue, 19 Dec 2017 12:56:22 +0000 (20:56 +0800)
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 <liuchang0812@gmail.com>
Signed-off-by: lvshanchun <lvshanchun@gmail.com>
src/rgw/rgw_rados.cc
src/rgw/rgw_sync_module.h

index 3b21c8afb58ade38bd5cb29397832fac831e2a68..d2ed808d87cd73079ecb8cd1cd2a99f6ec36906d 100644 (file)
@@ -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;
     }
   }
index cab2eb5d9bb63b1a8d2565d1fbb76b5227ca1e2c..be3fdc3d420ec420e45fabe009050d52c71118d6 100644 (file)
@@ -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<string> get_registered_module_names() const {
+    vector<string> names;
+    for (auto& i: modules) {
+      if (!i.first.empty()) {
+        names.push_back(i.first);
+      }
+    }
+    return names;
+  }
 };
 
 class RGWStatRemoteObjCBCR : public RGWCoroutine {