From 70c6cac4e6bad05de95641bb57ea2d7b6f64318c Mon Sep 17 00:00:00 2001 From: Daniel Gryniewicz Date: Thu, 1 Sep 2022 13:52:26 -0400 Subject: [PATCH] RGW - Zipper - Allow per-store admin APIs Some of the existing admin APIs are rados-specific, and other stores will want to add specific APIs. Allow this by having a function to add store-specific APIs. Signed-off-by: Daniel Gryniewicz --- src/rgw/CMakeLists.txt | 9 +++------ src/rgw/rgw_main.cc | 17 ++--------------- src/rgw/rgw_sal.h | 3 +++ src/rgw/rgw_sal_dbstore.h | 1 + src/rgw/rgw_sal_filter.h | 3 +++ src/rgw/rgw_sal_motr.h | 1 + src/rgw/rgw_sal_rados.cc | 19 +++++++++++++++++++ src/rgw/rgw_sal_rados.h | 1 + 8 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index 01a4e6c3fe654..6206db6ff1844 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -121,12 +121,15 @@ set(librgw_common_srcs rgw_rados.cc rgw_resolve.cc rgw_rest.cc + rgw_rest_bucket.cc rgw_rest_client.cc + rgw_rest_config.cc rgw_rest_conn.cc rgw_rest_log.cc rgw_rest_metadata.cc rgw_rest_pubsub.cc rgw_rest_pubsub_common.cc + rgw_rest_ratelimit.cc rgw_rest_realm.cc rgw_rest_role.cc rgw_rest_s3.cc @@ -283,16 +286,10 @@ set(rgw_a_srcs rgw_realm_watcher.cc rgw_os_lib.cc rgw_process.cc - rgw_rest_bucket.cc - rgw_rest_config.cc - rgw_rest_log.cc - rgw_rest_metadata.cc - rgw_rest_realm.cc rgw_rest_swift.cc rgw_rest_usage.cc rgw_rest_info.cc rgw_rest_user.cc - rgw_rest_ratelimit.cc rgw_swift_auth.cc rgw_usage.cc rgw_opa.cc diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index eb9ed5a63ef20..2b6e66e3806f1 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -26,13 +26,7 @@ #include "rgw_rest_info.h" #include "rgw_rest_usage.h" #include "rgw_rest_user.h" -#include "rgw_rest_bucket.h" -#include "rgw_rest_metadata.h" -#include "rgw_rest_log.h" -#include "rgw_rest_config.h" -#include "rgw_rest_realm.h" #include "rgw_rest_sts.h" -#include "rgw_rest_ratelimit.h" #include "rgw_swift_auth.h" #include "rgw_log.h" #include "rgw_tools.h" @@ -501,16 +495,9 @@ int main(int argc, const char **argv) admin_resource->register_resource("info", new RGWRESTMgr_Info); admin_resource->register_resource("usage", new RGWRESTMgr_Usage); admin_resource->register_resource("user", new RGWRESTMgr_User); - /* XXX dang part of this is RADOS specific */ - admin_resource->register_resource("bucket", new RGWRESTMgr_Bucket); - /*Registering resource for /admin/metadata */ - admin_resource->register_resource("metadata", new RGWRESTMgr_Metadata); - /* XXX dang ifdef these RADOS ? */ - admin_resource->register_resource("log", new RGWRESTMgr_Log); - admin_resource->register_resource("config", new RGWRESTMgr_Config); - admin_resource->register_resource("realm", new RGWRESTMgr_Realm); - admin_resource->register_resource("ratelimit", new RGWRESTMgr_Ratelimit); + /* Register store-specific admin APIs */ + store->register_admin_apis(admin_resource); rest.register_resource(g_conf()->rgw_admin_entry, admin_resource); } diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 46280e6662397..1152a1242cf08 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -23,6 +23,7 @@ #include "rgw_datalog_notify.h" #include "include/random.h" +class RGWRESTMgr; class RGWAccessListFilter; class RGWLC; struct rgw_user_bucket; @@ -451,6 +452,8 @@ class Store { virtual const std::string& get_luarocks_path() const = 0; /** Set the location of where lua packages are installed */ virtual void set_luarocks_path(const std::string& path) = 0; + /** Register admin APIs unique to this store */ + virtual void register_admin_apis(RGWRESTMgr* mgr) = 0; }; /** diff --git a/src/rgw/rgw_sal_dbstore.h b/src/rgw/rgw_sal_dbstore.h index 85c320432bb6b..d70da2b497c63 100644 --- a/src/rgw/rgw_sal_dbstore.h +++ b/src/rgw/rgw_sal_dbstore.h @@ -899,6 +899,7 @@ public: virtual void set_luarocks_path(const std::string& path) override { luarocks_path = path; } + virtual void register_admin_apis(RGWRESTMgr* mgr) override { }; /* Unique to DBStore */ void setDBStoreManager(DBStoreManager *stm) { dbsm = stm; } diff --git a/src/rgw/rgw_sal_filter.h b/src/rgw/rgw_sal_filter.h index a422d2b4c2361..501b380daaa7c 100644 --- a/src/rgw/rgw_sal_filter.h +++ b/src/rgw/rgw_sal_filter.h @@ -307,6 +307,9 @@ public: virtual const std::string& get_luarocks_path() const override; virtual void set_luarocks_path(const std::string& path) override; + virtual void register_admin_apis(RGWRESTMgr* mgr)override { + return next->register_admin_apis(mgr); + } }; class FilterUser : public User { diff --git a/src/rgw/rgw_sal_motr.h b/src/rgw/rgw_sal_motr.h index b773d0eab102f..00e260d293d57 100644 --- a/src/rgw/rgw_sal_motr.h +++ b/src/rgw/rgw_sal_motr.h @@ -1029,6 +1029,7 @@ class MotrStore : public StoreStore { virtual void set_luarocks_path(const std::string& path) override { luarocks_path = path; } + virtual void register_admin_apis(RGWRESTMgr* mgr) override { }; int open_idx(struct m0_uint128 *id, bool create, struct m0_idx *out); void close_idx(struct m0_idx *idx) { m0_idx_fini(idx); } diff --git a/src/rgw/rgw_sal_rados.cc b/src/rgw/rgw_sal_rados.cc index 79b3915e56602..8f72e222c7c6e 100644 --- a/src/rgw/rgw_sal_rados.cc +++ b/src/rgw/rgw_sal_rados.cc @@ -39,6 +39,13 @@ #include "rgw_service.h" #include "rgw_lc.h" #include "rgw_lc_tier.h" +#include "rgw_rest_admin.h" +#include "rgw_rest_bucket.h" +#include "rgw_rest_metadata.h" +#include "rgw_rest_log.h" +#include "rgw_rest_config.h" +#include "rgw_rest_ratelimit.h" +#include "rgw_rest_realm.h" #include "services/svc_sys_obj.h" #include "services/svc_meta.h" #include "services/svc_meta_be_sobj.h" @@ -1420,6 +1427,18 @@ void RadosStore::finalize(void) rados->finalize(); } +void RadosStore::register_admin_apis(RGWRESTMgr* mgr) +{ + mgr->register_resource("bucket", new RGWRESTMgr_Bucket); + /*Registering resource for /admin/metadata */ + mgr->register_resource("metadata", new RGWRESTMgr_Metadata); + mgr->register_resource("log", new RGWRESTMgr_Log); + /* XXX These may become global when cbodley is done with his zone work */ + mgr->register_resource("config", new RGWRESTMgr_Config); + mgr->register_resource("realm", new RGWRESTMgr_Realm); + mgr->register_resource("ratelimit", new RGWRESTMgr_Ratelimit); +} + std::unique_ptr RadosStore::get_lua_manager() { return std::make_unique(this); diff --git a/src/rgw/rgw_sal_rados.h b/src/rgw/rgw_sal_rados.h index 732a7ea977542..0771b9ad974b9 100644 --- a/src/rgw/rgw_sal_rados.h +++ b/src/rgw/rgw_sal_rados.h @@ -248,6 +248,7 @@ class RadosStore : public StoreStore { virtual void set_luarocks_path(const std::string& path) override { luarocks_path = path; } + virtual void register_admin_apis(RGWRESTMgr* mgr) override; /* Unique to RadosStore */ int get_obj_head_ioctx(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, const rgw_obj& obj, -- 2.39.5