From 4ba8a7a9975534c873c00e5d362be796c40338b7 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 12 Apr 2016 10:28:01 -0400 Subject: [PATCH] Dedupe concurrent ipmi health requests IPMI health requests are relatively expensive. It's also pretty popular and therefore prone to be the target of inadvertantly aggressive concurrent requests. Mitigate the harm by detecting concurrent usage and having callers share an answer. --- .../confluent/plugins/hardwaremanagement/ipmi.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index 536af948..9142fdc8 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -92,6 +92,8 @@ class IpmiCommandWrapper(ipmicommand.Command): def __init__(self, node, cfm, **kwargs): self.cfm = cfm self.node = node + self._inhealth = False + self._lasthealth = None self._attribwatcher = cfm.watch_attributes( (node,), ('secret.hardwaremanagementuser', 'secret.hardwaremanagementpassword', 'secret.ipmikg', @@ -113,6 +115,16 @@ class IpmiCommandWrapper(ipmicommand.Command): # then do nothing pass + def get_health(self): + if self._inhealth: + while self._inhealth: + eventlet.sleep(0.1) + return self._lasthealth + self._inhealth = True + self._lasthealth = super(IpmiCommandWrapper, self).get_health() + self._inhealth = False + return self._lasthealth + def _ipmi_evtloop(): while True: @@ -845,7 +857,7 @@ class IpmiHandler(object): return def _str_health(health): - if health == 'unknown': + if isinstance(health, str): return health if pygconstants.Health.Failed & health: health = 'failed'