cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #00811
[Merge] lp:~smoser/cloud-init/trunk.improve-wait into lp:cloud-init
Scott Moser has proposed merging lp:~smoser/cloud-init/trunk.improve-wait into lp:cloud-init.
Commit message:
improve how cloud-init-wait waits
since we run from a udev event, this is sufficient.
udev settle will exit when either of
a.) the file exists
b.) the udev event queue has all been processed.
Since cloud-init-wait is being run as a udev event, 'b' cannot
be satisfied until it finishes. Thus, this essentially becomes a
inotify based wait for the file /run/cloud-init/network-config-ready
and no loops are needed.
Requested reviews:
Martin Pitt (pitti)
cloud init development team (cloud-init-dev)
For more details, see:
https://code.launchpad.net/~smoser/cloud-init/trunk.improve-wait/+merge/290243
--
Your team cloud init development team is requested to review the proposed merge of lp:~smoser/cloud-init/trunk.improve-wait into lp:cloud-init.
=== modified file 'udev/cloud-init-wait'
--- udev/cloud-init-wait 2016-03-21 02:31:21 +0000
+++ udev/cloud-init-wait 2016-03-28 18:55:53 +0000
@@ -3,16 +3,13 @@
CI_NET_READY="/run/cloud-init/network-config-ready"
LOG="/run/cloud-init/${0##*/}.log"
LOG_INIT=0
+MAX_WAIT=60
DEBUG=0
block_until_ready() {
- local fname="$1"
- local naplen="$2" max="$3" n=0
- while ! [ -f "$fname" ]; do
- n=$(($n+1))
- [ "$n" -ge "$max" ] && return 1
- sleep $naplen
- done
+ local fname="$1" max="$2"
+ [ -f "$fname" ] && return 0
+ udevadm settle "--timeout=$max" "--exit-if-exists=$fname"
}
log() {
@@ -56,7 +53,7 @@
return 0
fi
- block_until_ready "$readyfile" .1 600 ||
+ block_until_ready "$readyfile" "$MAX_WAIT" ||
{ log "failed waiting for ready on $INTERFACE"; return 1; }
log "net config ready"
References