File jsc#ECO-1611-0006-Feature-stonith_admin-add-delay-option-to-support-en.patch of Package pacemaker.26926
From 79de5db4ea3f9154391a168eb70d60f7fb535f8b Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Wed, 18 Mar 2020 15:44:24 +0100
Subject: [PATCH 6/9] Feature: stonith_admin: add --delay option to support
enforced fencing delay
It can be specified with --fence, --reboot or --unfence commands.
The default value -1 disables enforced fencing delay.
---
include/pcmki/pcmki_fence.h | 4 +++-
lib/pacemaker/pcmk_fence.c | 24 +++++++++++++++---------
tools/stonith_admin.c | 14 ++++++++++----
3 files changed, 28 insertions(+), 14 deletions(-)
Index: pacemaker-2.0.1+20190417.13d370ca9/tools/stonith_admin.c
===================================================================
--- pacemaker-2.0.1+20190417.13d370ca9.orig/tools/stonith_admin.c
+++ pacemaker-2.0.1+20190417.13d370ca9/tools/stonith_admin.c
@@ -166,6 +166,10 @@ static struct crm_option long_options[]
"Operation timeout in seconds (default 120;\n"
"\t\t\tused with most commands)."
},
+ { "delay", required_argument, NULL, 'y',
+ "Enforced fencing delay in seconds (default -1 (disabled);\n"
+ "\t\t\twith --fence, --reboot, --unfence)."
+ },
{ "as-node-id", no_argument, NULL, 'n',
"(Advanced) The supplied node is the corosync node ID\n"
"\t\t\t(with --last)."
@@ -190,6 +194,7 @@ struct {
char *name;
int timeout;
int tolerance;
+ int delay;
int rc;
} async_fence_data;
@@ -254,11 +259,13 @@ async_fence_helper(gpointer user_data)
st->cmds->register_notification(st, T_STONITH_NOTIFY_FENCE, notify_callback);
- call_id = st->cmds->fence(st,
- st_opt_allow_suicide,
- async_fence_data.target,
- async_fence_data.action,
- async_fence_data.timeout, async_fence_data.tolerance);
+ call_id = st->cmds->fence_with_delay(st,
+ st_opt_allow_suicide,
+ async_fence_data.target,
+ async_fence_data.action,
+ async_fence_data.timeout,
+ async_fence_data.tolerance,
+ async_fence_data.delay);
if (call_id < 0) {
g_main_loop_quit(mainloop);
@@ -274,7 +281,8 @@ async_fence_helper(gpointer user_data)
}
static int
-mainloop_fencing(stonith_t * st, const char *target, const char *action, int timeout, int tolerance)
+mainloop_fencing(stonith_t * st, const char *target, const char *action,
+ int timeout, int tolerance, int delay)
{
crm_trigger_t *trig;
@@ -283,6 +291,7 @@ mainloop_fencing(stonith_t * st, const c
async_fence_data.action = action;
async_fence_data.timeout = timeout;
async_fence_data.tolerance = tolerance;
+ async_fence_data.delay = delay;
async_fence_data.rc = -1;
trig = mainloop_add_trigger(G_PRIORITY_HIGH, async_fence_helper, NULL);
@@ -453,6 +462,7 @@ main(int argc, char **argv)
int verbose = 0;
int argerr = 0;
int timeout = 120;
+ int delay = -1;
int option_index = 0;
int fence_level = 0;
int no_connect = 0;
@@ -543,6 +553,9 @@ main(int argc, char **argv)
case 't':
timeout = crm_atoi(optarg, NULL);
break;
+ case 'y':
+ delay = crm_atoi(optarg, NULL);
+ break;
case 'B':
case 'F':
case 'U':
@@ -726,13 +739,13 @@ main(int argc, char **argv)
rc = st->cmds->confirm(st, st_opts, target);
break;
case 'B':
- rc = mainloop_fencing(st, target, "reboot", timeout, tolerance);
+ rc = mainloop_fencing(st, target, "reboot", timeout, tolerance, delay);
break;
case 'F':
- rc = mainloop_fencing(st, target, "off", timeout, tolerance);
+ rc = mainloop_fencing(st, target, "off", timeout, tolerance, delay);
break;
case 'U':
- rc = mainloop_fencing(st, target, "on", timeout, tolerance);
+ rc = mainloop_fencing(st, target, "on", timeout, tolerance, delay);
break;
case 'h':
{