File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments