Merge lp:~fginther/adt-cloud-worker/uci-nova-wait-for-active into lp:~canonical-ci-engineering/adt-cloud-worker/uci-nova

Proposed by Francis Ginther
Status: Merged
Approved by: Francis Ginther
Approved revision: 13
Merged at revision: 10
Proposed branch: lp:~fginther/adt-cloud-worker/uci-nova-wait-for-active
Merge into: lp:~canonical-ci-engineering/adt-cloud-worker/uci-nova
Prerequisite: lp:~cprov/adt-cloud-worker/uci-nova-refix
Diff against target: 16 lines (+5/-1)
1 file modified
uci-nova (+5/-1)
To merge this branch: bzr merge lp:~fginther/adt-cloud-worker/uci-nova-wait-for-active
Reviewer Review Type Date Requested Status
Celso Providelo (community) Approve
Review via email: mp+256877@code.launchpad.net

Commit message

Wait for nova instance to become ACTIVE before searching for ipaddr.

Description of the change

Wait for nova instance to become ACTIVE before searching for ipaddr.

This solves the problem of other 'network' text in the "nova show" output tripping up the awk command searching for ipaddr.

https://trello.com/c/WA8HuriB/68-proposed-migration-uci-nova-can-get-tripped-up-when-looking-for-the-ip-address

To post a comment you must log in.
13. By Francis Ginther

Add a comment on why the ACTIVE check was added.

Revision history for this message
Celso Providelo (cprov) wrote :

Thanks for fixing this subtle problem, Francis.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'uci-nova'
2--- uci-nova 2015-04-22 03:04:57 +0000
3+++ uci-nova 2015-04-22 03:04:57 +0000
4@@ -250,7 +250,11 @@
5 retry=60
6 while [ -z "$ipaddr" ]; do
7 OUT=$(nova show --minimal $SRVNAME)
8- ipaddr=$(echo "$OUT" | awk 'BEGIN {FS="|"} /network/ {n=split($3,i,/,\s*/); gsub(" ", "", i[n]); print i[n]}')
9+ # Check that the instance is in the 'ACTIVE' state before probing for
10+ # the IP address to avoid awk'ing the wrong field
11+ if $(echo "$OUT" | grep -q "ACTIVE"); then
12+ ipaddr=$(echo "$OUT" | awk 'BEGIN {FS="|"} /network/ {n=split($3,i,/,\s*/); gsub(" ", "", i[n]); print i[n]}')
13+ fi
14 retry=$(( retry - 1 ))
15 if [ $retry -le 0 ]; then
16 error "Failed to acquire an IP address. Aborting!"

Subscribers

People subscribed via source and target branches