From b2b8fc30bf9bbccb8cab06a21833d2d7a179435b Mon Sep 17 00:00:00 2001 From: RayJin2000 Date: Thu, 28 Mar 2024 07:35:46 +0100 Subject: [PATCH] HAProxy skips the wait when drain=true and the backend is down - fix issue 8092 (#8100) * fix issue 8092 * "is not" => "!=" * moved the drain & down cause to the wait * added changelogs for PR 8100 * fixed yaml * fixed file type * Apply suggestions from code review Removed a dot from a comment Co-authored-by: Felix Fontein * Update plugins/modules/haproxy.py Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein --- .../fragments/8100-haproxy-drain-fails-on-down-backend.yml | 2 ++ plugins/modules/haproxy.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/8100-haproxy-drain-fails-on-down-backend.yml diff --git a/changelogs/fragments/8100-haproxy-drain-fails-on-down-backend.yml b/changelogs/fragments/8100-haproxy-drain-fails-on-down-backend.yml new file mode 100644 index 0000000000..58f1478914 --- /dev/null +++ b/changelogs/fragments/8100-haproxy-drain-fails-on-down-backend.yml @@ -0,0 +1,2 @@ +bugfixes: + - "haproxy - fix an issue where HAProxy could get stuck in DRAIN mode when the backend was unreachable (https://github.com/ansible-collections/community.general/issues/8092)." diff --git a/plugins/modules/haproxy.py b/plugins/modules/haproxy.py index 05f52d55c8..cbaa438334 100644 --- a/plugins/modules/haproxy.py +++ b/plugins/modules/haproxy.py @@ -343,7 +343,7 @@ class HAProxy(object): if state is not None: self.execute(Template(cmd).substitute(pxname=backend, svname=svname)) - if self.wait: + if self.wait and not (wait_for_status == "DRAIN" and state == "DOWN"): self.wait_until_status(backend, svname, wait_for_status) def get_state_for(self, pxname, svname):