2013-05-21 14:29:04 +02:00
|
|
|
commit 1e01228825eb8d4449edfbb1a1fa0c38fab4d5e6
|
|
|
|
Author: Gao,Yan <ygao@suse.com>
|
|
|
|
Date: Thu Sep 6 15:14:58 2012 +0800
|
|
|
|
|
|
|
|
Medium: stonith: Expose IDs of stonith resources to stonith agents through "$CRM_meta_st_device_id" environment variable
|
|
|
|
|
2016-02-29 15:41:59 +01:00
|
|
|
Index: pacemaker-1.1.14+git20160209.8d93feb/fencing/commands.c
|
2013-05-21 14:29:04 +02:00
|
|
|
===================================================================
|
2016-02-29 15:41:59 +01:00
|
|
|
--- pacemaker-1.1.14+git20160209.8d93feb.orig/fencing/commands.c
|
|
|
|
+++ pacemaker-1.1.14+git20160209.8d93feb/fencing/commands.c
|
|
|
|
@@ -826,6 +826,7 @@ build_device_from_xml(xmlNode * msg)
|
2013-05-21 14:29:04 +02:00
|
|
|
device->id, device->on_target_actions);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ g_hash_table_insert(device->params, strdup(CRM_META "_" F_STONITH_DEVICE), strdup(device->id));
|
|
|
|
device->work = mainloop_add_trigger(G_PRIORITY_HIGH, stonith_device_dispatch, device);
|
|
|
|
/* TODO: Hook up priority */
|
|
|
|
|
2016-02-29 15:41:59 +01:00
|
|
|
Index: pacemaker-1.1.14+git20160209.8d93feb/lib/fencing/st_client.c
|
2013-05-21 14:29:04 +02:00
|
|
|
===================================================================
|
2016-02-29 15:41:59 +01:00
|
|
|
--- pacemaker-1.1.14+git20160209.8d93feb.orig/lib/fencing/st_client.c
|
|
|
|
+++ pacemaker-1.1.14+git20160209.8d93feb/lib/fencing/st_client.c
|
2013-05-21 14:29:04 +02:00
|
|
|
@@ -54,6 +54,7 @@ struct stonith_action_s {
|
|
|
|
char *action;
|
|
|
|
char *victim;
|
|
|
|
char *args;
|
|
|
|
+ char *dev_id;
|
|
|
|
int timeout;
|
|
|
|
int async;
|
|
|
|
void *userdata;
|
2016-02-29 15:41:59 +01:00
|
|
|
@@ -679,6 +680,7 @@ stonith_action_destroy(stonith_action_t
|
2013-05-21 14:29:04 +02:00
|
|
|
free(action->args);
|
|
|
|
free(action->action);
|
|
|
|
free(action->victim);
|
|
|
|
+ free(action->dev_id);
|
|
|
|
free(action);
|
|
|
|
}
|
|
|
|
|
2016-02-29 15:41:59 +01:00
|
|
|
@@ -706,6 +708,8 @@ stonith_action_create(const char *agent,
|
2013-05-21 14:29:04 +02:00
|
|
|
if (device_args) {
|
|
|
|
char buffer[512];
|
|
|
|
const char *value = NULL;
|
|
|
|
+ const char *st_dev_id_key = CRM_META "_" F_STONITH_DEVICE;
|
|
|
|
+ const char *st_dev_id_value = NULL;
|
|
|
|
|
|
|
|
snprintf(buffer, 511, "pcmk_%s_retries", _action);
|
|
|
|
value = g_hash_table_lookup(device_args, buffer);
|
2016-02-29 15:41:59 +01:00
|
|
|
@@ -713,6 +717,11 @@ stonith_action_create(const char *agent,
|
2013-05-21 14:29:04 +02:00
|
|
|
if (value) {
|
|
|
|
action->max_retries = atoi(value);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ st_dev_id_value = g_hash_table_lookup(device_args, st_dev_id_key);
|
|
|
|
+ if (st_dev_id_value) {
|
|
|
|
+ action->dev_id = strdup(st_dev_id_value);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
return action;
|
2016-02-29 15:41:59 +01:00
|
|
|
@@ -894,6 +903,8 @@ internal_stonith_action_execute(stonith_
|
2013-05-21 14:29:04 +02:00
|
|
|
|
|
|
|
if (!pid) {
|
|
|
|
/* child */
|
|
|
|
+ const char *st_dev_id_key = CRM_META "_" F_STONITH_DEVICE;
|
2013-08-05 08:38:03 +02:00
|
|
|
+
|
|
|
|
setpgid(0, 0);
|
2013-05-21 14:29:04 +02:00
|
|
|
|
|
|
|
close(1);
|
2016-02-29 15:41:59 +01:00
|
|
|
@@ -916,6 +927,10 @@ internal_stonith_action_execute(stonith_
|
2013-05-21 14:29:04 +02:00
|
|
|
close(p_write_fd);
|
2016-02-29 15:41:59 +01:00
|
|
|
close(p_stderr_fd);
|
2013-05-21 14:29:04 +02:00
|
|
|
|
|
|
|
+ if (action->dev_id) {
|
|
|
|
+ setenv(st_dev_id_key, action->dev_id, 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
/* keep retries from executing out of control */
|
|
|
|
if (is_retry) {
|
|
|
|
sleep(1);
|