@@ -52,6 +52,28 @@ static int active_children = 0;
52
52
static gboolean stonith_device_dispatch (gpointer user_data );
53
53
static void st_child_done (GPid pid , gint status , gpointer user_data );
54
54
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
+
55
77
static void free_async_command (async_command_t * cmd )
56
78
{
57
79
if (!cmd ) {
@@ -83,7 +105,8 @@ static async_command_t *create_async_command(xmlNode *msg)
83
105
cmd = calloc (1 , sizeof (async_command_t ));
84
106
crm_element_value_int (msg , F_STONITH_CALLID , & (cmd -> id ));
85
107
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 ;
87
110
88
111
cmd -> origin = crm_element_value_copy (msg , F_ORIG );
89
112
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
179
202
}
180
203
181
204
cmd -> device = strdup (device -> id );
205
+ cmd -> timeout = get_action_timeout (device , cmd -> action , cmd -> default_timeout );
182
206
183
207
crm_debug ("Scheduling %s on %s for %s (timeout=%dms)" , cmd -> action , device -> id ,
184
208
cmd -> remote ?cmd -> remote :cmd -> client , cmd -> timeout );
@@ -745,6 +769,7 @@ static int stonith_query(xmlNode *msg, xmlNode **list)
745
769
{
746
770
struct device_search_s search ;
747
771
int available_devices = 0 ;
772
+ const char * action = NULL ;
748
773
xmlNode * dev = get_xpath_object ("//@" F_STONITH_TARGET , msg , LOG_DEBUG_3 );
749
774
750
775
search .host = NULL ;
@@ -760,6 +785,8 @@ static int stonith_query(xmlNode *msg, xmlNode **list)
760
785
}
761
786
return pcmk_ok ;
762
787
}
788
+
789
+ action = crm_element_value (dev , F_STONITH_ACTION );
763
790
}
764
791
765
792
crm_log_xml_debug (msg , "Query" );
@@ -781,10 +808,15 @@ static int stonith_query(xmlNode *msg, xmlNode **list)
781
808
crm_xml_add_int (* list , "st-available-devices" , available_devices );
782
809
for (lpc = search .capable ; lpc != NULL ; lpc = lpc -> next ) {
783
810
stonith_device_t * device = (stonith_device_t * )lpc -> data ;
811
+ int action_specific_timeout = get_action_timeout (device , action , 0 );
812
+
784
813
dev = create_xml_node (* list , F_STONITH_DEVICE );
785
814
crm_xml_add (dev , XML_ATTR_ID , device -> id );
786
815
crm_xml_add (dev , "namespace" , device -> namespace );
787
816
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
+ }
788
820
if (search .host == NULL ) {
789
821
xmlNode * attrs = create_xml_node (dev , XML_TAG_ATTRS );
790
822
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 *
1238
1270
} else if (crm_str_eq (op , STONITH_OP_EXEC , TRUE)) {
1239
1271
rc = stonith_device_action (request , & output );
1240
1272
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 ;
1241
1281
} else if (is_reply && crm_str_eq (op , STONITH_OP_QUERY , TRUE)) {
1242
1282
process_remote_stonith_query (request );
1243
1283
return ;
0 commit comments