From 04effaa9032b052343e3cf82a65054f0d35834ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= <radoslaw.piliszek@gmail.com>
Date: Sun, 26 Apr 2020 21:51:20 +0200
Subject: [PATCH] Fix haproxy restarting twice per Ansible run

Since haproxy is orchestrated via site.yml in a single play,
it does not need flushing handlers as handlers run will
happen at the end of this play.

Change-Id: Ia3743575da707325be93c39b4a2bcae9211cacb2
Related-Bug: #1864810
Closes-Bug: #1875228
---
 ansible/roles/haproxy/tasks/deploy.yml               | 6 ++++--
 ansible/roles/haproxy/tasks/upgrade.yml              | 6 ++++--
 releasenotes/notes/bug-1864810-5a5d0f91c0171b19.yaml | 7 +++++++
 3 files changed, 15 insertions(+), 4 deletions(-)
 create mode 100644 releasenotes/notes/bug-1864810-5a5d0f91c0171b19.yaml

diff --git a/ansible/roles/haproxy/tasks/deploy.yml b/ansible/roles/haproxy/tasks/deploy.yml
index 476832489..e2768de7e 100644
--- a/ansible/roles/haproxy/tasks/deploy.yml
+++ b/ansible/roles/haproxy/tasks/deploy.yml
@@ -3,5 +3,7 @@
 
 - include_tasks: config.yml
 
-- name: Flush handlers
-  meta: flush_handlers
+# NOTE(yoctozepto): haproxy role handlers should not be flushed early.
+# site.yml handles all haproxy things in a dedicated play.
+# This is to avoid extra haproxy service restart.
+# See: https://bugs.launchpad.net/kolla-ansible/+bug/1875228
diff --git a/ansible/roles/haproxy/tasks/upgrade.yml b/ansible/roles/haproxy/tasks/upgrade.yml
index ad22684c4..32a5d4d71 100644
--- a/ansible/roles/haproxy/tasks/upgrade.yml
+++ b/ansible/roles/haproxy/tasks/upgrade.yml
@@ -16,5 +16,7 @@
   notify:
     - Restart keepalived container
 
-- name: Flush handlers
-  meta: flush_handlers
+# NOTE(yoctozepto): haproxy role handlers should not be flushed early.
+# site.yml handles all haproxy things in a dedicated play.
+# This is to avoid extra haproxy service restart.
+# See: https://bugs.launchpad.net/kolla-ansible/+bug/1875228
diff --git a/releasenotes/notes/bug-1864810-5a5d0f91c0171b19.yaml b/releasenotes/notes/bug-1864810-5a5d0f91c0171b19.yaml
new file mode 100644
index 000000000..a21654fb1
--- /dev/null
+++ b/releasenotes/notes/bug-1864810-5a5d0f91c0171b19.yaml
@@ -0,0 +1,7 @@
+---
+fixes:
+  - |
+    Fixes haproxy role to avoid restarting haproxy service multiple times
+    in a single Ansible run.
+    `LP#1864810 <https://launchpad.net/bugs/1864810>`__
+    `LP#1875228 <https://launchpad.net/bugs/1875228>`__
-- 
GitLab