From 46d12ae7d396a1e74df6a47376a4bdada5d42e10 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Tue, 11 Aug 2020 07:57:40 -0700 Subject: [PATCH] Handle NetworkManager for dhcp-all-interfaces NetworkManager takes a distinctly differnet network management approach and the bulk of the dhcp-all-interfaces code is largely targetted at distribution specific configuration. Some which may or may not override settings, or only partially assert desirable settings. As such, we need to set appropriate configuration, such as the correct client to be used, and timeouts based upon user supplied settings. By default this change sets the client to be dhclient on redhat styled machines, as the packaging default, while it works for ramdisk usage, it does not reset the interface between retries, which can be critical if the infrastucture operator is attempting to configure LACP trunks to the end node. Change-Id: I0e0cfbdbf7ef2b2861b934ccd7dab9d83a35c8f0 Story: 2008001 Task: 40648 --- .../install.d/50-dhcp-all-interfaces | 19 +++++++++++++-- .../NetworkManager-conf.d-00-main.conf | 24 +++++++++++++++++++ ...faces-networkmanager-b34f2fc8fb1a678f.yaml | 10 ++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 diskimage_builder/elements/dhcp-all-interfaces/install.d/NetworkManager-conf.d-00-main.conf create mode 100644 releasenotes/notes/dhcp-all-interfaces-networkmanager-b34f2fc8fb1a678f.yaml diff --git a/diskimage_builder/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces b/diskimage_builder/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces index 0f140f02..9b722311 100755 --- a/diskimage_builder/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces +++ b/diskimage_builder/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces @@ -8,14 +8,29 @@ set -o pipefail SCRIPTDIR=$(dirname $0) -# TODO(hjensas): Once ndisc6 package is available in EPEL8 drop this, and add the package back in pkg-map. -# See: https://bugzilla.redhat.com/show_bug.cgi?id=1779134 if [ -e "/etc/redhat-release" ]; then + # TODO(hjensas): Once ndisc6 package is available in EPEL8 drop this, + # and add the package back in pkg-map. + # See: https://bugzilla.redhat.com/show_bug.cgi?id=1779134 if type dnf &>/dev/null; then dnf -v -y install ndisc6 || true else yum -v -y install ndisc6 || true fi + # NOTE(TheJulia): While the internal client which every networkmanager user + # should have is internal, dhclient has better behavior which includes + # shutting down the port between retries which is critical for recovery + # from LACP port blocking situations. As such, we'll force it to dhclient. + # For more information, see https://storyboard.openstack.org/#!/story/2008001 + DIB_DHCP_CLIENT=${DIB_DHCP_CLIENT:-dhclient} +fi + + +# Sets appropriate NetworkManager configuration, if the folder is present. +if [ -x "/etc/NetworkManager" ]; then + install -D -g root -o root -m 0644 ${SCRIPTDIR}/NetworkManager-conf.d-00-main.conf /etc/NetworkManager/conf.d/00-main.conf + sed -i "s/DIB_DHCP_CLIENT/${DIB_DHCP_CLIENT:-internal}/g" /etc/NetworkManager/conf.d/00-main.conf + sed -i "s/DIB_DHCP_TIMEOUT/${DIB_DHCP_TIMEOUT:-30}/g" /etc/NetworkManager/conf.d/00-main.conf fi diff --git a/diskimage_builder/elements/dhcp-all-interfaces/install.d/NetworkManager-conf.d-00-main.conf b/diskimage_builder/elements/dhcp-all-interfaces/install.d/NetworkManager-conf.d-00-main.conf new file mode 100644 index 00000000..2074d0af --- /dev/null +++ b/diskimage_builder/elements/dhcp-all-interfaces/install.d/NetworkManager-conf.d-00-main.conf @@ -0,0 +1,24 @@ +# WARNING: This file has been modified by the diskimage-builder +# dhcp-all-interfaces element as this machine is likely running +# a ramdisk or needs to attempt auto-configuration on all interfaces. +[main] +# This makes sense even with dhcp on all interfaces in the event +# that the configuration has been or is being supplied via external means. +ignore-carrier=* +# Use dhclient as was done previously to the Centos8/RHEL8 RPM defaults. +# This is because dhclient shuts the interface down after a retry attempt +# which allows the link state to reset with some switches, which may be +# important for the ramdisk to recover networking. +dhcp=DIB_DHCP_CLIENT + +[connection] +# Keep retrying, this is important for this important espescialy for +# ramdisks in environments where varying switch configurations may +# cause traffic to be blocked or intermittent connectivity failures +# such as those at an edge site may cause issues. +autoconnect-retries=-1 +# Set the timeout. Diskimage-builder dhcp-all-interfaces has a 30 +# second default. NetworkManager, by default, is 45 seconds. +# In some cases where ramdisks are in use, 60 seconds is advisable. +ipv4.dhcp-timeout=DIB_DHCP_TIMEOUT +ipv6.dhcp-timeout=DIB_DHCP_TIMEOUT diff --git a/releasenotes/notes/dhcp-all-interfaces-networkmanager-b34f2fc8fb1a678f.yaml b/releasenotes/notes/dhcp-all-interfaces-networkmanager-b34f2fc8fb1a678f.yaml new file mode 100644 index 00000000..28a3214c --- /dev/null +++ b/releasenotes/notes/dhcp-all-interfaces-networkmanager-b34f2fc8fb1a678f.yaml @@ -0,0 +1,10 @@ +--- +fixes: + - | + Fixes support for the ``dhcp-all-interfaces`` element when the system + networking configuration is managed via ``NetworkManager``. + - | + Fixes ``NetworkManager`` configuration with the ``dhcp-all-interfaces`` + element to account for Centos8/RHEL8's default change to the + ``NetworkManager`` internal DHCP client, which can introduce different + behavior for infrastucture operators such as those using LACP.