Blame SOURCES/008-dynamic-list-fencing.patch

7ac83c
From 2d15fb37525f88ec8d5acb689b698044c4bb69b1 Mon Sep 17 00:00:00 2001
7ac83c
From: Hideo Yamauchi <renayama19661014@ybb.ne.jp>
7ac83c
Date: Thu, 17 Jun 2021 22:39:12 +0900
7ac83c
Subject: [PATCH 1/2] Low: fenced: Low: fenced: Remove unnecessary release.
7ac83c
7ac83c
---
7ac83c
 daemons/fenced/fenced_commands.c | 3 ---
7ac83c
 1 file changed, 3 deletions(-)
7ac83c
7ac83c
diff --git a/daemons/fenced/fenced_commands.c b/daemons/fenced/fenced_commands.c
7ac83c
index fee55a7..35aec06 100644
7ac83c
--- a/daemons/fenced/fenced_commands.c
7ac83c
+++ b/daemons/fenced/fenced_commands.c
7ac83c
@@ -1104,9 +1104,6 @@ dynamic_list_search_cb(GPid pid, int rc, const char *output, gpointer user_data)
7ac83c
         /* Fall back to status */
7ac83c
         g_hash_table_replace(dev->params,
7ac83c
                              strdup(PCMK_STONITH_HOST_CHECK), strdup("status"));
7ac83c
-
7ac83c
-        g_list_free_full(dev->targets, free);
7ac83c
-        dev->targets = NULL;
7ac83c
     } else if (!rc) {
7ac83c
         crm_info("Refreshing port list for %s", dev->id);
7ac83c
         g_list_free_full(dev->targets, free);
7ac83c
-- 
7ac83c
1.8.3.1
7ac83c
7ac83c
7ac83c
From a29f88f6020aac5f1ac32072942eb5713d7be50d Mon Sep 17 00:00:00 2001
7ac83c
From: Hideo Yamauchi <renayama19661014@ybb.ne.jp>
7ac83c
Date: Thu, 17 Jun 2021 22:40:40 +0900
7ac83c
Subject: [PATCH 2/2] High: fenced: Wrong device may be selected when
7ac83c
 "dynamic-list" is specified.
7ac83c
7ac83c
---
7ac83c
 daemons/fenced/fenced_commands.c | 67 +++++++++++++++++++++++-----------------
7ac83c
 1 file changed, 38 insertions(+), 29 deletions(-)
7ac83c
7ac83c
diff --git a/daemons/fenced/fenced_commands.c b/daemons/fenced/fenced_commands.c
7ac83c
index 35aec06..da076fb 100644
7ac83c
--- a/daemons/fenced/fenced_commands.c
7ac83c
+++ b/daemons/fenced/fenced_commands.c
7ac83c
@@ -904,6 +904,31 @@ xml2device_params(const char *name, xmlNode *dev)
7ac83c
     return params;
7ac83c
 }
7ac83c
 
7ac83c
+static const char *
7ac83c
+target_list_type(stonith_device_t * dev)
7ac83c
+{
7ac83c
+    const char *check_type = NULL;
7ac83c
+
7ac83c
+    check_type = g_hash_table_lookup(dev->params, PCMK_STONITH_HOST_CHECK);
7ac83c
+
7ac83c
+    if (check_type == NULL) {
7ac83c
+
7ac83c
+        if (g_hash_table_lookup(dev->params, PCMK_STONITH_HOST_LIST)) {
7ac83c
+            check_type = "static-list";
7ac83c
+        } else if (g_hash_table_lookup(dev->params, PCMK_STONITH_HOST_MAP)) {
7ac83c
+            check_type = "static-list";
7ac83c
+        } else if (pcmk_is_set(dev->flags, st_device_supports_list)) {
7ac83c
+            check_type = "dynamic-list";
7ac83c
+        } else if (pcmk_is_set(dev->flags, st_device_supports_status)) {
7ac83c
+            check_type = "status";
7ac83c
+        } else {
7ac83c
+            check_type = "none";
7ac83c
+        }
7ac83c
+    }
7ac83c
+
7ac83c
+    return check_type;
7ac83c
+}
7ac83c
+
7ac83c
 static stonith_device_t *
7ac83c
 build_device_from_xml(xmlNode * msg)
7ac83c
 {
7ac83c
@@ -931,6 +956,12 @@ build_device_from_xml(xmlNode * msg)
7ac83c
     value = g_hash_table_lookup(device->params, PCMK_STONITH_HOST_MAP);
7ac83c
     device->aliases = build_port_aliases(value, &(device->targets));
7ac83c
 
7ac83c
+    value = target_list_type(device);
7ac83c
+    if (!pcmk__str_eq(value, "static-list", pcmk__str_casei) && device->targets) {
7ac83c
+        /* Other than "static-list", dev-> targets is unnecessary. */
7ac83c
+        g_list_free_full(device->targets, free);
7ac83c
+        device->targets = NULL;
7ac83c
+    }
7ac83c
     device->agent_metadata = get_agent_metadata(device->agent);
7ac83c
     if (device->agent_metadata) {
7ac83c
         read_action_metadata(device);
7ac83c
@@ -971,31 +1002,6 @@ build_device_from_xml(xmlNode * msg)
7ac83c
     return device;
7ac83c
 }
7ac83c
 
7ac83c
-static const char *
7ac83c
-target_list_type(stonith_device_t * dev)
7ac83c
-{
7ac83c
-    const char *check_type = NULL;
7ac83c
-
7ac83c
-    check_type = g_hash_table_lookup(dev->params, PCMK_STONITH_HOST_CHECK);
7ac83c
-
7ac83c
-    if (check_type == NULL) {
7ac83c
-
7ac83c
-        if (g_hash_table_lookup(dev->params, PCMK_STONITH_HOST_LIST)) {
7ac83c
-            check_type = "static-list";
7ac83c
-        } else if (g_hash_table_lookup(dev->params, PCMK_STONITH_HOST_MAP)) {
7ac83c
-            check_type = "static-list";
7ac83c
-        } else if (pcmk_is_set(dev->flags, st_device_supports_list)) {
7ac83c
-            check_type = "dynamic-list";
7ac83c
-        } else if (pcmk_is_set(dev->flags, st_device_supports_status)) {
7ac83c
-            check_type = "status";
7ac83c
-        } else {
7ac83c
-            check_type = "none";
7ac83c
-        }
7ac83c
-    }
7ac83c
-
7ac83c
-    return check_type;
7ac83c
-}
7ac83c
-
7ac83c
 static void
7ac83c
 schedule_internal_command(const char *origin,
7ac83c
                           stonith_device_t * device,
7ac83c
@@ -1099,11 +1105,14 @@ dynamic_list_search_cb(GPid pid, int rc, const char *output, gpointer user_data)
7ac83c
 
7ac83c
     /* If we successfully got the targets earlier, don't disable. */
7ac83c
     if (rc != 0 && !dev->targets) {
7ac83c
-        crm_notice("Disabling port list queries for %s: %s "
7ac83c
-                   CRM_XS " rc=%d", dev->id, output, rc);
7ac83c
-        /* Fall back to status */
7ac83c
-        g_hash_table_replace(dev->params,
7ac83c
+        if (g_hash_table_lookup(dev->params, PCMK_STONITH_HOST_CHECK) == NULL) {
7ac83c
+            /*
7ac83c
+                If the operation fails if the user does not explicitly specify "dynamic-list", it will fall back to "status".
7ac83c
+            */
7ac83c
+            crm_notice("Disabling port list queries for %s (%d): %s", dev->id, rc, output);
7ac83c
+            g_hash_table_replace(dev->params,
7ac83c
                              strdup(PCMK_STONITH_HOST_CHECK), strdup("status"));
7ac83c
+        }
7ac83c
     } else if (!rc) {
7ac83c
         crm_info("Refreshing port list for %s", dev->id);
7ac83c
         g_list_free_full(dev->targets, free);
7ac83c
-- 
7ac83c
1.8.3.1
7ac83c