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

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