diff --git a/RHEL-68322-fence_nutanix_ahv-handle-api-rate-limits.patch b/RHEL-68322-fence_nutanix_ahv-handle-api-rate-limits.patch new file mode 100644 index 0000000..0d95125 --- /dev/null +++ b/RHEL-68322-fence_nutanix_ahv-handle-api-rate-limits.patch @@ -0,0 +1,69 @@ +From 03c599c9d2d5a42b4aea6db66e3a50263fb78440 Mon Sep 17 00:00:00 2001 +From: Govindarajan Soundararajan +Date: Thu, 30 Jan 2025 02:01:28 -0800 +Subject: [PATCH] fence_nutanix_ahv: Handle API rate limits (#604) + +Nutanix Prism Central has rate limits set on +various API end points. The fence agent should +handle such rate limit errors and retry API requests +appropriately if it encounters any such errors. This +change adds retries for HTTP error 429 (rate limit), +and also for HTTP errors 500, and 503. +--- + agents/nutanix_ahv/fence_nutanix_ahv.py | 17 +++++++++++++---- + 1 file changed, 13 insertions(+), 4 deletions(-) + +diff --git a/agents/nutanix_ahv/fence_nutanix_ahv.py b/agents/nutanix_ahv/fence_nutanix_ahv.py +index 1a422ddad..67e6d907c 100644 +--- a/agents/nutanix_ahv/fence_nutanix_ahv.py ++++ b/agents/nutanix_ahv/fence_nutanix_ahv.py +@@ -10,6 +10,8 @@ + import time + import uuid + import requests ++from requests.adapters import HTTPAdapter ++from requests.packages.urllib3.util.retry import Retry + + sys.path.append("@FENCEAGENTSLIBDIR@") + from fencing import * +@@ -20,6 +22,7 @@ + MIN_TIMEOUT = 60 + PC_PORT = 9440 + POWER_STATES = {"ON": "on", "OFF": "off", "PAUSED": "off", "UNKNOWN": "unknown"} ++MAX_RETRIES = 5 + + + class NutanixClientException(Exception): +@@ -44,22 +47,28 @@ def __init__(self, username, password, disable_warnings=False): + self.password = password + self.valid_status_codes = [200, 202] + self.disable_warnings = disable_warnings ++ self.session = requests.Session() ++ self.session.auth = (self.username, self.password) ++ ++ retry_strategy = Retry(total=MAX_RETRIES, ++ backoff_factor=1, ++ status_forcelist=[429, 500, 503]) ++ ++ self.session.mount("https://", HTTPAdapter(max_retries=retry_strategy)) + + def request(self, url, method='GET', headers=None, **kwargs): +- session = requests.Session() +- session.auth = (self.username, self.password) + + if self.disable_warnings: + requests.packages.urllib3.disable_warnings() + + if headers: +- session.headers.update(headers) ++ self.session.headers.update(headers) + + response = None + + try: + logging.debug("Sending %s request to %s", method, url) +- response = session.request(method, url, **kwargs) ++ response = self.session.request(method, url, **kwargs) + response.raise_for_status() + except requests.exceptions.SSLError as err: + logging.error("Secure connection failed, verify SSL certificate") diff --git a/fence-agents.spec b/fence-agents.spec index 1147587..edf3924 100644 --- a/fence-agents.spec +++ b/fence-agents.spec @@ -13,7 +13,7 @@ Name: fence-agents Summary: Set of unified programs capable of host isolation ("fencing") Version: 4.16.0 -Release: 7%{?alphatag:.%{alphatag}}%{?dist} +Release: 8%{?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 @@ -108,8 +108,9 @@ 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 +Patch11: RHEL-68322-fence_nutanix_ahv-handle-api-rate-limits.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 +%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 nutanix_ahv redfish rhevm rsa rsb sbd scsi vmware_rest vmware_soap wti %ifarch x86_64 %global testagents virsh heuristics_ping aliyun aws azure_arm gce openstack virt %endif @@ -227,6 +228,7 @@ BuildRequires: %{systemd_units} %patch -p1 -P 8 %patch -p1 -P 9 %patch -p1 -P 10 +%patch -p1 -P 11 # prevent compilation of something that won't get used anyway sed -i.orig 's|FENCE_ZVM=1|FENCE_ZVM=0|' configure.ac @@ -942,6 +944,19 @@ Device Mapper Multipath. %{_datadir}/cluster/fence_mpath_check* %{_mandir}/man8/fence_mpath.8* +%package nutanix-ahv +License: GPL-2.0-or-later AND LGPL-2.0-or-later +Summary: Fence agent for Nutanix AHV +Requires: python3-requests +Requires: fence-agents-common = %{version}-%{release} +BuildArch: noarch +Obsoletes: fence-agents < 3.1.13 +%description nutanix-ahv +Fence agent for Nutanix AHV clusters. +%files nutanix-ahv +%{_sbindir}/fence_nutanix_ahv +%{_mandir}/man8/fence_nutanix_ahv.8* + %ifarch x86_64 ppc64le %package openstack License: GPL-2.0-or-later AND LGPL-2.0-or-later @@ -1186,6 +1201,10 @@ are located on corosync cluster nodes. %endif %changelog +* Mon Apr 7 2025 Oyvind Albrigtsen - 4.16.0-8 +- fence_nutanix_ahv: new fence agent + Resolves: RHEL-68322 + * Tue Mar 25 2025 Oyvind Albrigtsen - 4.16.0-7 - fence_sbd: get devices from SBD_DEVICE env variable if devices parameter isnt set