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
This commit is contained in:
Derek Higgins 2018-04-05 14:12:09 +01:00
parent 20be250b2a
commit 97399e9bb1
2 changed files with 12 additions and 2 deletions

View File

@ -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

View File

@ -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)