From 02d1822169ff8bafc491528a0f7af9c05fd2b332 Mon Sep 17 00:00:00 2001 From: liupei Date: Wed, 22 May 2024 18:45:43 +0800 Subject: [PATCH] fence_scsi: Automatically detect devices for shared VGs fence_scsi: Add support for space-separated devices and update in meta-data --- ...ated-devices-and-update-in-meta-data.patch | 95 +++++++++++++++++++ ...ically-detect-devices-for-shared-VGs.patch | 61 ++++++++++++ fence-agents.spec | 8 +- 3 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 backport-fence_scsi-Add-support-for-space-separated-devices-and-update-in-meta-data.patch create mode 100644 backport-fence_scsi-Automatically-detect-devices-for-shared-VGs.patch diff --git a/backport-fence_scsi-Add-support-for-space-separated-devices-and-update-in-meta-data.patch b/backport-fence_scsi-Add-support-for-space-separated-devices-and-update-in-meta-data.patch new file mode 100644 index 0000000..a098bda --- /dev/null +++ b/backport-fence_scsi-Add-support-for-space-separated-devices-and-update-in-meta-data.patch @@ -0,0 +1,95 @@ +From e363e55169a7be1cbeac5568fe2a32692867d4c6 Mon Sep 17 00:00:00 2001 +From: Arslan Ahmad +Date: Thu, 4 May 2023 12:55:41 +0530 +Subject: [PATCH 08/46] fence_scsi: Add support for space-separated devices and + update in meta-data + +Currently the devices associated with fence_scsi should be +comma-separated. With this commit, fence_scsi will also work if the +'devices' are space-separated. + +Additionally, this commit includes meta-data update: +1. For fence_scsi: + - The 'devices' parameter is optional if the cluster is configured with +clvm/lvmlock. + - The 'devices' parameter can be comma or space-separated. + +2. For fence_mpath: + - The 'devices' parameter can be comma or space-separated. +--- + agents/mpath/fence_mpath.py | 2 +- + agents/scsi/fence_scsi.py | 8 ++++---- + tests/data/metadata/fence_mpath.xml | 2 +- + tests/data/metadata/fence_scsi.xml | 2 +- + 4 files changed, 7 insertions(+), 7 deletions(-) + +diff --git a/agents/mpath/fence_mpath.py b/agents/mpath/fence_mpath.py +index ee81eab3..6976fee9 100644 +--- a/agents/mpath/fence_mpath.py ++++ b/agents/mpath/fence_mpath.py +@@ -226,7 +226,7 @@ def define_new_opts(): + "help" : "-d, --devices=[devices] List of devices to use for current operation", + "required" : "0", + "shortdesc" : "List of devices to use for current operation. Devices can \ +-be comma-separated list of device-mapper multipath devices (eg. /dev/mapper/3600508b400105df70000e00000ac0000 or /dev/mapper/mpath1). \ ++be comma or space separated list of device-mapper multipath devices (eg. /dev/mapper/3600508b400105df70000e00000ac0000 or /dev/mapper/mpath1). \ + Each device must support SCSI-3 persistent reservations.", + "order": 1 + } +diff --git a/agents/scsi/fence_scsi.py b/agents/scsi/fence_scsi.py +index 3de4ba0b..42530ceb 100644 +--- a/agents/scsi/fence_scsi.py ++++ b/agents/scsi/fence_scsi.py +@@ -350,8 +350,8 @@ def define_new_opts(): + "help" : "-d, --devices=[devices] List of devices to use for current operation", + "required" : "0", + "shortdesc" : "List of devices to use for current operation. Devices can \ +-be comma-separated list of raw devices (eg. /dev/sdc). Each device must support SCSI-3 \ +-persistent reservations.", ++be comma or space separated list of raw devices (eg. /dev/sdc). Each device must support SCSI-3 \ ++persistent reservations. Optional if cluster is configured with clvm or lvmlockd.", + "order": 1 + } + all_opt["nodename"] = { +@@ -612,10 +612,10 @@ failing." + + options["--key"] = options["--key"].lstrip('0') + +- if not ("--devices" in options and options["--devices"].split(",")): ++ if not ("--devices" in options and [d for d in re.split("\s*,\s*|\s+", options["--devices"].strip()) if d]): + options["devices"] = get_shared_devices(options) + else: +- options["devices"] = options["--devices"].split(",") ++ options["devices"] = [d for d in re.split("\s*,\s*|\s+", options["--devices"].strip()) if d] + + if not options["devices"]: + fail_usage("Failed: No devices found") +diff --git a/tests/data/metadata/fence_mpath.xml b/tests/data/metadata/fence_mpath.xml +index e22d3a1f..262956dc 100644 +--- a/tests/data/metadata/fence_mpath.xml ++++ b/tests/data/metadata/fence_mpath.xml +@@ -14,7 +14,7 @@ When used as a watchdog device you can define e.g. retry=1, retry-sleep=2 and ve + + + +- List of devices to use for current operation. Devices can be comma-separated list of device-mapper multipath devices (eg. /dev/mapper/3600508b400105df70000e00000ac0000 or /dev/mapper/mpath1). Each device must support SCSI-3 persistent reservations. ++ List of devices to use for current operation. Devices can be comma or space separated list of device-mapper multipath devices (eg. /dev/mapper/3600508b400105df70000e00000ac0000 or /dev/mapper/mpath1). Each device must support SCSI-3 persistent reservations. + + + +diff --git a/tests/data/metadata/fence_scsi.xml b/tests/data/metadata/fence_scsi.xml +index 4fa86189..facb2f52 100644 +--- a/tests/data/metadata/fence_scsi.xml ++++ b/tests/data/metadata/fence_scsi.xml +@@ -19,7 +19,7 @@ When used as a watchdog device you can define e.g. retry=1, retry-sleep=2 and ve + + + +- List of devices to use for current operation. Devices can be comma-separated list of raw devices (eg. /dev/sdc). Each device must support SCSI-3 persistent reservations. ++ List of devices to use for current operation. Devices can be comma or space separated list of raw devices (eg. /dev/sdc). Each device must support SCSI-3 persistent reservations. Optional if cluster is configured with clvm or lvmlockd. + + + +-- +2.25.1 + diff --git a/backport-fence_scsi-Automatically-detect-devices-for-shared-VGs.patch b/backport-fence_scsi-Automatically-detect-devices-for-shared-VGs.patch new file mode 100644 index 0000000..3cc4580 --- /dev/null +++ b/backport-fence_scsi-Automatically-detect-devices-for-shared-VGs.patch @@ -0,0 +1,61 @@ +From 4661b6f625c57a728ec58023da89ba378d4d1c27 Mon Sep 17 00:00:00 2001 +From: Arslan Ahmad +Date: Mon, 17 Apr 2023 15:59:49 +0530 +Subject: [PATCH 06/46] fence_scsi: Automatically detect devices for shared VGs + +Currently, if no devices option is given, fence_scsi automatically +builds a device list containing all LVM PVs that back VGs with the +clustered ('c') bit set. With this commit, fence_scsi will also consider +VGs with the shared ('s') bit set. + +Additionally, the existing check is too broad. We should consider a +volume group to be clustered or shared only if the 6th bit is set to 'c' +or 's'. This way, we can avoid false positives. + +Closes RHBZ#2187327 +Closes RHBZ#2187329 +--- + agents/scsi/fence_scsi.py | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +diff --git a/agents/scsi/fence_scsi.py b/agents/scsi/fence_scsi.py +index 85e4f29e..3de4ba0b 100644 +--- a/agents/scsi/fence_scsi.py ++++ b/agents/scsi/fence_scsi.py +@@ -314,7 +314,7 @@ def dev_read(fail=True, opt=None): + return devs + + +-def get_clvm_devices(options): ++def get_shared_devices(options): + devs = [] + cmd = options["--vgs-path"] + " " +\ + "--noheadings " +\ +@@ -324,10 +324,11 @@ def get_clvm_devices(options): + "--config 'global { locking_type = 0 } devices { preferred_names = [ \"^/dev/dm\" ] }'" + out = run_cmd(options, cmd) + if out["rc"]: +- fail_usage("Failed: Cannot get clvm devices") +- for line in out["out"].split("\n"): +- if 'c' in line.split(":")[0]: +- devs.append(line.split(":")[1]) ++ fail_usage("Failed: Cannot get shared devices") ++ for line in out["out"].splitlines(): ++ vg_attr, pv_name = line.strip().split(":") ++ if vg_attr[5] in "cs": ++ devs.append(pv_name) + return devs + + +@@ -612,7 +613,7 @@ failing." + options["--key"] = options["--key"].lstrip('0') + + if not ("--devices" in options and options["--devices"].split(",")): +- options["devices"] = get_clvm_devices(options) ++ options["devices"] = get_shared_devices(options) + else: + options["devices"] = options["--devices"].split(",") + +-- +2.25.1 + diff --git a/fence-agents.spec b/fence-agents.spec index b63024f..9ff297a 100644 --- a/fence-agents.spec +++ b/fence-agents.spec @@ -6,7 +6,7 @@ Name: fence-agents Summary: Set of unified programs capable of host isolation ("fencing") Version: 4.12.1 -Release: 6 +Release: 7 License: GPLv2+ and LGPLv2+ Group: System Environment/Base URL: https://github.com/ClusterLabs/fence-agents @@ -14,6 +14,8 @@ Source0: https://github.com/ClusterLabs/fence-agents/archive//v%{version}/%{name Patch0: fence_ipmilan-fix-typo-in-description.patch Patch1: fence_scsi-fix-registration-handling-if-ISID-conflic.patch Patch2: fence_scsi-fix-registration-handling-in-device-off-workflows.patch +Patch3: backport-fence_scsi-Automatically-detect-devices-for-shared-VGs.patch +Patch4: backport-fence_scsi-Add-support-for-space-separated-devices-and-update-in-meta-data.patch # skipped: pve, raritan, rcd-serial, virsh %global allfenceagents %(cat < - 4.12.1-7 +- fence_scsi: Automatically detect devices for shared VGs + fence_scsi: Add support for space-separated devices and update in meta-data + * Mon May 13 2024 zouzhimin - 4.12.1-6 - fence_scsi: fix registration handling in device 'off' workflows -- Gitee