From 97399e9bb1e0f0d3186f487009983bef8ed39679 Mon Sep 17 00:00:00 2001 From: Derek Higgins Date: Thu, 5 Apr 2018 14:12:09 +0100 Subject: [PATCH] Set the dhclient timeout to match DIB_DHCP_TIMEOUT On initial boot when networking is brought up by cloud-init this is the timeout that dhclient adheres to. Centos configures "timeout 300" (for an EC2 bug) in their cloud image, which results in a 5 minutes delay to boot in cases where no dhcp available (e.g. IPv6 SLAAC). To reduce this boot delay and to provide consistency with places where we have set other dhcp timeouts set this to DIB_DHCP_TIMEOUT. Change-Id: I119a002070501c3dfe7c6730b07ee25f422b85b0 Related-Bug: #1758324 --- .../elements/dhcp-all-interfaces/README.rst | 5 +++-- .../dhcp-all-interfaces/install.d/50-dhcp-all-interfaces | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/diskimage_builder/elements/dhcp-all-interfaces/README.rst b/diskimage_builder/elements/dhcp-all-interfaces/README.rst index eb56a378d..4c6c7353d 100644 --- a/diskimage_builder/elements/dhcp-all-interfaces/README.rst +++ b/diskimage_builder/elements/dhcp-all-interfaces/README.rst @@ -24,6 +24,7 @@ Environment Variables DIB_DHCP_TIMEOUT :Required: No :Default: 30 - :Description: Amount of time in seconds that the systemd service will - wait to get an address. Should be increased in networks such as Infiniband. + :Description: Amount of time in seconds that the systemd service(or dhclient) + will wait to get an address. Should be increased in networks such as + Infiniband. :Example: DIB_DHCP_TIMEOUT=300 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 25018929f..bbbd74e79 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 @@ -14,6 +14,15 @@ if [ "$DISTRO_NAME" != "gentoo" ]; then sed -i "s/DIB_DHCP_TIMEOUT/${DIB_DHCP_TIMEOUT:-30}/" /usr/local/sbin/dhcp-all-interfaces.sh fi +if [ -f /etc/dhcp/dhclient.conf ] ; then + # Set the dhclient timeout configurations to match DIB_DHCP_TIMEOUT, + if grep -o "^timeout " /etc/dhcp/dhclient.conf ; then + sed -i -e "s/^timeout .*/# \"timeout\" Value set by dhcp-all-interfaces\ntimeout ${DIB_DHCP_TIMEOUT:-30}/" /etc/dhcp/dhclient.conf + else + echo -e "# \"timeout\" Value set by dhcp-all-interfaces\ntimeout ${DIB_DHCP_TIMEOUT:-30}" >> /etc/dhcp/dhclient.conf + fi +fi + if [ "$DIB_INIT_SYSTEM" == "upstart" ]; then if [ -e "/etc/redhat-release" ] ; then # the init system is upstart but networking is using sysv compatibility (i.e. Centos/RHEL 6)