- fence_sbd: get devices from SBD_DEVICE env variable if devices
parameter isnt set Resolves: RHEL-79799
This commit is contained in:
parent
1b21632c8d
commit
846c9ec691
@ -0,0 +1,160 @@
|
||||
From f73b6b4465de1bf2b2887efd3b9767d3f36abd24 Mon Sep 17 00:00:00 2001
|
||||
From: xin liang <xliang@suse.com>
|
||||
Date: Fri, 26 Jul 2024 10:49:55 +0800
|
||||
Subject: [PATCH 1/3] fence_sbd: if sbd devices are not specified with option,
|
||||
read SBD_DEVICE
|
||||
|
||||
from environment
|
||||
---
|
||||
agents/sbd/fence_sbd.py | 12 ++++++++----
|
||||
1 file changed, 8 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/agents/sbd/fence_sbd.py b/agents/sbd/fence_sbd.py
|
||||
index bf95bb72e..c36220295 100644
|
||||
--- a/agents/sbd/fence_sbd.py
|
||||
+++ b/agents/sbd/fence_sbd.py
|
||||
@@ -342,7 +342,7 @@ def define_new_opts():
|
||||
"longopt" : "devices",
|
||||
"help":"--devices=[device_a,device_b] \
|
||||
Comma separated list of sbd devices",
|
||||
- "required" : "1",
|
||||
+ "required" : "0",
|
||||
"shortdesc" : "SBD Device",
|
||||
"order": 1
|
||||
}
|
||||
@@ -382,10 +382,14 @@ def main():
|
||||
docs["vendorurl"] = ""
|
||||
show_docs(options, docs)
|
||||
|
||||
- # We need to check if --devices is given and not empty.
|
||||
+ # If not specified then read SBD_DEVICE from environment
|
||||
if "--devices" not in options:
|
||||
- fail_usage("No SBD devices specified. \
|
||||
- At least one SBD device is required.")
|
||||
+ dev_list = os.getenv("SBD_DEVICE")
|
||||
+ if dev_list:
|
||||
+ options["--devices"] = ",".join(dev_list.split(";"))
|
||||
+ else:
|
||||
+ fail_usage("No SBD devices specified. \
|
||||
+ At least one SBD device is required.")
|
||||
|
||||
run_delay(options)
|
||||
|
||||
|
||||
From 744d534225b51db26058660b753df2991b9356a0 Mon Sep 17 00:00:00 2001
|
||||
From: xin liang <xliang@suse.com>
|
||||
Date: Fri, 26 Jul 2024 17:45:07 +0800
|
||||
Subject: [PATCH 2/3] fence_sbd: Update fence_sbd.xml
|
||||
|
||||
---
|
||||
tests/data/metadata/fence_sbd.xml | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tests/data/metadata/fence_sbd.xml b/tests/data/metadata/fence_sbd.xml
|
||||
index 82ded25b9..c2daf0c54 100644
|
||||
--- a/tests/data/metadata/fence_sbd.xml
|
||||
+++ b/tests/data/metadata/fence_sbd.xml
|
||||
@@ -8,7 +8,7 @@
|
||||
<content type="string" default="reboot" />
|
||||
<shortdesc lang="en">Fencing action</shortdesc>
|
||||
</parameter>
|
||||
- <parameter name="devices" unique="0" required="1">
|
||||
+ <parameter name="devices" unique="0" required="0">
|
||||
<getopt mixed="--devices=[device_a,device_b]" />
|
||||
<content type="string" />
|
||||
<shortdesc lang="en">SBD Device</shortdesc>
|
||||
|
||||
From 06457f95a4d89d4b6a856ae14ccbcda4d357bef6 Mon Sep 17 00:00:00 2001
|
||||
From: xin liang <xliang@suse.com>
|
||||
Date: Tue, 10 Dec 2024 10:00:00 +0800
|
||||
Subject: [PATCH 3/3] fence_sbd: Check if the sbd daemon is running before
|
||||
using SBD_DEVICE enviroment variable
|
||||
|
||||
And add @SBDPID_PATH@ for the sbd daemon pid file path
|
||||
---
|
||||
agents/sbd/fence_sbd.py | 31 ++++++++++++++++++++++++++++++-
|
||||
configure.ac | 2 ++
|
||||
make/fencebuild.mk | 1 +
|
||||
3 files changed, 33 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/agents/sbd/fence_sbd.py b/agents/sbd/fence_sbd.py
|
||||
index c36220295..bebc7fae1 100644
|
||||
--- a/agents/sbd/fence_sbd.py
|
||||
+++ b/agents/sbd/fence_sbd.py
|
||||
@@ -14,6 +14,7 @@
|
||||
DEVICE_NOT_INIT = -3
|
||||
PATH_NOT_EXISTS = -1
|
||||
PATH_NOT_BLOCK = -2
|
||||
+SBD_PID_FILE = "@SBDPID_PATH@"
|
||||
|
||||
def is_block_device(filename):
|
||||
"""Checks if a given path is a valid block device
|
||||
@@ -356,6 +357,34 @@ def define_new_opts():
|
||||
"order": 200
|
||||
}
|
||||
|
||||
+
|
||||
+def sbd_daemon_is_running():
|
||||
+ """Check if the sbd daemon is running
|
||||
+ """
|
||||
+ if not os.path.exists(SBD_PID_FILE):
|
||||
+ logging.info("SBD PID file %s does not exist", SBD_PID_FILE)
|
||||
+ return False
|
||||
+
|
||||
+ try:
|
||||
+ with open(SBD_PID_FILE, "r") as pid_file:
|
||||
+ pid = int(pid_file.read().strip())
|
||||
+ except Exception as e:
|
||||
+ logging.error("Failed to read PID file %s: %s", SBD_PID_FILE, e)
|
||||
+ return False
|
||||
+
|
||||
+ try:
|
||||
+ # send signal 0 to check if the process is running
|
||||
+ os.kill(pid, 0)
|
||||
+ except ProcessLookupError:
|
||||
+ logging.info("SBD daemon is not running")
|
||||
+ return False
|
||||
+ except Exception as e:
|
||||
+ logging.error("Failed to send signal 0 to PID %d: %s", pid, e)
|
||||
+ return False
|
||||
+
|
||||
+ return True
|
||||
+
|
||||
+
|
||||
def main():
|
||||
"""Main function
|
||||
"""
|
||||
@@ -385,7 +414,7 @@ def main():
|
||||
# If not specified then read SBD_DEVICE from environment
|
||||
if "--devices" not in options:
|
||||
dev_list = os.getenv("SBD_DEVICE")
|
||||
- if dev_list:
|
||||
+ if dev_list and sbd_daemon_is_running():
|
||||
options["--devices"] = ",".join(dev_list.split(";"))
|
||||
else:
|
||||
fail_usage("No SBD devices specified. \
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 6b7322419..0425a9d21 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -145,6 +145,8 @@ eval FENCETMPDIR="`eval echo ${FENCETMPDIR}`"
|
||||
AC_DEFINE_UNQUOTED(FENCETMPDIR,"$FENCETMPDIR", Where Fence agents keep state files)
|
||||
AC_SUBST(FENCETMPDIR)
|
||||
|
||||
+SBDPID_PATH=${localstatedir}/run/sbd.pid
|
||||
+AC_SUBST(SBDPID_PATH)
|
||||
|
||||
if test "x$AGENTS_LIST" = x; then
|
||||
AC_ERROR([No agents selected])
|
||||
diff --git a/make/fencebuild.mk b/make/fencebuild.mk
|
||||
index 9a3c6d6dd..bc9259190 100644
|
||||
--- a/make/fencebuild.mk
|
||||
+++ b/make/fencebuild.mk
|
||||
@@ -9,6 +9,7 @@ define gen_agent_from_py
|
||||
-e 's#@''SBINDIR@#${sbindir}#g' \
|
||||
-e 's#@''LIBEXECDIR@#${libexecdir}#g' \
|
||||
-e 's#@''FENCETMPDIR@#${FENCETMPDIR}#g' \
|
||||
+ -e 's#@''SBDPID_PATH@#${SBDPID_PATH}#g' \
|
||||
-e 's#@''IPMITOOL_PATH@#${IPMITOOL_PATH}#g' \
|
||||
-e 's#@''OPENSTACK_PATH@#${OPENSTACK_PATH}#g' \
|
||||
-e 's#@''AMTTOOL_PATH@#${AMTTOOL_PATH}#g' \
|
@ -13,7 +13,7 @@
|
||||
Name: fence-agents
|
||||
Summary: Set of unified programs capable of host isolation ("fencing")
|
||||
Version: 4.16.0
|
||||
Release: 6%{?alphatag:.%{alphatag}}%{?dist}
|
||||
Release: 7%{?alphatag:.%{alphatag}}%{?dist}
|
||||
License: GPL-2.0-or-later AND LGPL-2.0-or-later
|
||||
URL: https://github.com/ClusterLabs/fence-agents
|
||||
Source0: https://fedorahosted.org/releases/f/e/fence-agents/%{name}-%{version}.tar.gz
|
||||
@ -107,6 +107,7 @@ Patch6: bundled-kubevirt.patch
|
||||
Patch7: bundled-pycurl.patch
|
||||
Patch8: bundled-suds.patch
|
||||
Patch9: RHEL-83520-fence_ibm_vpc-refresh-bearer-token.patch
|
||||
Patch10: RHEL-79799-fence_sbd-get-devices-from-SBD_DEVICE-if-devices-parameter-isnt-set.patch
|
||||
|
||||
%global supportedagents amt_ws apc apc_snmp bladecenter brocade cisco_mds cisco_ucs drac5 eaton_snmp emerson eps hpblade ibmblade ibm_powervs ibm_vpc ifmib ilo ilo_moonshot ilo_mp ilo_ssh intelmodular ipdu ipmilan kdump kubevirt lpar mpath redfish rhevm rsa rsb sbd scsi vmware_rest vmware_soap wti
|
||||
%ifarch x86_64
|
||||
@ -225,6 +226,7 @@ BuildRequires: %{systemd_units}
|
||||
%patch -p1 -P 7
|
||||
%patch -p1 -P 8
|
||||
%patch -p1 -P 9
|
||||
%patch -p1 -P 10
|
||||
|
||||
# prevent compilation of something that won't get used anyway
|
||||
sed -i.orig 's|FENCE_ZVM=1|FENCE_ZVM=0|' configure.ac
|
||||
@ -1184,6 +1186,11 @@ are located on corosync cluster nodes.
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Tue Mar 25 2025 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.16.0-7
|
||||
- fence_sbd: get devices from SBD_DEVICE env variable if devices
|
||||
parameter isnt set
|
||||
Resolves: RHEL-79799
|
||||
|
||||
* Mon Mar 17 2025 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.16.0-6
|
||||
- fence_ibm_vpc: refresh bearer-token if token data is corrupt, and
|
||||
avoid edge-case of writing empty token file
|
||||
|
Loading…
Reference in New Issue
Block a user