Skip to content

Commit 6f850e1

Browse files
committed
fix: add dhcp-server-detector fallback using dhclient
fixes sonic_vs with older (202505) image Signed-off-by: Benjamin Ritter <benjamin.ritter@x-cellent.com>
1 parent 325cf00 commit 6f850e1

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

deploy_partition.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,23 @@
218218
ansible.builtin.shell: |
219219
systemctl restart isc-dhcp-server
220220
sleep 2
221-
dhcp-server-detector Vlan4000 --exit-on-first-offer --duration 10
221+
222+
# dhcp-server-detector is a pyroute2 >= 0.9.3 console script, and SONiC 202505 pins
223+
# pyroute2 0.7.12, so fall back to dhclient there. dhclient has no timeout flag and
224+
# ignores `timeout` from a config file -- it always waits ~60s -- hence timeout(1).
225+
# -sf /bin/true keeps it from configuring the SVI, and on success it forks a renewing
226+
# daemon with an empty pid file, so the leftover is killed by its exact command line.
227+
# `pkill -x -f` matches the whole cmdline, so it cannot match this script's own shell
228+
# the way a plain `pkill -f` would.
229+
if command -v dhcp-server-detector >/dev/null; then
230+
dhcp-server-detector Vlan4000 --exit-on-first-offer --duration 10
231+
else
232+
probe="dhclient -4 -1 -sf /bin/true -lf /run/dhcp-probe.leases -pf /run/dhcp-probe.pid Vlan4000"
233+
timeout 15 $probe
234+
rc=$?
235+
pkill -x -f "$probe" || true
236+
exit $rc
237+
fi
222238
args:
223239
executable: /bin/bash
224240
when: dhcp_subnets is defined

0 commit comments

Comments
 (0)