File pacemaker-set-meta_timeout-env-crm_resource-force-executes-RA-1.patch of Package pacemaker.8397
commit 77d5db932618a7e0fbf92bf74c8117cdff5ae983
Author: Kazunori INOUE <inouekazu@intellilink.co.jp>
Date: Fri Oct 27 13:18:43 2017 +0900
Low: tools: set meta_timeout env when crm_resource --force-* executes RA
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c
index 8070c43eb..48455e6c8 100644
--- a/tools/crm_resource_runtime.c
+++ b/tools/crm_resource_runtime.c
@@ -1458,6 +1458,10 @@ cli_resource_execute(const char *rsc_id, const char *rsc_action, GHashTable *ove
GHashTable *params = NULL;
resource_t *rsc = pe_find_resource(data_set->resources, rsc_id);
+ xmlNode *child = NULL;
+ const char *timeout = NULL;
+ long timeout_ms = 0;
+
if (rsc == NULL) {
CMD_ERR("Must supply a resource id with -r");
return -ENXIO;
@@ -1508,6 +1512,34 @@ cli_resource_execute(const char *rsc_id, const char *rsc_action, GHashTable *ove
params = generate_resource_params(rsc, data_set);
+ /* add meta_timeout env needed by some resource agents */
+ child = first_named_child(rsc->xml, "operations");
+ for (child = first_named_child(child, XML_ATTR_OP);
+ child != NULL; child = crm_next_same_xml(child)) {
+ if (safe_str_eq(action, crm_element_value(child, XML_NVPAIR_ATTR_NAME))) {
+ timeout = crm_element_value(child, XML_ATTR_TIMEOUT);
+ break;
+ }
+ }
+ if (timeout == NULL && data_set->op_defaults) {
+ GHashTable *action_meta = crm_str_table_new();
+ unpack_instance_attributes(data_set->input, data_set->op_defaults, XML_TAG_META_SETS,
+ NULL, action_meta, NULL, FALSE, data_set->now);
+ timeout = g_hash_table_lookup(action_meta, XML_ATTR_TIMEOUT);
+ }
+ if (timeout == NULL && data_set->config_hash) {
+ timeout = pe_pref(data_set->config_hash, "default-action-timeout");
+ }
+ if (timeout == NULL) {
+ timeout = CRM_DEFAULT_OP_TIMEOUT_S;
+ }
+ timeout_ms = crm_get_msec(timeout);
+ if (timeout_ms < 0) {
+ timeout_ms = 0;
+ }
+ g_hash_table_insert(params, strdup("CRM_meta_timeout"),
+ crm_strdup_printf("%ld", timeout_ms));
+
/* add crm_feature_set env needed by some resource agents */
g_hash_table_insert(params, strdup(XML_ATTR_CRM_VERSION), strdup(CRM_FEATURE_SET));