fab351
From 46a8b8e9e7f150c2a17d4adeacb25ccf003ec425 Mon Sep 17 00:00:00 2001
fab351
From: Jonathan Lebon <jonathan@jlebon.com>
fab351
Date: Tue, 21 Jan 2020 17:57:31 -0500
fab351
Subject: [PATCH] network-legacy/ifup: nuke pid and lease files if dhclient
fab351
 failed
fab351
fab351
Otherwise we won't retry dhclient again on that interface. In
fab351
FCOS/RHCOS, we want to bake in `ip=dhcp,dhcp6` so we automatically try
fab351
getting a DHCPv6 lease if DHCPv4 failed.
fab351
fab351
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1793591
fab351
(cherry picked from commit d0de58f23252a9da4a8badd71777e7c8418fa4b7)
fab351
---
fab351
 modules.d/35network-legacy/ifup.sh | 3 +++
fab351
 1 file changed, 3 insertions(+)
fab351
fab351
diff --git a/modules.d/35network-legacy/ifup.sh b/modules.d/35network-legacy/ifup.sh
fab351
index 16b950be..dd18d70b 100755
fab351
--- a/modules.d/35network-legacy/ifup.sh
fab351
+++ b/modules.d/35network-legacy/ifup.sh
fab351
@@ -62,6 +62,9 @@ do_dhcp() {
fab351
         [ $_COUNT -lt $_DHCPRETRY ] && sleep 1
fab351
     done
fab351
     warn "dhcp for interface $netif failed"
fab351
+    # nuke those files since we failed; we might retry dhcp again if it's e.g.
fab351
+    # `ip=dhcp,dhcp6` and we check for the PID file at the top
fab351
+    rm -f /tmp/dhclient.$netif.{pid,lease}
fab351
     return 1
fab351
 }
fab351
 
fab351