Blame SOURCES/001-status-deletion.patch

308170
From 6c529bb624ad548f66ce6ef1fa80b77c688918f4 Mon Sep 17 00:00:00 2001
308170
From: Ken Gaillot <kgaillot@redhat.com>
308170
Date: Fri, 22 Nov 2019 16:39:54 -0600
308170
Subject: [PATCH 1/4] Refactor: controller: rename struct recurring_op_s to
308170
 active_op_t
308170
308170
... because it holds both recurring and pending non-recurring actions,
308170
and the name was confusing
308170
---
308170
 daemons/controld/controld_execd.c       | 18 +++++++++---------
308170
 daemons/controld/controld_execd_state.c |  4 ++--
308170
 daemons/controld/controld_lrm.h         |  8 ++++----
308170
 3 files changed, 15 insertions(+), 15 deletions(-)
308170
308170
diff --git a/daemons/controld/controld_execd.c b/daemons/controld/controld_execd.c
308170
index 9e8dd36..48f35dd 100644
308170
--- a/daemons/controld/controld_execd.c
308170
+++ b/daemons/controld/controld_execd.c
308170
@@ -403,7 +403,7 @@ lrm_state_verify_stopped(lrm_state_t * lrm_state, enum crmd_fsa_state cur_state,
308170
     GHashTableIter gIter;
308170
     const char *key = NULL;
308170
     rsc_history_t *entry = NULL;
308170
-    struct recurring_op_s *pending = NULL;
308170
+    active_op_t *pending = NULL;
308170
 
308170
     crm_debug("Checking for active resources before exit");
308170
 
308170
@@ -909,7 +909,7 @@ static gboolean
308170
 lrm_remove_deleted_op(gpointer key, gpointer value, gpointer user_data)
308170
 {
308170
     const char *rsc = user_data;
308170
-    struct recurring_op_s *pending = value;
308170
+    active_op_t *pending = value;
308170
 
308170
     if (crm_str_eq(rsc, pending->rsc_id, TRUE)) {
308170
         crm_info("Removing op %s:%d for deleted resource %s",
308170
@@ -1137,7 +1137,7 @@ cancel_op(lrm_state_t * lrm_state, const char *rsc_id, const char *key, int op,
308170
 {
308170
     int rc = pcmk_ok;
308170
     char *local_key = NULL;
308170
-    struct recurring_op_s *pending = NULL;
308170
+    active_op_t *pending = NULL;
308170
 
308170
     CRM_CHECK(op != 0, return FALSE);
308170
     CRM_CHECK(rsc_id != NULL, return FALSE);
308170
@@ -1203,7 +1203,7 @@ cancel_action_by_key(gpointer key, gpointer value, gpointer user_data)
308170
 {
308170
     gboolean remove = FALSE;
308170
     struct cancel_data *data = user_data;
308170
-    struct recurring_op_s *op = (struct recurring_op_s *)value;
308170
+    active_op_t *op = value;
308170
 
308170
     if (crm_str_eq(op->op_key, data->key, TRUE)) {
308170
         data->done = TRUE;
308170
@@ -2107,7 +2107,7 @@ stop_recurring_action_by_rsc(gpointer key, gpointer value, gpointer user_data)
308170
 {
308170
     gboolean remove = FALSE;
308170
     struct stop_recurring_action_s *event = user_data;
308170
-    struct recurring_op_s *op = (struct recurring_op_s *)value;
308170
+    active_op_t *op = value;
308170
 
308170
     if ((op->interval_ms != 0)
308170
         && crm_str_eq(op->rsc_id, event->rsc->id, TRUE)) {
308170
@@ -2124,7 +2124,7 @@ stop_recurring_actions(gpointer key, gpointer value, gpointer user_data)
308170
 {
308170
     gboolean remove = FALSE;
308170
     lrm_state_t *lrm_state = user_data;
308170
-    struct recurring_op_s *op = (struct recurring_op_s *)value;
308170
+    active_op_t *op = value;
308170
 
308170
     if (op->interval_ms != 0) {
308170
         crm_info("Cancelling op %d for %s (%s)", op->call_id, op->rsc_id,
308170
@@ -2297,9 +2297,9 @@ do_lrm_rsc_op(lrm_state_t * lrm_state, lrmd_rsc_info_t * rsc, const char *operat
308170
          * for them to complete during shutdown
308170
          */
308170
         char *call_id_s = make_stop_id(rsc->id, call_id);
308170
-        struct recurring_op_s *pending = NULL;
308170
+        active_op_t *pending = NULL;
308170
 
308170
-        pending = calloc(1, sizeof(struct recurring_op_s));
308170
+        pending = calloc(1, sizeof(active_op_t));
308170
         crm_trace("Recording pending op: %d - %s %s", call_id, op_id, call_id_s);
308170
 
308170
         pending->call_id = call_id;
308170
@@ -2517,7 +2517,7 @@ did_lrm_rsc_op_fail(lrm_state_t *lrm_state, const char * rsc_id,
308170
 
308170
 void
308170
 process_lrm_event(lrm_state_t *lrm_state, lrmd_event_data_t *op,
308170
-                  struct recurring_op_s *pending, xmlNode *action_xml)
308170
+                  active_op_t *pending, xmlNode *action_xml)
308170
 {
308170
     char *op_id = NULL;
308170
     char *op_key = NULL;
308170
diff --git a/daemons/controld/controld_execd_state.c b/daemons/controld/controld_execd_state.c
308170
index 0e21d18..473da97 100644
308170
--- a/daemons/controld/controld_execd_state.c
308170
+++ b/daemons/controld/controld_execd_state.c
308170
@@ -44,7 +44,7 @@ free_deletion_op(gpointer value)
308170
 static void
308170
 free_recurring_op(gpointer value)
308170
 {
308170
-    struct recurring_op_s *op = (struct recurring_op_s *)value;
308170
+    active_op_t *op = value;
308170
 
308170
     free(op->user_data);
308170
     free(op->rsc_id);
308170
@@ -61,7 +61,7 @@ fail_pending_op(gpointer key, gpointer value, gpointer user_data)
308170
 {
308170
     lrmd_event_data_t event = { 0, };
308170
     lrm_state_t *lrm_state = user_data;
308170
-    struct recurring_op_s *op = (struct recurring_op_s *)value;
308170
+    active_op_t *op = value;
308170
 
308170
     crm_trace("Pre-emptively failing " CRM_OP_FMT " on %s (call=%s, %s)",
308170
               op->rsc_id, op->op_type, op->interval_ms,
308170
diff --git a/daemons/controld/controld_lrm.h b/daemons/controld/controld_lrm.h
308170
index 598682b..27df5d7 100644
308170
--- a/daemons/controld/controld_lrm.h
308170
+++ b/daemons/controld/controld_lrm.h
308170
@@ -33,8 +33,8 @@ typedef struct resource_history_s {
308170
 
308170
 void history_free(gpointer data);
308170
 
308170
-/* TODO - Replace this with lrmd_event_data_t */
308170
-struct recurring_op_s {
308170
+// In-flight action (recurring or pending)
308170
+typedef struct active_op_s {
308170
     guint interval_ms;
308170
     int call_id;
308170
     gboolean remove;
308170
@@ -45,7 +45,7 @@ struct recurring_op_s {
308170
     char *op_key;
308170
     char *user_data;
308170
     GHashTable *params;
308170
-};
308170
+} active_op_t;
308170
 
308170
 typedef struct lrm_state_s {
308170
     const char *node_name;
308170
@@ -164,4 +164,4 @@ void remote_ra_process_maintenance_nodes(xmlNode *xml);
308170
 gboolean remote_ra_controlling_guest(lrm_state_t * lrm_state);
308170
 
308170
 void process_lrm_event(lrm_state_t *lrm_state, lrmd_event_data_t *op,
308170
-                       struct recurring_op_s *pending, xmlNode *action_xml);
308170
+                       active_op_t *pending, xmlNode *action_xml);
308170
-- 
308170
1.8.3.1
308170
308170
308170
From 93a59f1df8fe11d365032d75f10cb4189ad2f1f8 Mon Sep 17 00:00:00 2001
308170
From: Ken Gaillot <kgaillot@redhat.com>
308170
Date: Fri, 22 Nov 2019 16:45:31 -0600
308170
Subject: [PATCH 2/4] Refactor: controller: convert active_op_t booleans to
308170
 bitmask
308170
308170
---
308170
 daemons/controld/controld_execd.c | 11 +++++------
308170
 daemons/controld/controld_lrm.h   |  8 ++++++--
308170
 2 files changed, 11 insertions(+), 8 deletions(-)
308170
308170
diff --git a/daemons/controld/controld_execd.c b/daemons/controld/controld_execd.c
308170
index 48f35dd..2c9d9c0 100644
308170
--- a/daemons/controld/controld_execd.c
308170
+++ b/daemons/controld/controld_execd.c
308170
@@ -1148,18 +1148,17 @@ cancel_op(lrm_state_t * lrm_state, const char *rsc_id, const char *key, int op,
308170
     pending = g_hash_table_lookup(lrm_state->pending_ops, key);
308170
 
308170
     if (pending) {
308170
-        if (remove && pending->remove == FALSE) {
308170
-            pending->remove = TRUE;
308170
+        if (remove && is_not_set(pending->flags, active_op_remove)) {
308170
+            set_bit(pending->flags, active_op_remove);
308170
             crm_debug("Scheduling %s for removal", key);
308170
         }
308170
 
308170
-        if (pending->cancelled) {
308170
+        if (is_set(pending->flags, active_op_cancelled)) {
308170
             crm_debug("Operation %s already cancelled", key);
308170
             free(local_key);
308170
             return FALSE;
308170
         }
308170
-
308170
-        pending->cancelled = TRUE;
308170
+        set_bit(pending->flags, active_op_cancelled);
308170
 
308170
     } else {
308170
         crm_info("No pending op found for %s", key);
308170
@@ -2652,7 +2651,7 @@ process_lrm_event(lrm_state_t *lrm_state, lrmd_event_data_t *op,
308170
         crm_err("Recurring operation %s was cancelled without transition information",
308170
                 op_key);
308170
 
308170
-    } else if (pending->remove) {
308170
+    } else if (is_set(pending->flags, active_op_remove)) {
308170
         /* This recurring operation was cancelled (by us) and pending, and we
308170
          * have been waiting for it to finish.
308170
          */
308170
diff --git a/daemons/controld/controld_lrm.h b/daemons/controld/controld_lrm.h
308170
index 27df5d7..3ab7048 100644
308170
--- a/daemons/controld/controld_lrm.h
308170
+++ b/daemons/controld/controld_lrm.h
308170
@@ -33,12 +33,16 @@ typedef struct resource_history_s {
308170
 
308170
 void history_free(gpointer data);
308170
 
308170
+enum active_op_e {
308170
+    active_op_remove    = (1 << 0),
308170
+    active_op_cancelled = (1 << 1),
308170
+};
308170
+
308170
 // In-flight action (recurring or pending)
308170
 typedef struct active_op_s {
308170
     guint interval_ms;
308170
     int call_id;
308170
-    gboolean remove;
308170
-    gboolean cancelled;
308170
+    uint32_t flags; // bitmask of active_op_e
308170
     time_t start_time;
308170
     char *rsc_id;
308170
     char *op_type;
308170
-- 
308170
1.8.3.1
308170
308170
308170
From 4d087d021d325e26b41a9b36b5b190dc7b25334c Mon Sep 17 00:00:00 2001
308170
From: Ken Gaillot <kgaillot@redhat.com>
308170
Date: Fri, 22 Nov 2019 16:58:25 -0600
308170
Subject: [PATCH 3/4] Refactor: controller: remove unused argument
308170
308170
---
308170
 daemons/controld/controld_execd.c | 10 +++++-----
308170
 1 file changed, 5 insertions(+), 5 deletions(-)
308170
308170
diff --git a/daemons/controld/controld_execd.c b/daemons/controld/controld_execd.c
308170
index 2c9d9c0..46c1958 100644
308170
--- a/daemons/controld/controld_execd.c
308170
+++ b/daemons/controld/controld_execd.c
308170
@@ -43,8 +43,8 @@ static int delete_rsc_status(lrm_state_t * lrm_state, const char *rsc_id, int ca
308170
 
308170
 static lrmd_event_data_t *construct_op(lrm_state_t * lrm_state, xmlNode * rsc_op,
308170
                                        const char *rsc_id, const char *operation);
308170
-static void do_lrm_rsc_op(lrm_state_t * lrm_state, lrmd_rsc_info_t * rsc, const char *operation,
308170
-                          xmlNode * msg, xmlNode * request);
308170
+static void do_lrm_rsc_op(lrm_state_t *lrm_state, lrmd_rsc_info_t *rsc,
308170
+                          const char *operation, xmlNode *msg);
308170
 
308170
 void send_direct_ack(const char *to_host, const char *to_sys,
308170
                      lrmd_rsc_info_t * rsc, lrmd_event_data_t * op, const char *rsc_id);
308170
@@ -1858,7 +1858,7 @@ do_lrm_invoke(long long action,
308170
                           crm_rsc_delete, user_name);
308170
 
308170
         } else {
308170
-            do_lrm_rsc_op(lrm_state, rsc, operation, input->xml, input->msg);
308170
+            do_lrm_rsc_op(lrm_state, rsc, operation, input->xml);
308170
         }
308170
 
308170
         lrmd_free_rsc_info(rsc);
308170
@@ -2170,8 +2170,8 @@ record_pending_op(const char *node_name, lrmd_rsc_info_t *rsc, lrmd_event_data_t
308170
 }
308170
 
308170
 static void
308170
-do_lrm_rsc_op(lrm_state_t * lrm_state, lrmd_rsc_info_t * rsc, const char *operation, xmlNode * msg,
308170
-              xmlNode * request)
308170
+do_lrm_rsc_op(lrm_state_t *lrm_state, lrmd_rsc_info_t *rsc,
308170
+              const char *operation, xmlNode *msg)
308170
 {
308170
     int call_id = 0;
308170
     char *op_id = NULL;
308170
-- 
308170
1.8.3.1
308170
308170
308170
From 356b417274918b7da6cdd9c72c036c923160b318 Mon Sep 17 00:00:00 2001
308170
From: Ken Gaillot <kgaillot@redhat.com>
308170
Date: Fri, 6 Dec 2019 12:15:05 -0600
308170
Subject: [PATCH 4/4] Refactor: scheduler: combine two "if" statements
308170
308170
... for readability, and ease of adding another block later
308170
---
308170
 lib/pacemaker/pcmk_sched_graph.c | 120 +++++++++++++++++++--------------------
308170
 1 file changed, 60 insertions(+), 60 deletions(-)
308170
308170
diff --git a/lib/pacemaker/pcmk_sched_graph.c b/lib/pacemaker/pcmk_sched_graph.c
308170
index e5a8a01..a6967fe 100644
308170
--- a/lib/pacemaker/pcmk_sched_graph.c
308170
+++ b/lib/pacemaker/pcmk_sched_graph.c
308170
@@ -1088,71 +1088,71 @@ action2xml(action_t * action, gboolean as_input, pe_working_set_t *data_set)
308170
         return action_xml;
308170
     }
308170
 
308170
-    /* List affected resource */
308170
-    if (action->rsc) {
308170
-        if (is_set(action->flags, pe_action_pseudo) == FALSE) {
308170
-            int lpc = 0;
308170
-
308170
-            xmlNode *rsc_xml = create_xml_node(action_xml, crm_element_name(action->rsc->xml));
308170
-
308170
-            const char *attr_list[] = {
308170
-                XML_AGENT_ATTR_CLASS,
308170
-                XML_AGENT_ATTR_PROVIDER,
308170
-                XML_ATTR_TYPE
308170
-            };
308170
-
308170
-            if (is_set(action->rsc->flags, pe_rsc_orphan) && action->rsc->clone_name) {
308170
-                /* Do not use the 'instance free' name here as that
308170
-                 * might interfere with the instance we plan to keep.
308170
-                 * Ie. if there are more than two named /anonymous/
308170
-                 * instances on a given node, we need to make sure the
308170
-                 * command goes to the right one.
308170
-                 *
308170
-                 * Keep this block, even when everyone is using
308170
-                 * 'instance free' anonymous clone names - it means
308170
-                 * we'll do the right thing if anyone toggles the
308170
-                 * unique flag to 'off'
308170
-                 */
308170
-                crm_debug("Using orphan clone name %s instead of %s", action->rsc->id,
308170
-                          action->rsc->clone_name);
308170
-                crm_xml_add(rsc_xml, XML_ATTR_ID, action->rsc->clone_name);
308170
-                crm_xml_add(rsc_xml, XML_ATTR_ID_LONG, action->rsc->id);
308170
+    if (action->rsc && is_not_set(action->flags, pe_action_pseudo)) {
308170
+        int lpc = 0;
308170
+        xmlNode *rsc_xml = NULL;
308170
+        const char *attr_list[] = {
308170
+            XML_AGENT_ATTR_CLASS,
308170
+            XML_AGENT_ATTR_PROVIDER,
308170
+            XML_ATTR_TYPE
308170
+        };
308170
+
308170
+        // List affected resource
308170
+
308170
+        rsc_xml = create_xml_node(action_xml,
308170
+                                  crm_element_name(action->rsc->xml));
308170
+        if (is_set(action->rsc->flags, pe_rsc_orphan)
308170
+            && action->rsc->clone_name) {
308170
+            /* Do not use the 'instance free' name here as that
308170
+             * might interfere with the instance we plan to keep.
308170
+             * Ie. if there are more than two named /anonymous/
308170
+             * instances on a given node, we need to make sure the
308170
+             * command goes to the right one.
308170
+             *
308170
+             * Keep this block, even when everyone is using
308170
+             * 'instance free' anonymous clone names - it means
308170
+             * we'll do the right thing if anyone toggles the
308170
+             * unique flag to 'off'
308170
+             */
308170
+            crm_debug("Using orphan clone name %s instead of %s", action->rsc->id,
308170
+                      action->rsc->clone_name);
308170
+            crm_xml_add(rsc_xml, XML_ATTR_ID, action->rsc->clone_name);
308170
+            crm_xml_add(rsc_xml, XML_ATTR_ID_LONG, action->rsc->id);
308170
 
308170
-            } else if (is_not_set(action->rsc->flags, pe_rsc_unique)) {
308170
-                const char *xml_id = ID(action->rsc->xml);
308170
-
308170
-                crm_debug("Using anonymous clone name %s for %s (aka. %s)", xml_id, action->rsc->id,
308170
-                          action->rsc->clone_name);
308170
-
308170
-                /* ID is what we'd like client to use
308170
-                 * ID_LONG is what they might know it as instead
308170
-                 *
308170
-                 * ID_LONG is only strictly needed /here/ during the
308170
-                 * transition period until all nodes in the cluster
308170
-                 * are running the new software /and/ have rebooted
308170
-                 * once (meaning that they've only ever spoken to a DC
308170
-                 * supporting this feature).
308170
-                 *
308170
-                 * If anyone toggles the unique flag to 'on', the
308170
-                 * 'instance free' name will correspond to an orphan
308170
-                 * and fall into the clause above instead
308170
-                 */
308170
-                crm_xml_add(rsc_xml, XML_ATTR_ID, xml_id);
308170
-                if (action->rsc->clone_name && safe_str_neq(xml_id, action->rsc->clone_name)) {
308170
-                    crm_xml_add(rsc_xml, XML_ATTR_ID_LONG, action->rsc->clone_name);
308170
-                } else {
308170
-                    crm_xml_add(rsc_xml, XML_ATTR_ID_LONG, action->rsc->id);
308170
-                }
308170
+        } else if (is_not_set(action->rsc->flags, pe_rsc_unique)) {
308170
+            const char *xml_id = ID(action->rsc->xml);
308170
+
308170
+            crm_debug("Using anonymous clone name %s for %s (aka. %s)", xml_id, action->rsc->id,
308170
+                      action->rsc->clone_name);
308170
 
308170
+            /* ID is what we'd like client to use
308170
+             * ID_LONG is what they might know it as instead
308170
+             *
308170
+             * ID_LONG is only strictly needed /here/ during the
308170
+             * transition period until all nodes in the cluster
308170
+             * are running the new software /and/ have rebooted
308170
+             * once (meaning that they've only ever spoken to a DC
308170
+             * supporting this feature).
308170
+             *
308170
+             * If anyone toggles the unique flag to 'on', the
308170
+             * 'instance free' name will correspond to an orphan
308170
+             * and fall into the clause above instead
308170
+             */
308170
+            crm_xml_add(rsc_xml, XML_ATTR_ID, xml_id);
308170
+            if (action->rsc->clone_name && safe_str_neq(xml_id, action->rsc->clone_name)) {
308170
+                crm_xml_add(rsc_xml, XML_ATTR_ID_LONG, action->rsc->clone_name);
308170
             } else {
308170
-                CRM_ASSERT(action->rsc->clone_name == NULL);
308170
-                crm_xml_add(rsc_xml, XML_ATTR_ID, action->rsc->id);
308170
+                crm_xml_add(rsc_xml, XML_ATTR_ID_LONG, action->rsc->id);
308170
             }
308170
 
308170
-            for (lpc = 0; lpc < DIMOF(attr_list); lpc++) {
308170
-                crm_xml_add(rsc_xml, attr_list[lpc],
308170
-                            g_hash_table_lookup(action->rsc->meta, attr_list[lpc]));
308170
-            }
308170
+        } else {
308170
+            CRM_ASSERT(action->rsc->clone_name == NULL);
308170
+            crm_xml_add(rsc_xml, XML_ATTR_ID, action->rsc->id);
308170
+        }
308170
+
308170
+        for (lpc = 0; lpc < DIMOF(attr_list); lpc++) {
308170
+            crm_xml_add(rsc_xml, attr_list[lpc],
308170
+                        g_hash_table_lookup(action->rsc->meta, attr_list[lpc]));
308170
         }
308170
     }
308170
 
308170
-- 
308170
1.8.3.1
308170