]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/Mgr: remove shutdown() and handle_signal() 54319/head
authorRamana Raja <rraja@redhat.com>
Thu, 2 Nov 2023 18:38:02 +0000 (14:38 -0400)
committerRamana Raja <rraja@redhat.com>
Fri, 3 Nov 2023 13:52:08 +0000 (09:52 -0400)
Mgr::shutdown() and Mgr::handle_signal() are never called since
3363a10. The mgr just exits on SIGINT or SIGTERM.

Also found and removed other unreachable code associated with
shutdown in mgr codebase.

Fixes: https://tracker.ceph.com/issues/63410
Signed-off-by: Ramana Raja <rraja@redhat.com>
12 files changed:
src/mgr/ActivePyModules.cc
src/mgr/ActivePyModules.h
src/mgr/ClusterState.cc
src/mgr/ClusterState.h
src/mgr/DaemonServer.cc
src/mgr/DaemonServer.h
src/mgr/Mgr.cc
src/mgr/Mgr.h
src/mgr/MgrStandby.cc
src/mgr/MgrStandby.h
src/mgr/PyModuleRegistry.cc
src/mgr/PyModuleRegistry.h

index 45038e734afcf90c15c0e54e01757ddb4aeef7b7..2f4f6bd1e80bbee64e74cec6c90e5a63df545340 100644 (file)
@@ -555,42 +555,6 @@ void ActivePyModules::start_one(PyModuleRef py_module)
   }));
 }
 
-void ActivePyModules::shutdown()
-{
-  std::lock_guard locker(lock);
-
-  // Stop per active module finisher thread
-  for (auto& [name, module] : modules) {
-      dout(4) << "Stopping active module " << name << " finisher thread" << dendl;
-      module->finisher.wait_for_empty();
-      module->finisher.stop();
-  }
-
-  // Signal modules to drop out of serve() and/or tear down resources
-  for (auto& [name, module] : modules) {
-    lock.unlock();
-    dout(10) << "calling module " << name << " shutdown()" << dendl;
-    module->shutdown();
-    dout(10) << "module " << name << " shutdown() returned" << dendl;
-    lock.lock();
-  }
-
-  // For modules implementing serve(), finish the threads where we
-  // were running that.
-  for (auto& [name, module] : modules) {
-    lock.unlock();
-    dout(10) << "joining module " << name << dendl;
-    module->thread.join();
-    dout(10) << "joined module " << name << dendl;
-    lock.lock();
-  }
-
-  cmd_finisher.wait_for_empty();
-  cmd_finisher.stop();
-
-  modules.clear();
-}
-
 void ActivePyModules::notify_all(const std::string &notify_type,
                      const std::string &notify_id)
 {
index 283f96a6ed95943edc3e84ad3cd31240d7d151c6..d6ade4849f78a53b78dff4fc7f5a4dec1567e0e2 100644 (file)
@@ -216,7 +216,6 @@ public:
       std::string *err);
 
   int init();
-  void shutdown();
 
   void start_one(PyModuleRef py_module);
 
index 7f811a5e41597852c91cd031e9f5e60f8b67e977..6b106268efc48737187de5187ccd1fd07322650d 100644 (file)
@@ -225,14 +225,6 @@ void ClusterState::final_init()
   ceph_assert(r == 0);
 }
 
-void ClusterState::shutdown()
-{
-  // unregister commands
-  g_ceph_context->get_admin_socket()->unregister_commands(asok_hook);
-  delete asok_hook;
-  asok_hook = NULL;
-}
-
 bool ClusterState::asok_command(
   std::string_view admin_command,
   const cmdmap_t& cmdmap,
index 7939cd8eb8f0f7911b9f0d6c0aa218646bd67437..2beac362b472e4002d46869375f4efc87839a963 100644 (file)
@@ -152,7 +152,6 @@ public:
   }
 
   void final_init();
-  void shutdown();
   bool asok_command(std::string_view admin_command,
                    const cmdmap_t& cmdmap,
                    Formatter *f,
index a4e85e2fc421f32d6278c389fd31c9c5d4182fc9..b1781316f82814f4ecde9ba517671e403548dc38 100644 (file)
@@ -98,7 +98,6 @@ DaemonServer::DaemonServer(MonClient *monc_,
       audit_clog(audit_clog_),
       pgmap_ready(false),
       timer(g_ceph_context, lock),
-      shutting_down(false),
       tick_event(nullptr),
       osd_perf_metric_collector_listener(this),
       osd_perf_metric_collector(osd_perf_metric_collector_listener),
@@ -358,11 +357,6 @@ void DaemonServer::schedule_tick_locked(double delay_sec)
     tick_event = nullptr;
   }
 
-  // on shutdown start rejecting explicit requests to send reports that may
-  // originate from python land which may still be running.
-  if (shutting_down)
-    return;
-
   tick_event = timer.add_event_after(delay_sec,
     new LambdaContext([this](int r) {
       tick();
@@ -407,19 +401,6 @@ void DaemonServer::handle_mds_perf_metric_query_updated()
       }));
 }
 
-void DaemonServer::shutdown()
-{
-  dout(10) << "begin" << dendl;
-  msgr->shutdown();
-  msgr->wait();
-  cluster_state.shutdown();
-  dout(10) << "done" << dendl;
-
-  std::lock_guard l(lock);
-  shutting_down = true;
-  timer.shutdown();
-}
-
 static DaemonKey key_from_service(
   const std::string& service_name,
   int peer_type,
index a7b6456100439ec3f8d20058a9c34ee59fc6589d..43125533e745a8e910fe7bc8a8340afe4d2673bb 100644 (file)
@@ -190,7 +190,6 @@ private:
   void maybe_ready(int32_t osd_id);
 
   SafeTimer timer;
-  bool shutting_down;
   Context *tick_event;
   void tick();
   void schedule_tick_locked(double delay_sec);
@@ -255,7 +254,6 @@ private:
 
 public:
   int init(uint64_t gid, entity_addrvec_t client_addrs);
-  void shutdown();
 
   entity_addrvec_t get_myaddrs() const;
 
index 63ad530fae2fc5b16e19cb856030c876bb211c6c..5bd2ffb246c74b8499125fa6d0a44a23f87a5d0c 100644 (file)
@@ -214,12 +214,6 @@ std::map<std::string, std::string> Mgr::load_store()
   return loaded;
 }
 
-void Mgr::handle_signal(int signum)
-{
-  ceph_assert(signum == SIGINT || signum == SIGTERM);
-  shutdown();
-}
-
 static void handle_mgr_signal(int signum)
 {
   derr << " *** Got signal " << sig_str(signum) << " ***" << dendl;
@@ -490,27 +484,6 @@ void Mgr::load_all_metadata()
   }
 }
 
-
-void Mgr::shutdown()
-{
-  dout(10) << "mgr shutdown init" << dendl;
-  finisher.queue(new LambdaContext([&](int) {
-    {
-      std::lock_guard l(lock);
-      // First stop the server so that we're not taking any more incoming
-      // requests
-      server.shutdown();
-    }
-    // after the messenger is stopped, signal modules to shutdown via finisher
-    py_module_registry->active_shutdown();
-  }));
-
-  // Then stop the finisher to ensure its enqueued contexts aren't going
-  // to touch references to the things we're about to tear down
-  finisher.wait_for_empty();
-  finisher.stop();
-}
-
 void Mgr::handle_osd_map()
 {
   ceph_assert(ceph_mutex_is_locked_by_me(lock));
index 22ebdb680410e89e335ed2232eac435fba68fd2b..65931c331f3638d8a5075a7077f3141ab48c4c80 100644 (file)
@@ -94,9 +94,6 @@ public:
   bool ms_dispatch2(const ceph::ref_t<Message>& m);
 
   void background_init(Context *completion);
-  void shutdown();
-
-  void handle_signal(int signum);
 
   std::map<std::string, std::string> get_services() const;
 
index 545624eb79b0522e178f5c6a97d1fb025e671d20..052e68681772b68da28cae60af24a97838bd1db6 100644 (file)
@@ -295,41 +295,6 @@ void MgrStandby::tick()
   ));
 }
 
-void MgrStandby::shutdown()
-{
-  finisher.queue(new LambdaContext([&](int) {
-    std::lock_guard l(lock);
-
-    dout(4) << "Shutting down" << dendl;
-
-    py_module_registry.shutdown();
-    // stop sending beacon first, I use monc to talk with monitors
-    timer.shutdown();
-    // client uses monc and objecter
-    client.shutdown();
-    mgrc.shutdown();
-    // Stop asio threads, so leftover events won't call into shut down
-    // monclient/objecter.
-    poolctx.finish();
-    // stop monc, so mon won't be able to instruct me to shutdown/activate after
-    // the active_mgr is stopped
-    monc.shutdown();
-    if (active_mgr) {
-      active_mgr->shutdown();
-    }
-    // objecter is used by monc and active_mgr
-    objecter.shutdown();
-    // client_messenger is used by all of them, so stop it in the end
-    client_messenger->shutdown();
-  }));
-
-  // Then stop the finisher to ensure its enqueued contexts aren't going
-  // to touch references to the things we're about to tear down
-  finisher.wait_for_empty();
-  finisher.stop();
-  mgr_perf_stop(g_ceph_context);
-}
-
 void MgrStandby::respawn()
 {
   // --- WARNING TO FUTURE COPY/PASTERS ---
index 0f06e3074a00439d605fe1a5b4cd3ee484322f2b..5d238c8557796c2b43e44568acd530dc688c0096 100644 (file)
@@ -79,7 +79,6 @@ public:
   bool ms_handle_refused(Connection *con) override;
 
   int init();
-  void shutdown();
   void respawn();
   int main(std::vector<const char *> args);
   void tick();
index f5f5008023fc1009455bfce1723c13f5915f35ca..eb2d2babe75fa6da4ecb751c2146caa412530ae7 100644 (file)
@@ -217,53 +217,6 @@ void PyModuleRegistry::active_start(
   }
 }
 
-void PyModuleRegistry::active_shutdown()
-{
-  std::lock_guard locker(lock);
-
-  if (active_modules != nullptr) {
-    active_modules->shutdown();
-    active_modules.reset();
-  }
-}
-
-void PyModuleRegistry::shutdown()
-{
-  std::lock_guard locker(lock);
-
-  if (standby_modules != nullptr) {
-    standby_modules->shutdown();
-    standby_modules.reset();
-  }
-
-  // Ideally, now, we'd be able to do this for all modules:
-  //
-  //    Py_EndInterpreter(pMyThreadState);
-  //    PyThreadState_Swap(pMainThreadState);
-  //
-  // Unfortunately, if the module has any other *python* threads active
-  // at this point, Py_EndInterpreter() will abort with:
-  //
-  //    Fatal Python error: Py_EndInterpreter: not the last thread
-  //
-  // This can happen when using CherryPy in a module, becuase CherryPy
-  // runs an extra thread as a timeout monitor, which spends most of its
-  // life inside a time.sleep(60).  Unless you are very, very lucky with
-  // the timing calling this destructor, that thread will still be stuck
-  // in a sleep, and Py_EndInterpreter() will abort.
-  //
-  // This could of course also happen with a poorly written module which
-  // made no attempt to clean up any additional threads it created.
-  //
-  // The safest thing to do is just not call Py_EndInterpreter(), and
-  // let Py_Finalize() kill everything after all modules are shut down.
-
-  modules.clear();
-
-  PyEval_RestoreThread(pMainThreadState);
-  Py_Finalize();
-}
-
 std::vector<std::string> PyModuleRegistry::probe_modules(const std::string &path) const
 {
   const auto opt = g_conf().get_val<std::string>("mgr_disabled_modules");
index 9af9abb57625f047f81f6fed0ca76810948f2983..9d6d9c2cdd0210b9b0077ffd4be3f996a7c65d29 100644 (file)
@@ -122,9 +122,6 @@ public:
     return standby_modules != nullptr;
   }
 
-  void active_shutdown();
-  void shutdown();
-
   std::vector<MonCommand> get_commands() const;
   std::vector<ModuleCommand> get_py_commands() const;