Blob Blame History Raw
commit 7d17d8ab2dd91bdcaf2dea199f2ef66b514daea0
Author: Andrew Beekhof <andrew@beekhof.net>
Date:   Wed Nov 6 14:15:24 2013 +1100

    PE: Probe containers not expected to be up
    
    RHEL-Only work-around, fixing properly upstream

diff --git a/include/crm/pengine/internal.h b/include/crm/pengine/internal.h
index 7240106..dd52e7f 100644
--- a/include/crm/pengine/internal.h
+++ b/include/crm/pengine/internal.h
@@ -262,4 +262,5 @@ op_digest_cache_t *rsc_action_digest_cmp(resource_t * rsc, xmlNode * xml_op, nod
 
 gboolean is_remote_node(xmlNode *xml);
 
+resource_t * rsc_contains_remote_node(pe_working_set_t * data_set, resource_t *rsc);
 #endif
diff --git a/include/crm/pengine/status.h b/include/crm/pengine/status.h
index 8eb4a1d..eb52464 100644
--- a/include/crm/pengine/status.h
+++ b/include/crm/pengine/status.h
@@ -183,6 +183,7 @@ struct node_s {
 #  define pe_rsc_migrating	0x00400000ULL
 
 #  define pe_rsc_failure_ignored 0x01000000ULL
+#  define pe_rsc_unexpectedly_running 0x02000000ULL
 
 #  define pe_rsc_needs_quorum	 0x10000000ULL
 #  define pe_rsc_needs_fencing	 0x20000000ULL
diff --git a/lib/pengine/unpack.c b/lib/pengine/unpack.c
index 78ceb85..56ed291 100644
--- a/lib/pengine/unpack.c
+++ b/lib/pengine/unpack.c
@@ -2014,6 +2014,9 @@ unpack_lrm_resources(node_t * node, xmlNode * lrm_rsc_list, pe_working_set_t * d
 {
     xmlNode *rsc_entry = NULL;
     gboolean found_orphaned_container_filler = FALSE;
+    GListPtr unexpected_containers = NULL;
+    GListPtr gIter = NULL;
+    resource_t *remote = NULL;
 
     CRM_CHECK(node != NULL, return FALSE);
 
@@ -2025,9 +2028,29 @@ unpack_lrm_resources(node_t * node, xmlNode * lrm_rsc_list, pe_working_set_t * d
         if (crm_str_eq((const char *)rsc_entry->name, XML_LRM_TAG_RESOURCE, TRUE)) {
             resource_t *rsc;
             rsc = unpack_lrm_rsc_state(node, rsc_entry, data_set);
-            if (rsc && is_set(rsc->flags, pe_rsc_orphan_container_filler)) {
+            if (!rsc) {
+                continue;
+            }
+            if (is_set(rsc->flags, pe_rsc_orphan_container_filler)) {
                 found_orphaned_container_filler = TRUE;
             }
+            if (is_set(rsc->flags, pe_rsc_unexpectedly_running)) {
+                remote = rsc_contains_remote_node(data_set, rsc);
+                if (remote) {
+                    unexpected_containers = g_list_append(unexpected_containers, remote);
+                }
+            }
+        }
+    }
+
+    /* If a container resource is unexpectedly up... and the remote-node
+     * connection resource for that container is not up, the entire container
+     * must be recovered. */
+    for (gIter = unexpected_containers; gIter != NULL; gIter = gIter->next) {
+        remote = (resource_t *) gIter->data;
+        if (remote->role != RSC_ROLE_STARTED) {
+            crm_warn("Recovering container resource %s. Resource is unexpectedly running and involves a remote-node.");
+            set_bit(remote->container->flags, pe_rsc_failed);
         }
     }
 
@@ -2037,7 +2060,7 @@ unpack_lrm_resources(node_t * node, xmlNode * lrm_rsc_list, pe_working_set_t * d
     if (found_orphaned_container_filler) {
         handle_orphaned_container_fillers(lrm_rsc_list, data_set);
     }
-
+    g_list_free(unexpected_containers);
     return TRUE;
 }
 
@@ -2366,6 +2389,7 @@ unpack_rsc_op(resource_t * rsc, node_t * node, xmlNode * xml_op,
         case PCMK_OCF_OK:
             if (is_probe && target_rc == 7) {
                 task_status_i = PCMK_LRM_OP_DONE;
+                set_bit(rsc->flags, pe_rsc_unexpectedly_running);
                 pe_rsc_info(rsc, "Operation %s found resource %s active on %s",
                             task, rsc->id, node->details->uname);
 
diff --git a/lib/pengine/utils.c b/lib/pengine/utils.c
index 1e3877d..e9997a2 100644
--- a/lib/pengine/utils.c
+++ b/lib/pengine/utils.c
@@ -1776,3 +1776,24 @@ const char *rsc_printable_id(resource_t *rsc)
     }
     return rsc->id;
 }
+
+resource_t *
+rsc_contains_remote_node(pe_working_set_t * data_set, resource_t *rsc)
+{
+    if (is_set(data_set->flags, pe_flag_have_remote_nodes) == FALSE) {
+        return FALSE;
+    }
+
+    if (rsc->fillers) {
+        GListPtr gIter = NULL;
+        for (gIter = rsc->fillers; gIter != NULL; gIter = gIter->next) {
+            resource_t *filler = (resource_t *) gIter->data;
+
+            if (filler->is_remote_node) {
+                return filler;
+            }
+        }
+    }
+    return NULL;
+}
+