From df8208afe15df570f22305edaf547532e00764e0 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 12:34:51 +0100 Subject: [PATCH] [PR #8100/b2b8fc30 backport][stable-8] HAProxy skips the wait when drain=true and the backend is down - fix issue 8092 (#8157) 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 (cherry picked from commit b2b8fc30bf9bbccb8cab06a21833d2d7a179435b) Co-authored-by: RayJin2000 --- .../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):