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

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