From 6ec04d585ab5d82354f47355f0d314a7da76d88a Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 16 Apr 2025 16:15:18 -0400 Subject: [PATCH] Tolerate timeout on reseat A server reseating itself will unplug itself potentially before replying. Tolerate this and be optimistic and assume success. Change-Id: Ic021cb539b59d1f6cf287033a1146151ced95eda --- pyghmi/ipmi/oem/lenovo/imm.py | 7 +++++-- pyghmi/redfish/oem/lenovo/xcc.py | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index ac9b983d..5acf6261 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -960,8 +960,11 @@ class XCCClient(IMMClient): def reseat(self): wc = self.wc.dupe(timeout=5) - rsp = wc.grab_json_response_with_status( - '/api/providers/virt_reseat', '{}') + try: + rsp = wc.grab_json_response_with_status( + '/api/providers/virt_reseat', '{}') + except socket.timeout: + return # probably reseated itself and unable to reply if rsp[1] == 500 and rsp[0] == 'Target Unavailable': return if rsp[1] != 200 or rsp[0].get('return', 1) != 0: diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index 07aeafb5..73304c18 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -311,8 +311,12 @@ class OEMHandler(generic.OEMHandler): raise pygexc.UnsupportedFunctionality( 'This is not an enclosure manager') wc = self.wc.dupe(timeout=5) - rsp = wc.grab_json_response_with_status( - '/api/providers/virt_reseat', '{}') + try: + rsp = wc.grab_json_response_with_status( + '/api/providers/virt_reseat', '{}') + except socket.timeout: + # Can't be certain, but most likely a timeout' + return if rsp[1] == 500 and rsp[0] == 'Target Unavailable': return if rsp[1] != 200 or rsp[0].get('return', 1) != 0: