mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-22 07:42:16 +00:00
api: failure_detector: Introduce convict-node API
Add POST /failure_detector/convict/{host} endpoint that forces local
failure detection of a given host, marking it as DOWN and dropping
connections.
Will be used in tests to speed up failure detection after killing a
node, avoiding the ~20s natural failure detection delay.
This commit is contained in:
@@ -7,6 +7,30 @@
|
||||
"application/json"
|
||||
],
|
||||
"apis":[
|
||||
{
|
||||
"path":"/failure_detector/convict/{host}",
|
||||
"operations":[
|
||||
{
|
||||
"method":"POST",
|
||||
"summary":"Forces failure detection of a given host locally, marks the node as DOWN, drops connections",
|
||||
"type":"string",
|
||||
"nickname":"convict",
|
||||
"produces":[
|
||||
"application/json"
|
||||
],
|
||||
"parameters":[
|
||||
{
|
||||
"name":"host",
|
||||
"description":"Host ID of the node to convict",
|
||||
"required":true,
|
||||
"allowMultiple":false,
|
||||
"type":"string",
|
||||
"paramType":"path"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path":"/failure_detector/phi",
|
||||
"operations":[
|
||||
|
||||
@@ -9,9 +9,12 @@
|
||||
#include "failure_detector.hh"
|
||||
#include "api/api.hh"
|
||||
#include "api/api-doc/failure_detector.json.hh"
|
||||
#include "api/validate.hh"
|
||||
#include "gms/application_state.hh"
|
||||
#include "gms/gossiper.hh"
|
||||
|
||||
extern logging::logger apilog;
|
||||
|
||||
namespace api {
|
||||
using namespace seastar::httpd;
|
||||
|
||||
@@ -64,6 +67,15 @@ void set_failure_detector(http_context& ctx, routes& r, gms::gossiper& g) {
|
||||
return make_ready_future<json::json_return_type>(8);
|
||||
});
|
||||
|
||||
fd::convict.set(r, [&g] (std::unique_ptr<request> req) -> future<json::json_return_type> {
|
||||
return g.container().invoke_on(0, [req = std::move(req)] (gms::gossiper& g) -> future<json::json_return_type> {
|
||||
auto host_id = validate_host_id(req->get_path_param("host"));
|
||||
apilog.info("Convict {}", host_id);
|
||||
co_await g.convict(host_id);
|
||||
co_return seastar::json::json_void();
|
||||
});
|
||||
});
|
||||
|
||||
fd::get_simple_states.set(r, [&g] (std::unique_ptr<request> req) {
|
||||
return g.container().invoke_on(0, [] (gms::gossiper& g) {
|
||||
std::vector<fd::mapper> nodes_status;
|
||||
@@ -114,6 +126,7 @@ void unset_failure_detector(http_context& ctx, routes& r) {
|
||||
fd::set_phi_convict_threshold.unset(r);
|
||||
fd::get_endpoint_state.unset(r);
|
||||
fd::get_endpoint_phi_values.unset(r);
|
||||
fd::convict.unset(r);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user