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