summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam C. Emerson <aemerson@redhat.com>2022-01-21 15:14:42 -0500
committerGitHub <noreply@github.com>2022-01-21 15:14:42 -0500
commit485d85cd3e14e6323e91f9283afffd076c173206 (patch)
tree4c7a6ad982ab14552a735df2107bbb45b9bedca4
parent87a490d7b00fc018c0f01748a346e531657c54c4 (diff)
parent3c4a64ca040d3a0e0ddf762c391575498dc2a77f (diff)
downloadceph-485d85cd3e14e6323e91f9283afffd076c173206.tar.gz
Merge pull request #44674 from adamemerson/wip-53941
rgw: Report empty endpoints as error instead of crashing Reviewed-By: Casey Bodley <cbodley@redhat.com>
-rw-r--r--src/rgw/rgw_admin.cc8
-rw-r--r--src/rgw/rgw_rados.cc12
-rw-r--r--src/rgw/rgw_trim_mdlog.cc45
-rw-r--r--src/rgw/rgw_zone.h1
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; }