Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[interfaces-config] Fix race condition between networking service and interface-config service #139

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions files/image_config/interfaces/interfaces-config.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
#!/bin/bash

function wait_networking_service_done() {
local -i _WDOG_CNT="1"
local -ir _WDOG_MAX="30"

local -r _TIMEOUT="1s"

while [[ "${_WDOG_CNT}" -le "${_WDOG_MAX}" ]]; do
networking_status="$(systemctl is-active networking 2>&1)"

if [[ "${networking_status}" == active ]]; then
return
fi

echo "interfaces-config: networking service is running, wait for it done"

let "_WDOG_CNT++"
sleep "${_TIMEOUT}"
done

echo "interfaces-config: networking service is still running after 30 seconds, killing it"
systemctl kill networking 2>&1
}

if [[ $(ifquery --running eth0) ]]; then
wait_networking_service_done
ifdown --force eth0
fi

Expand Down