fence-agents/RHEL-56138-fence_mpath-2-fix-unfencing-issue-use-MULTILINE-avoid-duplicates.patch

45 lines
1.7 KiB
Diff
Raw Permalink Normal View History

From 99c5c3289b23064441f998949808a0b3569c2e3b Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Thu, 10 Oct 2024 09:55:16 +0200
Subject: [PATCH] fence_mpath: fix 0x-format patch causing unfencing issue, and
use re.MULTILINE to avoid duplicating device dev/key lines in
/run/cluster/mpath.devices
---
agents/mpath/fence_mpath.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/agents/mpath/fence_mpath.py b/agents/mpath/fence_mpath.py
index 2d8601497..2a4a58b36 100644
--- a/agents/mpath/fence_mpath.py
+++ b/agents/mpath/fence_mpath.py
@@ -40,7 +40,7 @@ def set_status(conn, options):
if options["--plug"] not in get_registration_keys(options, dev):
count += 1
logging.debug("Failed to register key "\
- + options["--plug"] + "on device " + dev + "\n")
+ + options["--plug"] + " on device " + dev + "\n")
continue
dev_write(options, dev)
@@ -147,8 +147,9 @@ def dev_write(options, dev):
store_fh = open(file_path, "a+")
except IOError:
fail_usage("Failed: Cannot open file \""+ file_path + "\"")
+ store_fh.seek(0)
out = store_fh.read()
- if not re.search(r"^" + dev + r"\s+", out):
+ if not re.search(r"^{}\s+{}$".format(dev, options["--plug"]), out, flags=re.MULTILINE):
store_fh.write(dev + "\t" + options["--plug"] + "\n")
store_fh.close()
@@ -332,7 +333,7 @@ def main():
fail_usage("Failed: No devices found")
options["devices"] = [d for d in re.split("\s*,\s*|\s+", options["--devices"].strip()) if d]
- options["--plug"] = re.sub(r"^0x0*|^0+", "", options["--plug"])
+ options["--plug"] = re.sub(r"^0x0*|^0+", "", options.get("--plug", ""))
# Input control END
result = fence_action(None, options, set_status, get_status)