[bfn]: Fix sigterm processing (#12952)

Why I did it
SIGTERM takes more than 10 seconds to be processed, so psud is stopped by SIGKILL, this causes unexpected behavior since data base is not cleared

How I did it
Decorate get_presence api to cancel it on SIGTERM signal in order to avoid long processing.

How to verify it
test_pmon_psud_stop_and_start_status
test_pmon_psud_term_and_start_status
This commit is contained in:
Dmytro Lytvynenko 2022-12-07 09:38:23 +02:00 committed by GitHub
parent 1bf5a245cd
commit 0711aea3aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -135,12 +135,16 @@ class Psu(PsuBase):
:param self.index: An integer, 1-based self.index of the PSU of which to query status
:return: Boolean, True if PSU is plugged, False if not
"""
@cancel_on_sigterm
def psu_present_get(client):
return client.pltfm_mgr.pltfm_mgr_pwr_supply_present_get(self.__index)
status = False
try:
status = thrift_try(psu_present_get)
status = thrift_try(psu_present_get, attempts=1)
except Exception as e:
if "Canceling" in str(e):
syslog.syslog(syslog.LOG_INFO, "{}".format(e))
finally:
return status