]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-daemon: Add configuration option shutdown failover timeout
authorMartin Schwenke <mschwenke@ddn.com>
Mon, 12 May 2025 02:00:28 +0000 (12:00 +1000)
committerMartin Schwenke <martins@samba.org>
Thu, 29 May 2025 09:56:31 +0000 (09:56 +0000)
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 <mschwenke@ddn.com>
SQ

Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/conf/ctdb_config.c
ctdb/conf/ctdb_config.h
ctdb/conf/failover_conf.c
ctdb/conf/failover_conf.h
ctdb/doc/ctdb.conf.5.xml
ctdb/server/ctdb_daemon.c
ctdb/tests/UNIT/cunit/config_test_001.sh

index f75bf374a8083a6bf2abc947a831406f0f1773fc..ba478550f6584f2776d8fdfe939bcbb437b07548 100644 (file)
@@ -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
index 575e3045fa4853a1948dcdc0fbf9926c888c210c..ee04a174d134df27dd428adb3136ad51590bbca3 100644 (file)
@@ -44,6 +44,7 @@ struct ctdb_config {
 
        /* Failover */
        bool failover_disabled;
+       int shutdown_failover_timeout;
 
        /* Legacy */
        bool realtime_scheduling;
index 3f9f749fcae9e08d765535464ade3edec196c409..01b0b617827a024df174f57238be823fb0814c4f 100644 (file)
@@ -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);
 }
index d7ac0ac507db86d10d86165ba8623c28d1582631..34ab9c193b336e5759444930a9daba3e81334c21 100644 (file)
@@ -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);
 
index 7bdbc038f7d25ce162415d805f619431ce02e092..8666d92f8306f6dd985789561734578d4350d6e8 100644 (file)
        </listitem>
       </varlistentry>
 
+      <varlistentry>
+       <term>shutdown failover timeout = <parameter>TIMEOUT</parameter></term>
+       <listitem>
+         <para>
+           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.
+         </para>
+         <para>
+           Set this to 0 to disable explicit failover on shutdown.
+         </para>
+         <para>
+           Default: <literal>10</literal>
+         </para>
+       </listitem>
+      </varlistentry>
+
     </variablelist>
   </refsect1>
 
index d6a65e13de353c416f8c2011b7eaf905d0098603..650dc454574ac85d2793ffeb2f457ab1da8cbff3 100644 (file)
@@ -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) {
index 9e7ac46261885a8fca8da2f610b3327a8ebf8913..fac4e15612aa169f974ceeb7281d1b3d94739fb0 100755 (executable)
@@ -49,6 +49,7 @@ ok <<EOF
        # debug script = 
 [failover]
        # disabled = false
+       # shutdown failover timeout = 10
 [legacy]
        # realtime scheduling = true
        # lmaster capability = true