File bug-976865_pacemaker-remote-cancel-op.patch of Package pacemaker.3577

commit c0cbf86cb167085b811e6c034b50219287b9fc62
Author: Gao,Yan <ygao@suse.com>
Date:   Wed May 25 14:15:02 2016 +0200

    Fix: crmd: Acknowledge cancellation operations for remote connection resources
    
    Previously, putting a remote connection resource into maintenance mode
    would cause crmd hanging on waiting for the cancellation of the monitor
    operation to return until it timed out.
    
    The cancellation operation for a remote connection resource is
    synchronous. We should acknowledge it directly.
    
    It also removes the pending operation with the correct operation id.

diff --git a/crmd/lrm.c b/crmd/lrm.c
index 633ac36..bb8af67 100644
--- a/crmd/lrm.c
+++ b/crmd/lrm.c
@@ -1684,10 +1684,14 @@ do_lrm_invoke(long long action,
                 in_progress = cancel_op(lrm_state, rsc->id, NULL, call, TRUE);
             }
 
-            if (in_progress == FALSE) {
+            /* Acknowledge the cancellation operation if it's for a remote connection resource */
+            if (in_progress == FALSE || is_remote_lrmd_ra(NULL, NULL, rsc->id)) {
                 lrmd_event_data_t *op = construct_op(lrm_state, input->xml, rsc->id, op_task);
+                char *op_id = make_stop_id(rsc->id, call);
 
-                crm_info("Nothing known about operation %d for %s", call, op_key);
+                if (is_remote_lrmd_ra(NULL, NULL, rsc->id) == FALSE) {
+                    crm_info("Nothing known about operation %d for %s", call, op_key);
+                }
                 delete_op_entry(lrm_state, NULL, rsc->id, op_key, call);
 
                 CRM_ASSERT(op != NULL);
@@ -1697,10 +1701,9 @@ do_lrm_invoke(long long action,
                 send_direct_ack(from_host, from_sys, rsc, op, rsc->id);
                 lrmd_free_event(op);
 
-                /* needed?? surely not otherwise the cancel_op_(_key) wouldn't
-                 * have failed in the first place
-                 */
-                g_hash_table_remove(lrm_state->pending_ops, op_key);
+                /* needed?? yes for the cancellation operation of a remote connection resource */
+                g_hash_table_remove(lrm_state->pending_ops, op_id);
+                free(op_id);
             }
 
             free(op_key);
diff --git a/crmd/lrm_state.c b/crmd/lrm_state.c
index 048e7be..8910bbd 100644
--- a/crmd/lrm_state.c
+++ b/crmd/lrm_state.c
@@ -744,8 +744,8 @@ lrm_state_cancel(lrm_state_t * lrm_state, const char *rsc_id, const char *action
         return -ENOTCONN;
     }
 
-    /* Optimize this, cancel requires a synced request/response to the server.
-     * Figure out a way to make this async. */
+    /* Figure out a way to make this async?
+     * NOTICE: Currently it's synced and directly acknowledged in do_lrm_invoke(). */
     if (is_remote_lrmd_ra(NULL, NULL, rsc_id)) {
         return remote_ra_cancel(lrm_state, rsc_id, action, interval);
     }
openSUSE Build Service is sponsored by