Skip to content

Commit ca7acf6

Browse files
committed
Merge branch 'stonith_timeout_3' of https://github.com/davidvossel/pacemaker
Conflicts: lrmd/regression.py.in
2 parents 5ce3093 + fd2c818 commit ca7acf6

File tree

14 files changed

+881
-139
lines changed

14 files changed

+881
-139
lines changed

crmd/te_actions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ te_fence_node(crm_graph_t * graph, crm_action_t * action)
147147

148148
stonith_api->cmds->register_callback(
149149
stonith_api, rc, transition_graph->stonith_timeout / 1000,
150-
FALSE, generate_transition_key(transition_graph->id, action->id, 0, te_uuid),
150+
st_opt_timeout_updates, generate_transition_key(transition_graph->id, action->id, 0, te_uuid),
151151
"tengine_stonith_callback", tengine_stonith_callback);
152152

153153
return TRUE;

fencing/commands.c

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,28 @@ static int active_children = 0;
5252
static gboolean stonith_device_dispatch(gpointer user_data);
5353
static void st_child_done(GPid pid, gint status, gpointer user_data);
5454

55+
static int
56+
get_action_timeout(stonith_device_t *device, const char *action, int default_timeout)
57+
{
58+
char buffer[512] = { 0, };
59+
char *value = NULL;
60+
61+
CRM_CHECK(action != NULL, return default_timeout);
62+
63+
if (!device->params) {
64+
return default_timeout;
65+
}
66+
67+
snprintf(buffer, sizeof(buffer) - 1, "pcmk_%s_timeout", action);
68+
value = g_hash_table_lookup(device->params, buffer);
69+
70+
if (!value) {
71+
return default_timeout;
72+
}
73+
74+
return atoi(value);
75+
}
76+
5577
static void free_async_command(async_command_t *cmd)
5678
{
5779
if (!cmd) {
@@ -83,7 +105,8 @@ static async_command_t *create_async_command(xmlNode *msg)
83105
cmd = calloc(1, sizeof(async_command_t));
84106
crm_element_value_int(msg, F_STONITH_CALLID, &(cmd->id));
85107
crm_element_value_int(msg, F_STONITH_CALLOPTS, &(cmd->options));
86-
crm_element_value_int(msg, F_STONITH_TIMEOUT, &(cmd->timeout));
108+
crm_element_value_int(msg, F_STONITH_TIMEOUT, &(cmd->default_timeout));
109+
cmd->timeout = cmd->default_timeout;
87110

88111
cmd->origin = crm_element_value_copy(msg, F_ORIG);
89112
cmd->remote = crm_element_value_copy(msg, F_STONITH_REMOTE);
@@ -179,6 +202,7 @@ static void schedule_stonith_command(async_command_t *cmd, stonith_device_t *dev
179202
}
180203

181204
cmd->device = strdup(device->id);
205+
cmd->timeout = get_action_timeout(device, cmd->action, cmd->default_timeout);
182206

183207
crm_debug("Scheduling %s on %s for %s (timeout=%dms)", cmd->action, device->id,
184208
cmd->remote?cmd->remote:cmd->client, cmd->timeout);
@@ -745,6 +769,7 @@ static int stonith_query(xmlNode *msg, xmlNode **list)
745769
{
746770
struct device_search_s search;
747771
int available_devices = 0;
772+
const char *action = NULL;
748773
xmlNode *dev = get_xpath_object("//@"F_STONITH_TARGET, msg, LOG_DEBUG_3);
749774

750775
search.host = NULL;
@@ -760,6 +785,8 @@ static int stonith_query(xmlNode *msg, xmlNode **list)
760785
}
761786
return pcmk_ok;
762787
}
788+
789+
action = crm_element_value(dev, F_STONITH_ACTION);
763790
}
764791

765792
crm_log_xml_debug(msg, "Query");
@@ -781,10 +808,15 @@ static int stonith_query(xmlNode *msg, xmlNode **list)
781808
crm_xml_add_int(*list, "st-available-devices", available_devices);
782809
for(lpc = search.capable; lpc != NULL; lpc = lpc->next) {
783810
stonith_device_t *device = (stonith_device_t*)lpc->data;
811+
int action_specific_timeout = get_action_timeout(device, action, 0);
812+
784813
dev = create_xml_node(*list, F_STONITH_DEVICE);
785814
crm_xml_add(dev, XML_ATTR_ID, device->id);
786815
crm_xml_add(dev, "namespace", device->namespace);
787816
crm_xml_add(dev, "agent", device->agent);
817+
if (action_specific_timeout) {
818+
crm_xml_add_int(dev, F_STONITH_ACTION_TIMEOUT, action_specific_timeout);
819+
}
788820
if(search.host == NULL) {
789821
xmlNode *attrs = create_xml_node(dev, XML_TAG_ATTRS);
790822
g_hash_table_foreach(device->params, hash2field, attrs);
@@ -1238,6 +1270,14 @@ stonith_command(stonith_client_t *client, uint32_t id, uint32_t flags, xmlNode *
12381270
} else if(crm_str_eq(op, STONITH_OP_EXEC, TRUE)) {
12391271
rc = stonith_device_action(request, &output);
12401272

1273+
} else if (crm_str_eq(op, STONITH_OP_TIMEOUT_UPDATE, TRUE)) {
1274+
const char *call_id = crm_element_value(request, F_STONITH_CALLID);
1275+
const char *client_id = crm_element_value(request, F_STONITH_CLIENTID);
1276+
int op_timeout = 0;
1277+
1278+
crm_element_value_int(request, F_STONITH_TIMEOUT, &op_timeout);
1279+
do_stonith_async_timeout_update(client_id, call_id, op_timeout);
1280+
return;
12411281
} else if(is_reply && crm_str_eq(op, STONITH_OP_QUERY, TRUE)) {
12421282
process_remote_stonith_query(request);
12431283
return;

fencing/internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ extern xmlNode *stonith_construct_reply(xmlNode * request, char *output, xmlNode
8282
extern xmlNode *stonith_construct_async_reply(async_command_t * cmd, const char *output, xmlNode * data,
8383
int rc);;
8484

85+
void
86+
do_stonith_async_timeout_update(const char *client, const char *call_id, int timeout);
87+
8588
extern void do_stonith_notify(int options, const char *type, int result, xmlNode * data, const char *remote);
8689

8790
extern remote_fencing_op_t *initiate_remote_stonith_op(stonith_client_t * client, xmlNode * request,

fencing/main.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ st_ipc_dispatch(qb_ipcs_connection_t *c, void *data, size_t size)
136136

137137
crm_xml_add(request, F_STONITH_CLIENTID, client->id);
138138
crm_xml_add(request, F_STONITH_CLIENTNAME, client->name);
139+
crm_xml_add(request, F_STONITH_CLIENTNODE, stonith_our_uname);
139140

140141
crm_log_xml_trace(request, "Client[inbound]");
141142
stonith_command(client, id, flags, request, NULL);
@@ -363,6 +364,35 @@ stonith_notify_client(gpointer key, gpointer value, gpointer user_data)
363364
}
364365
}
365366

367+
void
368+
do_stonith_async_timeout_update(const char *client_id, const char *call_id, int timeout)
369+
{
370+
stonith_client_t *client = NULL;
371+
xmlNode *notify_data = NULL;
372+
373+
if (!timeout || !call_id || !client_id) {
374+
return;
375+
}
376+
377+
client = g_hash_table_lookup(client_list, client_id);
378+
if (!client) {
379+
return;
380+
}
381+
382+
notify_data = create_xml_node(NULL, T_STONITH_TIMEOUT_VALUE);
383+
crm_xml_add(notify_data, F_TYPE, T_STONITH_TIMEOUT_VALUE);
384+
crm_xml_add(notify_data, F_STONITH_CALLID, call_id);
385+
crm_xml_add_int(notify_data, F_STONITH_TIMEOUT, timeout);
386+
387+
crm_trace("timeout update is %d for client %s and call id %s", timeout, client_id, call_id);
388+
389+
if (client->channel) {
390+
crm_ipcs_send(client->channel, 0, notify_data, crm_ipc_server_event);
391+
}
392+
393+
free_xml(notify_data);
394+
}
395+
366396
void
367397
do_stonith_notify(
368398
int options, const char *type, int result, xmlNode *data,
@@ -748,7 +778,7 @@ main(int argc, char ** argv)
748778
printf(" <parameters>\n");
749779

750780
printf(" <parameter name=\"stonith-timeout\" unique=\"0\">\n");
751-
printf(" <shortdesc lang=\"en\">How long to wait for the STONITH action to complete.</shortdesc>\n");
781+
printf(" <shortdesc lang=\"en\">How long to wait for the STONITH action to complete per a stonith device.</shortdesc>\n");
752782
printf(" <longdesc lang=\"en\">Overrides the stonith-timeout cluster property</longdesc>\n");
753783
printf(" <content type=\"time\" default=\"60s\"/>\n");
754784
printf(" </parameter>\n");

0 commit comments

Comments
 (0)