yellow team mailing list archive
-
yellow team
-
Mailing list archive
-
Message #00813
[Merge] lp:~frankban/lpsetup/use-lxcip-in-generated-scripts into lp:lpsetup
Francesco Banconi has proposed merging lp:~frankban/lpsetup/use-lxcip-in-generated-scripts into lp:lpsetup.
Requested reviews:
Launchpad Yellow Squad (yellow)
For more details, see:
https://code.launchpad.net/~frankban/lpsetup/use-lxcip-in-generated-scripts/+merge/104886
== Changes ==
Updated the generated script *lp-setup-lxc-build* to use *lp-lxc-ip*.
Before the script used DHCP leases to obtain the container's ip address, which appears to be fragile.
--
https://code.launchpad.net/~frankban/lpsetup/use-lxcip-in-generated-scripts/+merge/104886
Your team Launchpad Yellow Squad is requested to review the proposed merge of lp:~frankban/lpsetup/use-lxcip-in-generated-scripts into lp:lpsetup.
=== modified file 'lpsetup/settings.py'
--- lpsetup/settings.py 2012-05-03 10:24:21 +0000
+++ lpsetup/settings.py 2012-05-07 10:48:24 +0000
@@ -61,10 +61,6 @@
LXC_GUEST_CHOICES = ('lucid', 'oneiric', 'precise')
LXC_GUEST_OS = LXC_GUEST_CHOICES[0]
LXC_IP_COMMAND = ('/usr/bin/lp-lxc-ip', '-i', 'eth0', '-n')
-LXC_LEASES = (
- '/var/lib/dhcp3/dhclient.eth0.leases',
- '/var/lib/dhcp/dhclient.eth0.leases',
- )
LXC_LP_DIR_PATTERN = '/tmp/lxc-lp-*'
LXC_LP_TEST_DIR_PATTERN = '/var/lib/lxc/{lxc_name}-tmp-*'
LXC_NAME = 'lptests'
=== modified file 'lpsetup/subcommands/lxcinstall.py'
--- lpsetup/subcommands/lxcinstall.py 2012-05-02 16:32:06 +0000
+++ lpsetup/subcommands/lxcinstall.py 2012-05-07 10:48:24 +0000
@@ -36,7 +36,7 @@
LXC_GUEST_ARCH,
LXC_GUEST_CHOICES,
LXC_GUEST_OS,
- LXC_LEASES,
+ LXC_IP_COMMAND,
LXC_NAME,
LXC_OPTIONS,
LXC_PACKAGES,
@@ -57,13 +57,9 @@
def create_scripts(user, lxc_name, ssh_key_path):
"""Create scripts to update the Launchpad environment and run tests."""
- leases1, leases2 = [get_container_path(lxc_name, i) for i in LXC_LEASES]
context = {
- 'leases1': leases1,
- 'leases2': leases2,
+ 'lxcip': LXC_IP_COMMAND[0],
'lxc_name': lxc_name,
- 'pattern':
- r's/.* ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*/\1/',
'ssh_key_path': ssh_key_path,
'user': user,
}
=== modified file 'lpsetup/templates/lp-setup-lxc-build'
--- lpsetup/templates/lp-setup-lxc-build 2012-04-10 16:36:15 +0000
+++ lpsetup/templates/lp-setup-lxc-build 2012-05-07 10:48:24 +0000
@@ -8,24 +8,28 @@
# * This script is run as root.
set -ux
-truncate -c -s0 {leases1}
-truncate -c -s0 {leases2}
lxc-start -n {lxc_name} -d
lxc-wait -n {lxc_name} -s RUNNING
-delay=30
-while [ "$delay" -gt 0 -a ! -s {leases1} -a ! -s {leases2} ]
-do
- delay=$(( $delay - 1 ))
- sleep 1
+TRIES=60
+LXC_INTERFACE=''
+
+for i in $(seq 1 $TRIES); do
+ LXCIP_OUTPUT=`sudo {lxcip} -n {lxc_name} 2> /dev/null`
+ if [ $? = 0 ]; then
+ LXC_INTERFACE=`echo $LXCIP_OUTPUT | head -1 | cut -d ":" -f 1`
+ break
+ else
+ sleep 1
+ fi
done
-[ -s {leases1} ] && LEASES={leases1} || LEASES={leases2}
-IP_ADDRESS=`grep fixed-address $LEASES | tail -n 1 | sed -r '{pattern}'`
-
-if [ 0 -eq $? -a -n "$IP_ADDRESS" ]; then
- for i in $(seq 1 30); do
+if [ -n "$LXC_INTERFACE" ]; then
+ # Repeatedly try to connect over SSH until we either succeed
+ # or time out.
+ for i in $(seq 1 $TRIES); do
+ IP_ADDRESS=`sudo {lxcip} -n {lxc_name} -i $LXC_INTERFACE`
su {user} -c "/usr/bin/ssh -o StrictHostKeyChecking=no \
-i '{ssh_key_path}' $IP_ADDRESS make -C $PWD schema"
if [ ! 255 -eq $? ]; then
@@ -40,8 +44,6 @@
done
else
echo "could not get IP address - aborting." >&2
- echo "content of $LEASES:" >&2
- cat $LEASES >&2
fi
lxc-stop -n {lxc_name}