mirror of
https://github.com/ceph/ceph
synced 2025-02-24 03:27:10 +00:00
Merge pull request #48331 from tchaikov/crimson-stop
crimson/osd: shutdown on osdmaps' demand Reviewed-by: Samuel Just <sjust@redhat.com>
This commit is contained in:
commit
895a2f3208
@ -8,7 +8,6 @@
|
||||
#include <fstream>
|
||||
#include <random>
|
||||
|
||||
#include <seastar/apps/lib/stop_signal.hh>
|
||||
#include <seastar/core/app-template.hh>
|
||||
#include <seastar/core/print.hh>
|
||||
#include <seastar/core/prometheus.hh>
|
||||
@ -27,6 +26,7 @@
|
||||
#include "crimson/common/fatal_signal.h"
|
||||
#include "crimson/mon/MonClient.h"
|
||||
#include "crimson/net/Messenger.h"
|
||||
#include "crimson/osd/stop_signal.h"
|
||||
#include "global/pidfile.h"
|
||||
#include "osd.h"
|
||||
|
||||
@ -295,7 +295,8 @@ int main(int argc, const char* argv[])
|
||||
local_conf().get_config_values()).get();
|
||||
|
||||
crimson::osd::OSD osd(
|
||||
whoami, nonce, std::ref(*store), cluster_msgr, client_msgr,
|
||||
whoami, nonce, std::ref(should_stop.abort_source()),
|
||||
std::ref(*store), cluster_msgr, client_msgr,
|
||||
hb_front_msgr, hb_back_msgr);
|
||||
|
||||
if (config.count("mkkey")) {
|
||||
|
@ -75,6 +75,7 @@ using crimson::os::FuturizedStore;
|
||||
namespace crimson::osd {
|
||||
|
||||
OSD::OSD(int id, uint32_t nonce,
|
||||
seastar::abort_source& abort_source,
|
||||
crimson::os::FuturizedStore& store,
|
||||
crimson::net::MessengerRef cluster_msgr,
|
||||
crimson::net::MessengerRef public_msgr,
|
||||
@ -82,6 +83,7 @@ OSD::OSD(int id, uint32_t nonce,
|
||||
crimson::net::MessengerRef hb_back_msgr)
|
||||
: whoami{id},
|
||||
nonce{nonce},
|
||||
abort_source{abort_source},
|
||||
// do this in background
|
||||
beacon_timer{[this] { (void)send_beacon(); }},
|
||||
cluster_msgr{cluster_msgr},
|
||||
@ -1166,9 +1168,8 @@ seastar::future<> OSD::restart()
|
||||
|
||||
seastar::future<> OSD::shutdown()
|
||||
{
|
||||
// TODO
|
||||
superblock.mounted = boot_epoch;
|
||||
superblock.clean_thru = osdmap->get_epoch();
|
||||
logger().info("shutting down per osdmap");
|
||||
abort_source.request_abort();
|
||||
return seastar::now();
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <seastar/core/abort_source.hh>
|
||||
#include <seastar/core/future.hh>
|
||||
#include <seastar/core/shared_future.hh>
|
||||
#include <seastar/core/gate.hh>
|
||||
@ -62,6 +63,7 @@ class OSD final : public crimson::net::Dispatcher,
|
||||
private crimson::mgr::WithStats {
|
||||
const int whoami;
|
||||
const uint32_t nonce;
|
||||
seastar::abort_source& abort_source;
|
||||
seastar::timer<seastar::lowres_clock> beacon_timer;
|
||||
// talk with osd
|
||||
crimson::net::MessengerRef cluster_msgr;
|
||||
@ -116,6 +118,7 @@ class OSD final : public crimson::net::Dispatcher,
|
||||
|
||||
public:
|
||||
OSD(int id, uint32_t nonce,
|
||||
seastar::abort_source& abort_source,
|
||||
crimson::os::FuturizedStore& store,
|
||||
crimson::net::MessengerRef cluster_msgr,
|
||||
crimson::net::MessengerRef client_msgr,
|
||||
|
83
src/crimson/osd/stop_signal.h
Normal file
83
src/crimson/osd/stop_signal.h
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is open source software, licensed to you under the terms
|
||||
* of the Apache License, Version 2.0 (the "License"). See the NOTICE file
|
||||
* distributed with this work for additional information regarding copyright
|
||||
* ownership. You may not use this file except in compliance with the License.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020 Cloudius Systems, Ltd.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <seastar/core/abort_source.hh>
|
||||
#include <seastar/core/reactor.hh>
|
||||
#include <seastar/core/condition-variable.hh>
|
||||
|
||||
/// Seastar apps lib namespace
|
||||
|
||||
namespace seastar_apps_lib {
|
||||
|
||||
|
||||
/// \brief Futurized SIGINT/SIGTERM signals handler class
|
||||
///
|
||||
/// Seastar-style helper class that allows easy waiting for SIGINT/SIGTERM signals
|
||||
/// from your app.
|
||||
///
|
||||
/// Example:
|
||||
/// \code
|
||||
/// #include <seastar/apps/lib/stop_signal.hh>
|
||||
/// ...
|
||||
/// int main() {
|
||||
/// ...
|
||||
/// seastar::thread th([] {
|
||||
/// seastar_apps_lib::stop_signal stop_signal;
|
||||
/// <some code>
|
||||
/// stop_signal.wait().get(); // this will wait till we receive SIGINT or SIGTERM signal
|
||||
/// });
|
||||
/// \endcode
|
||||
class stop_signal {
|
||||
seastar::condition_variable _cond;
|
||||
seastar::abort_source _abort_source;
|
||||
|
||||
private:
|
||||
void on_signal() {
|
||||
if (stopping()) {
|
||||
return;
|
||||
}
|
||||
_abort_source.request_abort();
|
||||
_cond.broadcast();
|
||||
}
|
||||
public:
|
||||
stop_signal() {
|
||||
seastar::engine().handle_signal(SIGINT, [this] { on_signal(); });
|
||||
seastar::engine().handle_signal(SIGTERM, [this] { on_signal(); });
|
||||
}
|
||||
~stop_signal() {
|
||||
// There's no way to unregister a handler yet, so register a no-op handler instead.
|
||||
seastar::engine().handle_signal(SIGINT, [] {});
|
||||
seastar::engine().handle_signal(SIGTERM, [] {});
|
||||
}
|
||||
seastar::future<> wait() {
|
||||
return _cond.wait([this] { return _abort_source.abort_requested(); });
|
||||
}
|
||||
bool stopping() const {
|
||||
return _abort_source.abort_requested();
|
||||
}
|
||||
auto& abort_source() {
|
||||
return _abort_source;
|
||||
}
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user