From: Martin Schwenke Date: Mon, 12 May 2025 02:00:28 +0000 (+1000) Subject: ctdb-daemon: Add configuration option shutdown failover timeout X-Git-Tag: tevent-0.17.0~74 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dd9b73119afd3a0c60c87c938b5aefc766ca78d2;p=thirdparty%2Fsamba.git ctdb-daemon: Add configuration option shutdown failover timeout Allows the timeout for failover during shutdown to be modified. Defaults to 10s. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15858 Signed-off-by: Martin Schwenke SQ Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/conf/ctdb_config.c b/ctdb/conf/ctdb_config.c index f75bf374a80..ba478550f65 100644 --- a/ctdb/conf/ctdb_config.c +++ b/ctdb/conf/ctdb_config.c @@ -110,6 +110,10 @@ static void setup_config_pointers(struct conf_context *conf) FAILOVER_CONF_SECTION, FAILOVER_CONF_DISABLED, &ctdb_config.failover_disabled); + conf_assign_integer_pointer(conf, + FAILOVER_CONF_SECTION, + FAILOVER_CONF_SHUTDOWN_FAILOVER_TIMEOUT, + &ctdb_config.shutdown_failover_timeout); /* * Legacy diff --git a/ctdb/conf/ctdb_config.h b/ctdb/conf/ctdb_config.h index 575e3045fa4..ee04a174d13 100644 --- a/ctdb/conf/ctdb_config.h +++ b/ctdb/conf/ctdb_config.h @@ -44,6 +44,7 @@ struct ctdb_config { /* Failover */ bool failover_disabled; + int shutdown_failover_timeout; /* Legacy */ bool realtime_scheduling; diff --git a/ctdb/conf/failover_conf.c b/ctdb/conf/failover_conf.c index 3f9f749fcae..01b0b617827 100644 --- a/ctdb/conf/failover_conf.c +++ b/ctdb/conf/failover_conf.c @@ -50,4 +50,10 @@ void failover_conf_init(struct conf_context *conf) FAILOVER_CONF_DISABLED, false, check_static_boolean_change); + + conf_define_integer(conf, + FAILOVER_CONF_SECTION, + FAILOVER_CONF_SHUTDOWN_FAILOVER_TIMEOUT, + 10, + NULL); } diff --git a/ctdb/conf/failover_conf.h b/ctdb/conf/failover_conf.h index d7ac0ac507d..34ab9c193b3 100644 --- a/ctdb/conf/failover_conf.h +++ b/ctdb/conf/failover_conf.h @@ -25,6 +25,8 @@ #define FAILOVER_CONF_SECTION "failover" #define FAILOVER_CONF_DISABLED "disabled" +#define FAILOVER_CONF_SHUTDOWN_FAILOVER_TIMEOUT "shutdown failover timeout" + void failover_conf_init(struct conf_context *conf); diff --git a/ctdb/doc/ctdb.conf.5.xml b/ctdb/doc/ctdb.conf.5.xml index 7bdbc038f7d..8666d92f830 100644 --- a/ctdb/doc/ctdb.conf.5.xml +++ b/ctdb/doc/ctdb.conf.5.xml @@ -496,6 +496,24 @@ + + shutdown failover timeout = TIMEOUT + + + CTDB will wait for TIMEOUT seconds for failover to + complete during shutdown. This allows NFS servers on + other nodes to go into grace during graceful shutdown of a + node. + + + Set this to 0 to disable explicit failover on shutdown. + + + Default: 10 + + + + diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c index d6a65e13de3..650dc454574 100644 --- a/ctdb/server/ctdb_daemon.c +++ b/ctdb/server/ctdb_daemon.c @@ -54,6 +54,7 @@ #include "common/sock_io.h" #include "common/srvid.h" +#include "conf/ctdb_config.h" #include "conf/node.h" struct ctdb_client_pid_list { @@ -2252,8 +2253,6 @@ static uint64_t ctdb_srvid_id(struct ctdb_context *ctdb, uint32_t extra_mask) * timeout. */ -#define CTDB_SHUTDOWN_FAILOVER_TIMEOUT 10 - struct shutdown_takeover_state { bool takeover_done; bool timed_out; @@ -2348,7 +2347,7 @@ static void ctdb_shutdown_takeover(struct ctdb_context *ctdb) }; int ret = 0; - if (CTDB_SHUTDOWN_FAILOVER_TIMEOUT <= 0) { + if (ctdb_config.shutdown_failover_timeout <= 0) { return; } @@ -2371,7 +2370,7 @@ static void ctdb_shutdown_takeover(struct ctdb_context *ctdb) state.te = tevent_add_timer( ctdb->ev, ctdb->srv, - timeval_current_ofs(CTDB_SHUTDOWN_FAILOVER_TIMEOUT, 0), + timeval_current_ofs(ctdb_config.shutdown_failover_timeout, 0), shutdown_timeout_handler, &state); if (state.te == NULL) { diff --git a/ctdb/tests/UNIT/cunit/config_test_001.sh b/ctdb/tests/UNIT/cunit/config_test_001.sh index 9e7ac462618..fac4e15612a 100755 --- a/ctdb/tests/UNIT/cunit/config_test_001.sh +++ b/ctdb/tests/UNIT/cunit/config_test_001.sh @@ -49,6 +49,7 @@ ok <