Merge lp:~smoser/cloud-init/trunk.improve-wait into lp:~cloud-init-dev/cloud-init/trunk

Proposed by Scott Moser
Status: Merged
Merged at revision: 1190
Proposed branch: lp:~smoser/cloud-init/trunk.improve-wait
Merge into: lp:~cloud-init-dev/cloud-init/trunk
Diff against target: 33 lines (+5/-8)
1 file modified
udev/cloud-init-wait (+5/-8)
To merge this branch: bzr merge lp:~smoser/cloud-init/trunk.improve-wait
Reviewer Review Type Date Requested Status
Dimitri John Ledkov (community) Approve
Martin Pitt (community) Approve
cloud-init Commiters Pending
Review via email: mp+290243@code.launchpad.net

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.

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

This looks nice indeed, thanks!

review: Approve
Revision history for this message
Dimitri John Ledkov (xnox) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
3CI_NET_READY="/run/cloud-init/network-config-ready"3CI_NET_READY="/run/cloud-init/network-config-ready"
4LOG="/run/cloud-init/${0##*/}.log"4LOG="/run/cloud-init/${0##*/}.log"
5LOG_INIT=05LOG_INIT=0
6MAX_WAIT=60
6DEBUG=07DEBUG=0
78
8block_until_ready() {9block_until_ready() {
9 local fname="$1"10 local fname="$1" max="$2"
10 local naplen="$2" max="$3" n=011 [ -f "$fname" ] && return 0
11 while ! [ -f "$fname" ]; do12 udevadm settle "--timeout=$max" "--exit-if-exists=$fname"
12 n=$(($n+1))
13 [ "$n" -ge "$max" ] && return 1
14 sleep $naplen
15 done
16}13}
1714
18log() {15log() {
@@ -56,7 +53,7 @@
56 return 053 return 0
57 fi54 fi
5855
59 block_until_ready "$readyfile" .1 600 ||56 block_until_ready "$readyfile" "$MAX_WAIT" ||
60 { log "failed waiting for ready on $INTERFACE"; return 1; }57 { log "failed waiting for ready on $INTERFACE"; return 1; }
6158
62 log "net config ready"59 log "net config ready"