commit a82de2e8ee4ffb62bfcfc1c6c8b104db92a50f6a
Author: Ken Gaillot <kgaillot@redhat.com>
Date:   Fri Jun 10 09:11:08 2016 -0500

    Fix: crmd: use proper resource agent name when caching metadata
    
    This also improves logging when retrieving metadata.

Index: pacemaker/crmd/lrm.c
===================================================================
--- pacemaker.orig/crmd/lrm.c
+++ pacemaker/crmd/lrm.c
@@ -496,29 +496,28 @@ get_rsc_metadata(const char *type, const
         return NULL;
     }
 
-    snprintf(key, len, "%s::%s:%s", type, rclass, provider);
+    snprintf(key, len, "%s::%s:%s", rclass, provider, type);
     if(force == FALSE) {
-        crm_trace("Retreiving cached metadata for %s", key);
         metadata = g_hash_table_lookup(metadata_hash, key);
+        if (metadata) {
+            crm_trace("Retrieved cached metadata for %s", key);
+        }
     }
 
     if(metadata == NULL) {
         rc = lrm_state_get_metadata(lrm_state, rclass, provider, type, &metadata, 0);
-        crm_trace("Retreived live metadata for %s: %s (%d)", key, pcmk_strerror(rc), rc);
         if(rc == pcmk_ok) {
+            crm_trace("Retrieved live metadata for %s", key);
             CRM_LOG_ASSERT(metadata != NULL);
             g_hash_table_insert(metadata_hash, key, metadata);
             key = NULL;
         } else {
-            CRM_LOG_ASSERT(metadata == NULL);
-            metadata = NULL;
+            crm_trace("No metadata found for %s: %s" CRM_XS " rc=%d",
+                     key, pcmk_strerror(rc), rc);
+            CRM_CHECK(metadata == NULL, metadata = NULL);
         }
     }
 
-    if (metadata == NULL) {
-        crm_warn("No metadata found for %s: %s (%d)", key, pcmk_strerror(rc), rc);
-    }
-
     free(key);
     return metadata;
 }
@@ -746,17 +745,17 @@ build_operation_update(xmlNode * parent,
 
     m_string = get_rsc_metadata(rsc->type, rsc->class, rsc->provider, safe_str_eq(op->op_type, RSC_START));
     if(m_string == NULL) {
-        crm_err("No metadata for %s::%s:%s", rsc->provider, rsc->class, rsc->type);
+        crm_err("No metadata for %s::%s:%s", rsc->class, rsc->provider, rsc->type);
         return TRUE;
     }
 
     metadata = string2xml(m_string);
     if(metadata == NULL) {
-        crm_err("Metadata for %s::%s:%s is not valid XML", rsc->provider, rsc->class, rsc->type);
+        crm_err("Metadata for %s::%s:%s is not valid XML", rsc->class, rsc->provider, rsc->type);
         return TRUE;
     }
 
-    crm_trace("Includind additional digests for %s::%s:%s", rsc->provider, rsc->class, rsc->type);
+    crm_trace("Including additional digests for %s::%s:%s", rsc->class, rsc->provider, rsc->type);
     append_restart_list(op, metadata, xml_op, caller_version);
     append_secure_list(op, metadata, xml_op, caller_version);
 
Index: pacemaker/lib/lrmd/lrmd_client.c
===================================================================
--- pacemaker.orig/lib/lrmd/lrmd_client.c
+++ pacemaker/lib/lrmd/lrmd_client.c
@@ -1896,15 +1896,15 @@ heartbeat_get_metadata(const char *type,
 static int
 generic_get_metadata(const char *standard, const char *provider, const char *type, char **output)
 {
-    svc_action_t *action = resources_action_create(type,
-                                                   standard,
-                                                   provider,
-                                                   type,
-                                                   "meta-data",
-                                                   0,
-                                                   30000,
-                                                   NULL,
-                                                   0);
+    svc_action_t *action;
+
+    action = resources_action_create(type, standard, provider, type,
+                                     "meta-data", 0, 30000, NULL, 0);
+    if (action == NULL) {
+        crm_err("Unable to retrieve meta-data for %s:%s:%s", standard, provider, type);
+        services_action_free(action);
+        return -EINVAL;
+    }
 
     if (!(services_action_sync(action))) {
         crm_err("Failed to retrieve meta-data for %s:%s:%s", standard, provider, type);
@@ -1913,7 +1913,7 @@ generic_get_metadata(const char *standar
     }
 
     if (!action->stdout_data) {
-        crm_err("Failed to retrieve meta-data for %s:%s:%s", standard, provider, type);
+        crm_err("Failed to receive meta-data for %s:%s:%s", standard, provider, type);
         services_action_free(action);
         return -EIO;
     }
