- fence_ibm_powervs: performance improvements

Resolves: rhbz#2221643
This commit is contained in:
Oyvind Albrigtsen 2023-07-11 10:40:09 +02:00
parent 73b8678fb0
commit 03210e5733
2 changed files with 157 additions and 1 deletions

View File

@ -0,0 +1,150 @@
From 22935608247816be0ccec85fc590f19b509f3614 Mon Sep 17 00:00:00 2001
From: Andreas Schauberer <74912604+andscha@users.noreply.github.com>
Date: Thu, 15 Jun 2023 16:34:13 +0200
Subject: [PATCH 1/3] fence_ibm_powervs: improved performance
fence_ibm_powervs: improved performance
- improved performance using less power-iaas.cloud.ibm.com API calls
- add support for reboot_cycle, method to fence (onoff|cycle) (Default: onoff)
Addressed comments by oalbrigt in ClusterLabs #PR542
- you can use if options["--verbose-level"] > 1: to only print it when -vv or more or verbose_level is set to 2 or higher.
- Removed all_opt["method"] defaults
---
agents/ibm_powervs/fence_ibm_powervs.py | 70 ++++++++++++++++++-------
1 file changed, 51 insertions(+), 19 deletions(-)
diff --git a/agents/ibm_powervs/fence_ibm_powervs.py b/agents/ibm_powervs/fence_ibm_powervs.py
index 183893616..e65462cb9 100755
--- a/agents/ibm_powervs/fence_ibm_powervs.py
+++ b/agents/ibm_powervs/fence_ibm_powervs.py
@@ -12,6 +12,8 @@
state = {
"ACTIVE": "on",
"SHUTOFF": "off",
+ "HARD_REBOOT": "on",
+ "SOFT_REBOOT": "on",
"ERROR": "unknown"
}
@@ -37,21 +39,30 @@ def get_list(conn, options):
return outlets
for r in res["pvmInstances"]:
- if "--verbose" in options:
+ if options["--verbose-level"] > 1:
logging.debug(json.dumps(r, indent=2))
outlets[r["pvmInstanceID"]] = (r["serverName"], state[r["status"]])
return outlets
def get_power_status(conn, options):
+ outlets = {}
+ logging.debug("Info: getting power status for LPAR " + options["--plug"] + " instance " + options["--instance"])
try:
command = "cloud-instances/{}/pvm-instances/{}".format(
options["--instance"], options["--plug"])
res = send_command(conn, command)
- result = get_list(conn, options)[options["--plug"]][1]
+ outlets[res["pvmInstanceID"]] = (res["serverName"], state[res["status"]])
+ if options["--verbose-level"] > 1:
+ logging.debug(json.dumps(res, indent=2))
+ result = outlets[options["--plug"]][1]
+ logging.debug("Info: Status: {}".format(result))
except KeyError as e:
- logging.debug("Failed: Unable to get status for {}".format(e))
- fail(EC_STATUS)
+ try:
+ result = get_list(conn, options)[options["--plug"]][1]
+ except KeyError as ex:
+ logging.debug("Failed: Unable to get status for {}".format(ex))
+ fail(EC_STATUS)
return result
@@ -61,6 +72,7 @@ def set_power_status(conn, options):
"off" : '{"action" : "immediate-shutdown"}',
}[options["--action"]]
+ logging.debug("Info: set power status to " + options["--action"] + " for LPAR " + options["--plug"] + " instance " + options["--instance"])
try:
send_command(conn, "cloud-instances/{}/pvm-instances/{}/action".format(
options["--instance"], options["--plug"]), "POST", action)
@@ -68,6 +80,25 @@ def set_power_status(conn, options):
logging.debug("Failed: Unable to set power to {} for {}".format(options["--action"], e))
fail(EC_STATUS)
+def reboot_cycle(conn, options):
+ action = {
+ "reboot" : '{"action" : "hard-reboot"}',
+ }[options["--action"]]
+
+ logging.debug("Info: start reboot cycle with action " + options["--action"] + " for LPAR " + options["--plug"] + " instance " + options["--instance"])
+ try:
+ send_command(conn, "cloud-instances/{}/pvm-instances/{}/action".format(
+ options["--instance"], options["--plug"]), "POST", action)
+ except Exception as e:
+ result = get_power_status(conn, options)
+ logging.debug("Info: Status {}".format(result))
+ if result == "off":
+ return True
+ else:
+ logging.debug("Failed: Unable to cycle with {} for {}".format(options["--action"], e))
+ fail(EC_STATUS)
+ return True
+
def connect(opt, token):
conn = pycurl.Curl()
@@ -200,21 +231,21 @@ def define_new_opts():
"order" : 0
}
all_opt["api-type"] = {
- "getopt" : ":",
- "longopt" : "api-type",
- "help" : "--api-type=[public|private] API-type: 'public' (default) or 'private'",
- "required" : "0",
- "shortdesc" : "API-type (public|private)",
- "order" : 0
- }
+ "getopt" : ":",
+ "longopt" : "api-type",
+ "help" : "--api-type=[public|private] API-type: 'public' (default) or 'private'",
+ "required" : "0",
+ "shortdesc" : "API-type (public|private)",
+ "order" : 0
+ }
all_opt["proxy"] = {
- "getopt" : ":",
- "longopt" : "proxy",
- "help" : "--proxy=[http://<URL>:<PORT>] Proxy: 'http://<URL>:<PORT>'",
- "required" : "0",
- "shortdesc" : "Network proxy",
- "order" : 0
- }
+ "getopt" : ":",
+ "longopt" : "proxy",
+ "help" : "--proxy=[http://<URL>:<PORT>] Proxy: 'http://<URL>:<PORT>'",
+ "required" : "0",
+ "shortdesc" : "Network proxy",
+ "order" : 0
+ }
def main():
@@ -227,6 +258,7 @@ def main():
"proxy",
"port",
"no_password",
+ "method",
]
atexit.register(atexit_handler)
@@ -259,7 +291,7 @@ def main():
conn = connect(options, token)
atexit.register(disconnect, conn)
- result = fence_action(conn, options, set_power_status, get_power_status, get_list)
+ result = fence_action(conn, options, set_power_status, get_power_status, get_list, reboot_cycle)
sys.exit(result)

View File

@ -60,7 +60,7 @@
Name: fence-agents
Summary: Set of unified programs capable of host isolation ("fencing")
Version: 4.10.0
Release: 47%{?alphatag:.%{alphatag}}%{?dist}
Release: 48%{?alphatag:.%{alphatag}}%{?dist}
License: GPLv2+ and LGPLv2+
URL: https://github.com/ClusterLabs/fence-agents
Source0: https://fedorahosted.org/releases/f/e/fence-agents/%{name}-%{version}.tar.gz
@ -236,6 +236,7 @@ Patch41: bz2183162-fence_aws-2-fail-when-power-action-request-fails.patch
Patch42: bz2187327-fence_scsi-1-detect-devices-in-shared-vgs.patch
Patch43: bz2187327-fence_scsi-2-support-space-separated-devices.patch
Patch44: bz2211930-fence_azure-arm-stack-hub-support.patch
Patch45: bz2221643-fence_ibm_powervs-performance-improvements.patch
%global supportedagents amt_ws apc apc_snmp bladecenter brocade cisco_mds cisco_ucs compute drac5 eaton_snmp emerson eps evacuate 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
@ -391,6 +392,7 @@ BuildRequires: %{systemd_units}
%patch42 -p1
%patch43 -p1
%patch44 -p1
%patch45 -p1
# prevent compilation of something that won't get used anyway
sed -i.orig 's|FENCE_ZVM=1|FENCE_ZVM=0|' configure.ac
@ -1457,6 +1459,10 @@ are located on corosync cluster nodes.
%endif
%changelog
* Tue Jul 11 2023 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-48
- fence_ibm_powervs: performance improvements
Resolves: rhbz#2221643
* Tue Jun 20 2023 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-47
- fence_azure_arm: add Stack Hub support
Resolves: rhbz#2211930