Haproxy: add support for track in wait_until_status (#53677)

When haproxy is configured to track the status of a server using a
server in another backend it will not report all status as expected.
Using substring matching will solve this.

The CSV will output the server status in the following way:
MAINT: MAINT (via pxname/svname)
UP: UP
DOWN: DOWN

Haproxy doc on trach: https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#5.2-track
This commit is contained in:
Jonas Esbjørn Engell 2019-03-19 00:10:49 +01:00 committed by ansibot
parent 5ba7063f4f
commit f9b812a982

View file

@ -353,8 +353,9 @@ class HAProxy(object):
state = self.get_state_for(pxname, svname) state = self.get_state_for(pxname, svname)
# We can assume there will only be 1 element in state because both svname and pxname are always set when we get here # We can assume there will only be 1 element in state because both svname and pxname are always set when we get here
if state[0]['status'] == status: # When using track we get a status like this: MAINT (via pxname/svname) so we need to do substring matching
if not self._drain or (state[0]['scur'] == '0' and state == 'MAINT'): if status in state[0]['status']:
if not self._drain or (state[0]['scur'] == '0' and 'MAINT' in state):
return True return True
else: else:
time.sleep(self.wait_interval) time.sleep(self.wait_interval)