8a7340
From 9d951d55a1be44bbeb5df485d14d4f84ddf01142 Mon Sep 17 00:00:00 2001
18322d
From: Eduardo Otubo <otubo@redhat.com>
18322d
Date: Mon, 2 Mar 2020 10:46:35 +0100
8a7340
Subject: Remove race condition between cloud-init and NetworkManager
18322d
18322d
Message-id: <20200302104635.11648-1-otubo@redhat.com>
18322d
Patchwork-id: 94098
18322d
O-Subject: [RHEL-7.9/RHEL-8.2.0 cloud-init PATCH] Remove race condition between cloud-init and NetworkManager
18322d
Bugzilla: 1807797
18322d
RH-Acked-by: Cathy Avery <cavery@redhat.com>
18322d
RH-Acked-by: Mohammed Gamal <mgamal@redhat.com>
18322d
18322d
BZ: 1748015
18322d
BRANCH: rhel7/master-18.5
18322d
BREW: 26924611
18322d
18322d
BZ: 1807797
18322d
BRANCH: rhel820/master-18.5
18322d
BREW: 26924957
18322d
18322d
cloud-init service is set to start before NetworkManager service starts,
18322d
but this does not avoid a race condition between them. NetworkManager
18322d
starts before cloud-init can write `dns=none' to the file:
18322d
/etc/NetworkManager/conf.d/99-cloud-init.conf. This way NetworkManager
18322d
doesn't read the configuration and erases all resolv.conf values upon
18322d
shutdown. On the next reboot neither cloud-init or NetworkManager will
18322d
write anything to resolv.conf, leaving it blank.
18322d
18322d
This patch introduces a NM reload (try-restart) at the end of cloud-init
18322d
start up so it won't erase resolv.conf upon first shutdown.
18322d
18322d
x-downstream-only: yes
18322d
resolves: rhbz#1748015, rhbz#1807797 and rhbz#1804780
18322d
18322d
Signed-off-by: Eduardo Otubo otubo@redhat.com
18322d
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
18322d
---
18322d
 rhel/systemd/cloud-final.service | 2 ++
18322d
 1 file changed, 2 insertions(+)
18322d
18322d
diff --git a/rhel/systemd/cloud-final.service b/rhel/systemd/cloud-final.service
18322d
index 739b7e3..f303483 100644
18322d
--- a/rhel/systemd/cloud-final.service
18322d
+++ b/rhel/systemd/cloud-final.service
18322d
@@ -11,6 +11,8 @@ ExecStart=/usr/bin/cloud-init modules --mode=final
18322d
 RemainAfterExit=yes
18322d
 TimeoutSec=0
18322d
 KillMode=process
18322d
+ExecStartPost=/bin/echo "try restart NetworkManager.service"
18322d
+ExecStartPost=/usr/bin/systemctl try-restart NetworkManager.service
18322d
 
18322d
 # Output needs to appear in instance console output
18322d
 StandardOutput=journal+console
18322d
-- 
18322d
1.8.3.1
18322d