diff options
author | Adam C. Emerson <aemerson@redhat.com> | 2022-01-19 16:49:05 -0500 |
---|---|---|
committer | Adam C. Emerson <aemerson@redhat.com> | 2022-01-20 13:13:19 -0500 |
commit | 3c4a64ca040d3a0e0ddf762c391575498dc2a77f (patch) | |
tree | 656b3ccb01458b5000ec3a36a4a2e0d67de7abd4 | |
parent | 0ccd1f69be073987972f01e5e99fc1c19234034d (diff) | |
download | ceph-3c4a64ca040d3a0e0ddf762c391575498dc2a77f.tar.gz |
rgw: Report empty endpoints as error instead of crashing
Fixes: https://tracker.ceph.com/issues/53941
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
-rw-r--r-- | src/rgw/rgw_admin.cc | 8 | ||||
-rw-r--r-- | src/rgw/rgw_rados.cc | 12 | ||||
-rw-r--r-- | src/rgw/rgw_trim_mdlog.cc | 45 | ||||
-rw-r--r-- | src/rgw/rgw_zone.h | 1 |
4 files changed, 62 insertions, 4 deletions
diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 80262c20cd9..6d10387fb35 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -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; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 680da9f4fc4..5fb9e9f3c48 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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()) { diff --git a/src/rgw/rgw_trim_mdlog.cc b/src/rgw/rgw_trim_mdlog.cc index cb4b28bb475..4ddde03363d 100644 --- a/src/rgw/rgw_trim_mdlog.cc +++ b/src/rgw/rgw_trim_mdlog.cc @@ -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); } diff --git a/src/rgw/rgw_zone.h b/src/rgw/rgw_zone.h index a84d492e1f5..9e89cbf150a 100644 --- a/src/rgw/rgw_zone.h +++ b/src/rgw/rgw_zone.h @@ -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; } |