File bug-981489_pacemaker-crmd-clear-remote-node-attributes-on-disconnect.patch of Package pacemaker.3577

commit c3c3d98e74ae4415ecb66830376300d894918ac2
Author: Ken Gaillot <kgaillot@redhat.com>
Date:   Tue May 24 11:58:05 2016 -0500

    Fix: crmd: clear remote node transient attributes on disconnect
    
    Previously, transient attributes and LRM history were cleared for
    remote nodes only on startup. But if the shutdown attribute were set,
    the node couldn't startup, and the attribute couldn't be cleared,
    leaving the node down.
    
    Now, they are cleared at remote node stop (clearing at start is
    kept, just to be safe).
    
    This with 4c4d8c5 fixes RHBZ#1338623 while preserving the ability
    to do graceful stops on remote nodes.

Index: pacemaker/crmd/remote_lrmd_ra.c
===================================================================
--- pacemaker.orig/crmd/remote_lrmd_ra.c
+++ pacemaker/crmd/remote_lrmd_ra.c
@@ -474,6 +474,25 @@ remote_lrm_op_callback(lrmd_event_data_t
     }
 }
 
+
+/*!
+ * \internal
+ * \brief Get CIB call options to use local scope if master unavailable
+ *
+ * \return CIB call options
+ */
+static int
+crmd_cib_smart_opt()
+{
+    int call_opt = cib_quorum_override;
+
+    if (fsa_state == S_ELECTION || fsa_state == S_PENDING) {
+        crm_info("Sending update to local CIB in state: %s", fsa_state2string(fsa_state));
+        call_opt |= cib_scope_local;
+    }
+    return call_opt;
+}
+
 static void
 handle_remote_ra_stop(lrm_state_t * lrm_state, remote_ra_cmd_t * cmd)
 {
@@ -483,8 +502,15 @@ handle_remote_ra_stop(lrm_state_t * lrm_
     ra_data = lrm_state->remote_ra_data;
 
     if (ra_data->migrate_status != takeover_complete) {
+        int call_opt = crmd_cib_smart_opt();
+
         /* only clear the status if this stop is not apart of a successful migration */
         update_attrd_remote_node_removed(lrm_state->node_name, NULL);
+
+        /* Purge node's operation history and transient attributes from CIB */
+        erase_status_tag(lrm_state->node_name, XML_CIB_TAG_LRM, call_opt);
+        erase_status_tag(lrm_state->node_name, XML_TAG_TRANSIENT_NODEATTRS, call_opt);
+
         /* delete pending ops when ever the remote connection is intentionally stopped */
         g_hash_table_remove_all(lrm_state->pending_ops);
     } else {
openSUSE Build Service is sponsored by