]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Report empty endpoints as error instead of crashing 44674/head
authorAdam C. Emerson <aemerson@redhat.com>
Wed, 19 Jan 2022 21:49:05 +0000 (16:49 -0500)
committerAdam C. Emerson <aemerson@redhat.com>
Thu, 20 Jan 2022 18:13:19 +0000 (13:13 -0500)
Fixes: https://tracker.ceph.com/issues/53941
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_trim_mdlog.cc
src/rgw/rgw_zone.h

index 80262c20cd9fca5c231825778068ec4ce2fb6923..6d10387fb3598a8199bd70c4cff5c90de475d093 100644 (file)
@@ -8307,7 +8307,13 @@ next:
     }
 
     auto num_shards = g_conf()->rgw_md_log_max_shards;
-    ret = crs.run(dpp(), create_admin_meta_log_trim_cr(dpp(), static_cast<rgw::sal::RadosStore*>(store), &http, num_shards));
+    auto mltcr = create_admin_meta_log_trim_cr(
+      dpp(), static_cast<rgw::sal::RadosStore*>(store), &http, num_shards);
+    if (!mltcr) {
+      cerr << "Cluster misconfigured! Unable to trim." << std::endl;
+      return -EIO;
+    }
+    ret = crs.run(dpp(), mltcr);
     if (ret < 0) {
       cerr << "automated mdlog trim failed with " << cpp_strerror(ret) << std::endl;
       return -ret;
index 680da9f4fc433ef3d5eb66cef1b9fafccb5045d1..5fb9e9f3c48b55cae7aca35918aa15f646c953b7 100644 (file)
@@ -611,10 +611,16 @@ public:
   }
   int process(const DoutPrefixProvider *dpp) override {
     list<RGWCoroutinesStack*> stacks;
+    auto metatrimcr = create_meta_log_trim_cr(this, static_cast<rgw::sal::RadosStore*>(store), &http,
+                                             cct->_conf->rgw_md_log_max_shards,
+                                             trim_interval);
+    if (!metatrimcr) {
+      ldpp_dout(dpp, -1) << "Bailing out of trim thread!" << dendl;
+      return -EINVAL;
+    }
     auto meta = new RGWCoroutinesStack(store->ctx(), &crs);
-    meta->call(create_meta_log_trim_cr(this, static_cast<rgw::sal::RadosStore*>(store), &http,
-                                       cct->_conf->rgw_md_log_max_shards,
-                                       trim_interval));
+    meta->call(metatrimcr);
+
     stacks.push_back(meta);
 
     if (store->svc()->zone->sync_module_exports_data()) {
index cb4b28bb4755cab165eabada8b71afbc2b1f9469..4ddde03363d6b8c22c290e000a991c05a861768d 100644 (file)
@@ -677,9 +677,48 @@ class MetaPeerTrimPollCR : public MetaTrimPollCR {
   {}
 };
 
+namespace {
+bool sanity_check_endpoints(const DoutPrefixProvider *dpp, rgw::sal::RadosStore* store) {
+  bool retval = true;
+  auto current = store->svc()->mdlog->get_period_history()->get_current();
+  const auto& period = current.get_period();
+  for (const auto& [_, zonegroup] : period.get_map().zonegroups) {
+    if (zonegroup.endpoints.empty()) {
+      ldpp_dout(dpp, -1)
+       << __PRETTY_FUNCTION__ << ":" << __LINE__
+       << " WARNING: Cluster is is misconfigured! "
+       << " Zonegroup " << zonegroup.get_name()
+       << " (" << zonegroup.get_id() << ") in Realm "
+       << period.get_realm_name() << " ( " << period.get_realm() << ") "
+       << " has no endpoints!" << dendl;
+    }
+    for (const auto& [_, zone] : zonegroup.zones) {
+      if (zone.endpoints.empty()) {
+       ldpp_dout(dpp, -1)
+         << __PRETTY_FUNCTION__ << ":" << __LINE__
+         << " ERROR: Cluster is is misconfigured! "
+         << " Zone " << zone.name << " (" << zone.id << ") in Zonegroup "
+         << zonegroup.get_name() << " ( " << zonegroup.get_id()
+         << ") in Realm " << period.get_realm_name()
+         << " ( " << period.get_realm() << ") "
+         << " has no endpoints! Trimming is impossible." << dendl;
+       retval = false;
+      }
+    }
+  }
+  return retval;
+}
+}
+
 RGWCoroutine* create_meta_log_trim_cr(const DoutPrefixProvider *dpp, rgw::sal::RadosStore* store, RGWHTTPManager *http,
                                       int num_shards, utime_t interval)
 {
+  if (!sanity_check_endpoints(dpp, store)) {
+    ldpp_dout(dpp, -1)
+      << __PRETTY_FUNCTION__ << ":" << __LINE__
+      << " ERROR: Cluster is is misconfigured! Refusing to trim." << dendl;
+      return nullptr;
+  }
   if (store->svc()->zone->is_meta_master()) {
     return new MetaMasterTrimPollCR(dpp, store, http, num_shards, interval);
   }
@@ -705,6 +744,12 @@ RGWCoroutine* create_admin_meta_log_trim_cr(const DoutPrefixProvider *dpp, rgw::
                                             RGWHTTPManager *http,
                                             int num_shards)
 {
+  if (!sanity_check_endpoints(dpp, store)) {
+    ldpp_dout(dpp, -1)
+      << __PRETTY_FUNCTION__ << ":" << __LINE__
+      << " ERROR: Cluster is is misconfigured! Refusing to trim." << dendl;
+      return nullptr;
+  }
   if (store->svc()->zone->is_meta_master()) {
     return new MetaMasterAdminTrimCR(dpp, store, http, num_shards);
   }
index a84d492e1f52c91abed41c0c65d4db8d5edf9434..9e89cbf150a72183210415177d332757ba158b4e 100644 (file)
@@ -1271,6 +1271,7 @@ public:
   const rgw_zone_id& get_master_zone() const { return master_zone; }
   const std::string& get_master_zonegroup() const { return master_zonegroup; }
   const std::string& get_realm() const { return realm_id; }
+  const std::string& get_realm_name() const { return realm_name; }
   const RGWPeriodMap& get_map() const { return period_map; }
   RGWPeriodConfig& get_config() { return period_config; }
   const RGWPeriodConfig& get_config() const { return period_config; }