rbd-mirror: reopen all contexts logs on SIGHUP

Signed-off-by: Mykola Golub <mgolub@suse.com>
This commit is contained in:
Mykola Golub 2019-12-31 09:57:15 +00:00
parent f3b4919177
commit 9ddf111506
4 changed files with 39 additions and 5 deletions

View File

@ -1,6 +1,8 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#include <signal.h>
#include <boost/range/adaptor/map.hpp>
#include "common/Formatter.h"
@ -498,10 +500,26 @@ Mirror::~Mirror()
void Mirror::handle_signal(int signum)
{
m_stopping = true;
{
std::lock_guard l{m_lock};
dout(20) << signum << dendl;
std::lock_guard l{m_lock};
switch (signum) {
case SIGHUP:
for (auto &it : m_pool_replayers) {
it.second->reopen_logs();
}
g_ceph_context->reopen_logs();
break;
case SIGINT:
case SIGTERM:
m_stopping = true;
m_cond.notify_all();
break;
default:
ceph_abort_msgf("unexpected signal %d", signum);
}
}

View File

@ -248,6 +248,8 @@ bool PoolReplayer<I>::is_running() const {
template <typename I>
void PoolReplayer<I>::init(const std::string& site_name) {
std::lock_guard locker{m_lock};
ceph_assert(!m_pool_replayer_thread.is_started());
// reset state
@ -697,6 +699,19 @@ int PoolReplayer<I>::list_mirroring_namespaces(
return 0;
}
template <typename I>
void PoolReplayer<I>::reopen_logs()
{
std::lock_guard locker{m_lock};
if (m_local_rados) {
reinterpret_cast<CephContext *>(m_local_rados->cct())->reopen_logs();
}
if (m_remote_rados) {
reinterpret_cast<CephContext *>(m_remote_rados->cct())->reopen_logs();
}
}
template <typename I>
void PoolReplayer<I>::namespace_replayer_acquire_leader(const std::string &name,
Context *on_finish) {

View File

@ -64,6 +64,7 @@ public:
void restart();
void flush();
void release_leader();
void reopen_logs();
private:
/**

View File

@ -56,7 +56,7 @@ int main(int argc, const char **argv)
common_init_finish(g_ceph_context);
init_async_signal_handler();
register_async_signal_handler(SIGHUP, sighup_handler);
register_async_signal_handler(SIGHUP, handle_signal);
register_async_signal_handler_oneshot(SIGINT, handle_signal);
register_async_signal_handler_oneshot(SIGTERM, handle_signal);
@ -90,7 +90,7 @@ int main(int argc, const char **argv)
mirror->run();
cleanup:
unregister_async_signal_handler(SIGHUP, sighup_handler);
unregister_async_signal_handler(SIGHUP, handle_signal);
unregister_async_signal_handler(SIGINT, handle_signal);
unregister_async_signal_handler(SIGTERM, handle_signal);
shutdown_async_signal_handler();