sailesh1993 / rpms / cloud-init

Forked from rpms/cloud-init a year ago
Clone
fc6e82
From 24894dcf45a307f44e29dc5d5b2d864b75fd982c Mon Sep 17 00:00:00 2001
16d12a
From: Eduardo Otubo <otubo@redhat.com>
fc6e82
Date: Fri, 7 May 2021 13:36:14 +0200
16d12a
Subject: Remove race condition between cloud-init and NetworkManager
16d12a
16d12a
Message-id: <20200302104635.11648-1-otubo@redhat.com>
16d12a
Patchwork-id: 94098
16d12a
O-Subject: [RHEL-7.9/RHEL-8.2.0 cloud-init PATCH] Remove race condition between cloud-init and NetworkManager
16d12a
Bugzilla: 1807797
16d12a
RH-Acked-by: Cathy Avery <cavery@redhat.com>
16d12a
RH-Acked-by: Mohammed Gamal <mgamal@redhat.com>
16d12a
16d12a
BZ: 1748015
16d12a
BRANCH: rhel7/master-18.5
16d12a
BREW: 26924611
16d12a
16d12a
BZ: 1807797
16d12a
BRANCH: rhel820/master-18.5
16d12a
BREW: 26924957
16d12a
16d12a
cloud-init service is set to start before NetworkManager service starts,
16d12a
but this does not avoid a race condition between them. NetworkManager
16d12a
starts before cloud-init can write `dns=none' to the file:
16d12a
/etc/NetworkManager/conf.d/99-cloud-init.conf. This way NetworkManager
16d12a
doesn't read the configuration and erases all resolv.conf values upon
16d12a
shutdown. On the next reboot neither cloud-init or NetworkManager will
16d12a
write anything to resolv.conf, leaving it blank.
16d12a
16d12a
This patch introduces a NM reload (try-restart) at the end of cloud-init
16d12a
start up so it won't erase resolv.conf upon first shutdown.
16d12a
16d12a
x-downstream-only: yes
16d12a
resolves: rhbz#1748015, rhbz#1807797 and rhbz#1804780
16d12a
ea00c4
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
16d12a
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ea00c4
ea00c4
This commit is a squash and also includes the folloowing commits:
ea00c4
ea00c4
commit 316a17b7c02a87fa9b2981535be0b20d165adc46
ea00c4
Author: Eduardo Otubo <otubo@redhat.com>
ea00c4
Date:   Mon Jun 1 11:58:06 2020 +0200
ea00c4
ea00c4
    Make cloud-init.service execute after network is up
ea00c4
ea00c4
    RH-Author: Eduardo Otubo <otubo@redhat.com>
ea00c4
    Message-id: <20200526090804.2047-1-otubo@redhat.com>
ea00c4
    Patchwork-id: 96809
ea00c4
    O-Subject: [RHEL-8.2.1 cloud-init PATCH] Make cloud-init.service execute after network is up
ea00c4
    Bugzilla: 1803928
ea00c4
    RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
ea00c4
    RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
ea00c4
ea00c4
    cloud-init.service needs to wait until network is fully up before
ea00c4
    continuing executing and configuring its service.
ea00c4
ea00c4
    Signed-off-by: Eduardo Otubo <otubo@redhat.com>
ea00c4
ea00c4
    x-downstream-only: yes
ea00c4
    Resolves: rhbz#1831646
ea00c4
    Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ea00c4
ea00c4
commit 0422ba0e773d1a8257a3f2bf3db05f3bc7917eb7
ea00c4
Author: Eduardo Otubo <otubo@redhat.com>
ea00c4
Date:   Thu May 28 08:44:08 2020 +0200
ea00c4
ea00c4
    Remove race condition between cloud-init and NetworkManager
ea00c4
ea00c4
    RH-Author: Eduardo Otubo <otubo@redhat.com>
ea00c4
    Message-id: <20200327121911.17699-1-otubo@redhat.com>
ea00c4
    Patchwork-id: 94453
ea00c4
    O-Subject: [RHEL-7.9/RHEL-8.2.0 cloud-init PATCHv2] Remove race condition between cloud-init and NetworkManager
ea00c4
    Bugzilla: 1840648
ea00c4
    RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
ea00c4
    RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
ea00c4
    RH-Acked-by: Cathy Avery <cavery@redhat.com>
ea00c4
ea00c4
    cloud-init service is set to start before NetworkManager service starts,
ea00c4
    but this does not avoid a race condition between them. NetworkManager
ea00c4
    starts before cloud-init can write `dns=none' to the file:
ea00c4
    /etc/NetworkManager/conf.d/99-cloud-init.conf. This way NetworkManager
ea00c4
    doesn't read the configuration and erases all resolv.conf values upon
ea00c4
    shutdown. On the next reboot neither cloud-init or NetworkManager will
ea00c4
    write anything to resolv.conf, leaving it blank.
ea00c4
ea00c4
    This patch introduces a NM reload (try-reload-or-restart) at the end of cloud-init
ea00c4
    start up so it won't erase resolv.conf upon first shutdown.
ea00c4
ea00c4
    x-downstream-only: yes
ea00c4
ea00c4
    Signed-off-by: Eduardo Otubo otubo@redhat.com
ea00c4
    Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ea00c4
ea00c4
commit e0b48a936433faea7f56dbc29dda35acf7d375f7
ea00c4
Author: Eduardo Otubo <otubo@redhat.com>
ea00c4
Date:   Thu May 28 08:44:06 2020 +0200
ea00c4
ea00c4
    Enable ssh_deletekeys by default
ea00c4
ea00c4
    RH-Author: Eduardo Otubo <otubo@redhat.com>
ea00c4
    Message-id: <20200317091705.15715-1-otubo@redhat.com>
ea00c4
    Patchwork-id: 94365
ea00c4
    O-Subject: [RHEL-7.9/RHEL-8.2.0 cloud-init PATCH] Enable ssh_deletekeys by default
ea00c4
    Bugzilla: 1814152
ea00c4
    RH-Acked-by: Mohammed Gamal <mgamal@redhat.com>
ea00c4
    RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
ea00c4
ea00c4
    The configuration option ssh_deletekeys will trigger the generation
ea00c4
    of new ssh keys for every new instance deployed.
ea00c4
ea00c4
    x-downstream-only: yes
ea00c4
    resolves: rhbz#1814152
ea00c4
ea00c4
    Signed-off-by: Eduardo Otubo <otubo@redhat.com>
ea00c4
    Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
16d12a
---
fc6e82
 rhel/cloud.cfg                  | 2 +-
fc6e82
 rhel/systemd/cloud-init.service | 1 +
fc6e82
 2 files changed, 2 insertions(+), 1 deletion(-)
16d12a
ea00c4
diff --git a/rhel/cloud.cfg b/rhel/cloud.cfg
fc6e82
index 82e8bf62..9ecba215 100644
ea00c4
--- a/rhel/cloud.cfg
ea00c4
+++ b/rhel/cloud.cfg
ea00c4
@@ -6,7 +6,7 @@ ssh_pwauth:   0
ea00c4
 
ea00c4
 mount_default_fields: [~, ~, 'auto', 'defaults,nofail,x-systemd.requires=cloud-init.service', '0', '2']
ea00c4
 resize_rootfs_tmp: /dev
ea00c4
-ssh_deletekeys:   0
ea00c4
+ssh_deletekeys:   1
ea00c4
 ssh_genkeytypes:  ~
ea00c4
 syslog_fix_perms: ~
ea00c4
 disable_vmware_customization: false
ea00c4
diff --git a/rhel/systemd/cloud-init.service b/rhel/systemd/cloud-init.service
fc6e82
index d0023a05..0b3d796d 100644
ea00c4
--- a/rhel/systemd/cloud-init.service
ea00c4
+++ b/rhel/systemd/cloud-init.service
ea00c4
@@ -5,6 +5,7 @@ Wants=sshd-keygen.service
ea00c4
 Wants=sshd.service
ea00c4
 After=cloud-init-local.service
ea00c4
 After=NetworkManager.service network.service
ea00c4
+After=NetworkManager-wait-online.service
ea00c4
 Before=network-online.target
ea00c4
 Before=sshd-keygen.service
ea00c4
 Before=sshd.service
16d12a
-- 
fc6e82
2.27.0
16d12a