From: Casey Bodley Date: Wed, 31 Aug 2022 02:57:39 +0000 (-0400) Subject: rgw: add create_config_store() factory X-Git-Tag: v18.1.0~1101^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6530f1f9e58ae715587d6d2d42afb704a375d075;p=ceph.git rgw: add create_config_store() factory Signed-off-by: Casey Bodley --- diff --git a/src/common/options/rgw.yaml.in b/src/common/options/rgw.yaml.in index e758da2e003..32735ea94ea 100644 --- a/src/common/options/rgw.yaml.in +++ b/src/common/options/rgw.yaml.in @@ -3482,6 +3482,17 @@ options: - dbstore - motr - daos +- name: rgw_config_store + type: str + level: advanced + desc: Configuration storage backend + default: rados + services: + - rgw + enum_values: + - rados + - dbstore + - json - name: rgw_filter type: str level: advanced @@ -3508,6 +3519,24 @@ options: default: dbstore services: - rgw +- name: dbstore_config_uri + type: str + level: advanced + desc: 'Config database URI. URIs beginning with file: refer to local files opened with SQLite.' + default: file:/var/lib/ceph/radosgw/dbstore-config.db + see_also: + - rgw_config_store + services: + - rgw +- name: rgw_json_config + type: str + level: advanced + desc: Path to a json file that contains the static zone and zonegroup configuration. Requires rgw_config_store=json. + default: /var/lib/ceph/radosgw/config.json + see_also: + - rgw_config_store + services: + - rgw - name: motr_profile_fid type: str level: advanced diff --git a/src/rgw/rgw_sal.cc b/src/rgw/rgw_sal.cc index 1798775dcc0..90786ac49c9 100644 --- a/src/rgw/rgw_sal.cc +++ b/src/rgw/rgw_sal.cc @@ -23,10 +23,13 @@ #include "rgw_sal.h" #include "rgw_sal_rados.h" +#include "store/rados/config/store.h" +#include "store/json_config/store.h" #include "rgw_d3n_datacache.h" #ifdef WITH_RADOSGW_DBSTORE #include "rgw_sal_dbstore.h" +#include "store/dbstore/config/store.h" #endif #ifdef WITH_RADOSGW_MOTR @@ -374,6 +377,33 @@ StoreManager::Config StoreManager::get_config(bool admin, CephContext* cct) return cfg; } +auto StoreManager::create_config_store(const DoutPrefixProvider* dpp, + std::string_view type) + -> std::unique_ptr +{ + try { + if (type == "rados") { + return rgw::rados::create_config_store(dpp); +#ifdef WITH_RADOSGW_DBSTORE + } else if (type == "dbstore") { + const auto uri = g_conf().get_val("dbstore_config_uri"); + return rgw::dbstore::create_config_store(dpp, uri); +#endif + } else if (type == "json") { + auto filename = g_conf().get_val("rgw_json_config"); + return rgw::sal::create_json_config_store(dpp, filename); + } else { + ldpp_dout(dpp, -1) << "ERROR: unrecognized config store type '" + << type << "'" << dendl; + return nullptr; + } + } catch (const std::exception& e) { + ldpp_dout(dpp, -1) << "ERROR: failed to initialize config store '" + << type << "': " << e.what() << dendl; + } + return nullptr; +} + namespace rgw::sal { int Object::range_to_ofs(uint64_t obj_size, int64_t &ofs, int64_t &end) { diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 1152a1242cf..8bb2f476ddc 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -1605,6 +1605,12 @@ public: /** Get the config for stores/filters */ static Config get_config(bool admin, CephContext* cct); + + /** Create a ConfigStore */ + static auto create_config_store(const DoutPrefixProvider* dpp, + std::string_view type) + -> std::unique_ptr; + }; /** @} */