From c0fdbd2b2d6dfc3c5dc6c94c3a4e13a1c2b954e6 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 2 Nov 2022 13:10:58 -0400 Subject: [PATCH] rgw: RGWRealmReloader reloads auth_registry Signed-off-by: Casey Bodley --- src/rgw/rgw_appmain.cc | 5 +++-- src/rgw/rgw_asio_frontend.cc | 17 ++++++----------- src/rgw/rgw_asio_frontend.h | 3 +-- src/rgw/rgw_frontend.h | 24 +++++------------------- src/rgw/rgw_process.h | 7 ++----- src/rgw/rgw_realm_reloader.cc | 10 +++++++++- src/rgw/rgw_realm_reloader.h | 6 +++++- 7 files changed, 31 insertions(+), 41 deletions(-) diff --git a/src/rgw/rgw_appmain.cc b/src/rgw/rgw_appmain.cc index 8ca2dfe6aa8d7..a572d763ff96f 100644 --- a/src/rgw/rgw_appmain.cc +++ b/src/rgw/rgw_appmain.cc @@ -469,13 +469,14 @@ int rgw::AppMain::init_frontends2(RGWLib* rgwlib) if (env.driver->get_name() == "rados") { // add a watcher to respond to realm configuration changes pusher = std::make_unique(dpp, env.driver, null_yield); - fe_pauser = std::make_unique(fes, *(implicit_tenant_context.get()), pusher.get()); + fe_pauser = std::make_unique(fes, pusher.get()); rgw_pauser = std::make_unique(); rgw_pauser->add_pauser(fe_pauser.get()); if (lua_background) { rgw_pauser->add_pauser(lua_background.get()); } - reloader = std::make_unique(env, service_map_meta, rgw_pauser.get()); + reloader = std::make_unique( + env, *implicit_tenant_context, service_map_meta, rgw_pauser.get()); realm_watcher = std::make_unique(dpp, g_ceph_context, static_cast(env.driver)->svc()->zone->get_realm()); realm_watcher->add_watcher(RGWRealmNotify::Reload, *reloader); diff --git a/src/rgw/rgw_asio_frontend.cc b/src/rgw/rgw_asio_frontend.cc index 31276da64119b..5cfd0dc6bd20b 100644 --- a/src/rgw/rgw_asio_frontend.cc +++ b/src/rgw/rgw_asio_frontend.cc @@ -450,7 +450,7 @@ class AsioFrontend { void stop(); void join(); void pause(); - void unpause(rgw::sal::Driver* driver, rgw_auth_registry_ptr_t); + void unpause(); }; unsigned short parse_port(const char *input, boost::system::error_code& ec) @@ -1118,12 +1118,9 @@ void AsioFrontend::pause() } } -void AsioFrontend::unpause(rgw::sal::Driver* const driver, - rgw_auth_registry_ptr_t auth_registry) +void AsioFrontend::unpause() { - env.driver = driver; - env.auth_registry = std::move(auth_registry); - lua_manager = driver->get_lua_manager(); + lua_manager = env.driver->get_lua_manager(); // unpause to unblock connections pause_mutex.unlock(); @@ -1182,9 +1179,7 @@ void RGWAsioFrontend::pause_for_new_config() impl->pause(); } -void RGWAsioFrontend::unpause_with_new_config( - rgw::sal::Driver* const driver, - rgw_auth_registry_ptr_t auth_registry -) { - impl->unpause(driver, std::move(auth_registry)); +void RGWAsioFrontend::unpause_with_new_config() +{ + impl->unpause(); } diff --git a/src/rgw/rgw_asio_frontend.h b/src/rgw/rgw_asio_frontend.h index 85c60f3d191c1..940b717b5f2b3 100644 --- a/src/rgw/rgw_asio_frontend.h +++ b/src/rgw/rgw_asio_frontend.h @@ -22,8 +22,7 @@ public: void join() override; void pause_for_new_config() override; - void unpause_with_new_config(rgw::sal::Driver* driver, - rgw_auth_registry_ptr_t auth_registry) override; + void unpause_with_new_config() override; }; #endif // RGW_ASIO_FRONTEND_H diff --git a/src/rgw/rgw_frontend.h b/src/rgw/rgw_frontend.h index cf766024503f5..cdb53e3971a33 100644 --- a/src/rgw/rgw_frontend.h +++ b/src/rgw/rgw_frontend.h @@ -83,8 +83,7 @@ public: virtual void join() = 0; virtual void pause_for_new_config() = 0; - virtual void unpause_with_new_config(rgw::sal::Driver* driver, - rgw_auth_registry_ptr_t auth_registry) = 0; + virtual void unpause_with_new_config() = 0; }; @@ -122,11 +121,8 @@ public: pprocess->pause(); } - void unpause_with_new_config(rgw::sal::Driver* const driver, - rgw_auth_registry_ptr_t auth_registry) override { - env.driver = driver; - env.auth_registry = auth_registry; - pprocess->unpause_with_new_config(driver, std::move(auth_registry)); + void unpause_with_new_config() override { + pprocess->unpause_with_new_config(); } }; /* RGWProcessFrontend */ @@ -194,16 +190,11 @@ public: class RGWFrontendPauser : public RGWRealmReloader::Pauser { std::vector &frontends; RGWRealmReloader::Pauser* pauser; - rgw::auth::ImplicitTenants& implicit_tenants; public: RGWFrontendPauser(std::vector &frontends, - rgw::auth::ImplicitTenants& implicit_tenants, RGWRealmReloader::Pauser* pauser = nullptr) - : frontends(frontends), - pauser(pauser), - implicit_tenants(implicit_tenants) { - } + : frontends(frontends), pauser(pauser) {} void pause() override { for (auto frontend : frontends) @@ -212,13 +203,8 @@ class RGWFrontendPauser : public RGWRealmReloader::Pauser { pauser->pause(); } void resume(rgw::sal::Driver* driver) override { - /* Initialize the registry of auth strategies which will coordinate - * the dynamic reconfiguration. */ - auto auth_registry = \ - rgw::auth::StrategyRegistry::create(g_ceph_context, implicit_tenants, driver); - for (auto frontend : frontends) - frontend->unpause_with_new_config(driver, auth_registry); + frontend->unpause_with_new_config(); if (pauser) pauser->resume(driver); } diff --git a/src/rgw/rgw_process.h b/src/rgw/rgw_process.h index 4bfe86a3c861d..36f7ba924de51 100644 --- a/src/rgw/rgw_process.h +++ b/src/rgw/rgw_process.h @@ -115,11 +115,8 @@ public: m_tp.pause(); } - void unpause_with_new_config(rgw::sal::Driver* const driver, - rgw_auth_registry_ptr_t auth_registry) { - env.driver = driver; - env.auth_registry = std::move(auth_registry); - lua_manager = driver->get_lua_manager(); + void unpause_with_new_config() { + lua_manager = env.driver->get_lua_manager(); m_tp.unpause(); } diff --git a/src/rgw/rgw_realm_reloader.cc b/src/rgw/rgw_realm_reloader.cc index c79ad73672a70..f966b4b211cb0 100644 --- a/src/rgw/rgw_realm_reloader.cc +++ b/src/rgw/rgw_realm_reloader.cc @@ -27,9 +27,12 @@ static constexpr bool USE_SAFE_TIMER_CALLBACKS = false; -RGWRealmReloader::RGWRealmReloader(RGWProcessEnv& env, std::map& service_map_meta, +RGWRealmReloader::RGWRealmReloader(RGWProcessEnv& env, + const rgw::auth::ImplicitTenants& implicit_tenants, + std::map& service_map_meta, Pauser* frontends) : env(env), + implicit_tenants(implicit_tenants), service_map_meta(service_map_meta), frontends(frontends), timer(env.driver->ctx(), mutex, USE_SAFE_TIMER_CALLBACKS), @@ -172,6 +175,11 @@ void RGWRealmReloader::reload() ldpp_dout(&dp, 1) << " - usage subsystem init" << dendl; rgw_log_usage_init(cct, env.driver); + /* Initialize the registry of auth strategies which will coordinate + * the dynamic reconfiguration. */ + env.auth_registry = rgw::auth::StrategyRegistry::create( + cct, implicit_tenants, env.driver); + ldpp_dout(&dp, 1) << "Resuming frontends with new realm configuration." << dendl; frontends->resume(env.driver); diff --git a/src/rgw/rgw_realm_reloader.h b/src/rgw/rgw_realm_reloader.h index b07be97b99c73..0a28cff18603e 100644 --- a/src/rgw/rgw_realm_reloader.h +++ b/src/rgw/rgw_realm_reloader.h @@ -9,6 +9,7 @@ #include "rgw_sal_fwd.h" struct RGWProcessEnv; +namespace rgw::auth { class ImplicitTenants; } /** * RGWRealmReloader responds to new period notifications by recreating RGWRados @@ -33,7 +34,9 @@ class RGWRealmReloader : public RGWRealmWatcher::Watcher { virtual void resume(rgw::sal::Driver* driver) = 0; }; - RGWRealmReloader(RGWProcessEnv& env, std::map& service_map_meta, + RGWRealmReloader(RGWProcessEnv& env, + const rgw::auth::ImplicitTenants& implicit_tenants, + std::map& service_map_meta, Pauser* frontends); ~RGWRealmReloader() override; @@ -47,6 +50,7 @@ class RGWRealmReloader : public RGWRealmWatcher::Watcher { class C_Reload; //< Context that calls reload() RGWProcessEnv& env; + const rgw::auth::ImplicitTenants& implicit_tenants; std::map& service_map_meta; Pauser *const frontends; -- 2.39.5