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