]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: RGWRealmReloader reloads auth_registry
authorCasey Bodley <cbodley@redhat.com>
Wed, 2 Nov 2022 17:10:58 +0000 (13:10 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 9 Dec 2022 21:22:53 +0000 (16:22 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_appmain.cc
src/rgw/rgw_asio_frontend.cc
src/rgw/rgw_asio_frontend.h
src/rgw/rgw_frontend.h
src/rgw/rgw_process.h
src/rgw/rgw_realm_reloader.cc
src/rgw/rgw_realm_reloader.h

index 8ca2dfe6aa8d792faf019aa93d0eb1f1933ad866..a572d763ff96ff4eea61f42d1ea1763e43c102d7 100644 (file)
@@ -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<RGWPeriodPusher>(dpp, env.driver, null_yield);
-    fe_pauser = std::make_unique<RGWFrontendPauser>(fes, *(implicit_tenant_context.get()), pusher.get());
+    fe_pauser = std::make_unique<RGWFrontendPauser>(fes, pusher.get());
     rgw_pauser = std::make_unique<RGWPauser>();
     rgw_pauser->add_pauser(fe_pauser.get());
     if (lua_background) {
       rgw_pauser->add_pauser(lua_background.get());
     }
-    reloader = std::make_unique<RGWRealmReloader>(env, service_map_meta, rgw_pauser.get());
+    reloader = std::make_unique<RGWRealmReloader>(
+        env, *implicit_tenant_context, service_map_meta, rgw_pauser.get());
     realm_watcher = std::make_unique<RGWRealmWatcher>(dpp, g_ceph_context,
                                  static_cast<rgw::sal::RadosStore*>(env.driver)->svc()->zone->get_realm());
     realm_watcher->add_watcher(RGWRealmNotify::Reload, *reloader);
index 31276da64119b21f99926e455c504cd6d83c1cbe..5cfd0dc6bd20b62b59350420c9c74a945f2cbfeb 100644 (file)
@@ -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();
 }
index 85c60f3d191c11f218b61d1cd25c759bcf752847..940b717b5f2b3a10407b4c42a8c0a5b6f78650ac 100644 (file)
@@ -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
index cf766024503f54242b07511796ab14f614375021..cdb53e3971a33b963215d13f6d8f56f905321ff8 100644 (file)
@@ -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<RGWFrontend*> &frontends;
   RGWRealmReloader::Pauser* pauser;
-  rgw::auth::ImplicitTenants& implicit_tenants;
 
  public:
   RGWFrontendPauser(std::vector<RGWFrontend*> &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);
   }
index 4bfe86a3c861da357ba8c99b26066112c2dc1715..36f7ba924de51f4dbb5ab6c8c51999f65c846d88 100644 (file)
@@ -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();
   }
 
index c79ad73672a704a12a0d2f7e256f26a3cd20aa45..f966b4b211cb06f46e2456bf2bc7456c03b14ff0 100644 (file)
 static constexpr bool USE_SAFE_TIMER_CALLBACKS = false;
 
 
-RGWRealmReloader::RGWRealmReloader(RGWProcessEnv& env, std::map<std::string, std::string>& service_map_meta,
+RGWRealmReloader::RGWRealmReloader(RGWProcessEnv& env,
+                                   const rgw::auth::ImplicitTenants& implicit_tenants,
+                                   std::map<std::string, std::string>& 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);
index b07be97b99c736057d9064ffb5a99a6d44619c37..0a28cff18603e30d6396a155038142feb9bd7f30 100644 (file)
@@ -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<std::string, std::string>& service_map_meta,
+  RGWRealmReloader(RGWProcessEnv& env,
+                   const rgw::auth::ImplicitTenants& implicit_tenants,
+                   std::map<std::string, std::string>& 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<std::string, std::string>& service_map_meta;
   Pauser *const frontends;