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