From a52c7b659c6569c78aad4b92303f289009da476c Mon Sep 17 00:00:00 2001 From: Eduardo Otubo Date: Mon, 5 Oct 2020 13:51:50 +0200 Subject: Remove race condition between cloud-init and NetworkManager Message-id: <20200302104635.11648-1-otubo@redhat.com> Patchwork-id: 94098 O-Subject: [RHEL-7.9/RHEL-8.2.0 cloud-init PATCH] Remove race condition between cloud-init and NetworkManager Bugzilla: 1807797 RH-Acked-by: Cathy Avery RH-Acked-by: Mohammed Gamal BZ: 1748015 BRANCH: rhel7/master-18.5 BREW: 26924611 BZ: 1807797 BRANCH: rhel820/master-18.5 BREW: 26924957 cloud-init service is set to start before NetworkManager service starts, but this does not avoid a race condition between them. NetworkManager starts before cloud-init can write `dns=none' to the file: /etc/NetworkManager/conf.d/99-cloud-init.conf. This way NetworkManager doesn't read the configuration and erases all resolv.conf values upon shutdown. On the next reboot neither cloud-init or NetworkManager will write anything to resolv.conf, leaving it blank. This patch introduces a NM reload (try-restart) at the end of cloud-init start up so it won't erase resolv.conf upon first shutdown. x-downstream-only: yes resolves: rhbz#1748015, rhbz#1807797 and rhbz#1804780 Signed-off-by: Eduardo Otubo Signed-off-by: Miroslav Rezanina This commit is a squash and also includes the folloowing commits: commit 316a17b7c02a87fa9b2981535be0b20d165adc46 Author: Eduardo Otubo Date: Mon Jun 1 11:58:06 2020 +0200 Make cloud-init.service execute after network is up RH-Author: Eduardo Otubo Message-id: <20200526090804.2047-1-otubo@redhat.com> Patchwork-id: 96809 O-Subject: [RHEL-8.2.1 cloud-init PATCH] Make cloud-init.service execute after network is up Bugzilla: 1803928 RH-Acked-by: Vitaly Kuznetsov RH-Acked-by: Miroslav Rezanina cloud-init.service needs to wait until network is fully up before continuing executing and configuring its service. Signed-off-by: Eduardo Otubo x-downstream-only: yes Resolves: rhbz#1831646 Signed-off-by: Miroslav Rezanina commit 0422ba0e773d1a8257a3f2bf3db05f3bc7917eb7 Author: Eduardo Otubo Date: Thu May 28 08:44:08 2020 +0200 Remove race condition between cloud-init and NetworkManager RH-Author: Eduardo Otubo Message-id: <20200327121911.17699-1-otubo@redhat.com> Patchwork-id: 94453 O-Subject: [RHEL-7.9/RHEL-8.2.0 cloud-init PATCHv2] Remove race condition between cloud-init and NetworkManager Bugzilla: 1840648 RH-Acked-by: Vitaly Kuznetsov RH-Acked-by: Miroslav Rezanina RH-Acked-by: Cathy Avery cloud-init service is set to start before NetworkManager service starts, but this does not avoid a race condition between them. NetworkManager starts before cloud-init can write `dns=none' to the file: /etc/NetworkManager/conf.d/99-cloud-init.conf. This way NetworkManager doesn't read the configuration and erases all resolv.conf values upon shutdown. On the next reboot neither cloud-init or NetworkManager will write anything to resolv.conf, leaving it blank. This patch introduces a NM reload (try-reload-or-restart) at the end of cloud-init start up so it won't erase resolv.conf upon first shutdown. x-downstream-only: yes Signed-off-by: Eduardo Otubo otubo@redhat.com Signed-off-by: Miroslav Rezanina commit e0b48a936433faea7f56dbc29dda35acf7d375f7 Author: Eduardo Otubo Date: Thu May 28 08:44:06 2020 +0200 Enable ssh_deletekeys by default RH-Author: Eduardo Otubo Message-id: <20200317091705.15715-1-otubo@redhat.com> Patchwork-id: 94365 O-Subject: [RHEL-7.9/RHEL-8.2.0 cloud-init PATCH] Enable ssh_deletekeys by default Bugzilla: 1814152 RH-Acked-by: Mohammed Gamal RH-Acked-by: Vitaly Kuznetsov The configuration option ssh_deletekeys will trigger the generation of new ssh keys for every new instance deployed. x-downstream-only: yes resolves: rhbz#1814152 Signed-off-by: Eduardo Otubo Signed-off-by: Miroslav Rezanina --- rhel/cloud.cfg | 2 +- rhel/systemd/cloud-final.service | 2 ++ rhel/systemd/cloud-init.service | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/rhel/cloud.cfg b/rhel/cloud.cfg index 82e8bf6..9ecba21 100644 --- a/rhel/cloud.cfg +++ b/rhel/cloud.cfg @@ -6,7 +6,7 @@ ssh_pwauth: 0 mount_default_fields: [~, ~, 'auto', 'defaults,nofail,x-systemd.requires=cloud-init.service', '0', '2'] resize_rootfs_tmp: /dev -ssh_deletekeys: 0 +ssh_deletekeys: 1 ssh_genkeytypes: ~ syslog_fix_perms: ~ disable_vmware_customization: false diff --git a/rhel/systemd/cloud-final.service b/rhel/systemd/cloud-final.service index 739b7e3..05add07 100644 --- a/rhel/systemd/cloud-final.service +++ b/rhel/systemd/cloud-final.service @@ -11,6 +11,8 @@ ExecStart=/usr/bin/cloud-init modules --mode=final RemainAfterExit=yes TimeoutSec=0 KillMode=process +ExecStartPost=/bin/echo "trying to reload or restart NetworkManager.service" +ExecStartPost=/usr/bin/systemctl try-reload-or-restart NetworkManager.service # Output needs to appear in instance console output StandardOutput=journal+console diff --git a/rhel/systemd/cloud-init.service b/rhel/systemd/cloud-init.service index d0023a0..0b3d796 100644 --- a/rhel/systemd/cloud-init.service +++ b/rhel/systemd/cloud-init.service @@ -5,6 +5,7 @@ Wants=sshd-keygen.service Wants=sshd.service After=cloud-init-local.service After=NetworkManager.service network.service +After=NetworkManager-wait-online.service Before=network-online.target Before=sshd-keygen.service Before=sshd.service -- 1.8.3.1