Comment 0 for bug 1007483

Jean-Baptiste Lallement (jibel) wrote :

When multiple containers (template ubuntu) are created simultaneously only the first container is successfully created, others fail with "failed to execute template 'ubuntu'"

This is a very common scenario in automated tests.

TEST CASE:
Run the following script with sudo
"""
#!/bin/sh
MAX=3
echo "Destroying existing containers"
for x in $(seq 1 $MAX); do
    sudo lxc-destroy -f -n test-lxc-$x &
done

sleep 10
sudo lxc-list

echo "Creating $MAX ubuntu containers"
for x in $(seq 1 $MAX); do
    echo -n "Creating $x ..."
    sudo lxc-create -t ubuntu -n test-lxc-$x &
    echo "done"
done

echo "Waiting 30s for test to finish"
sleep 30
sudo lxc-list
"""

ACTUAL RESULT
=================================
$ sudo sh ./lxc-create-concurrent
Destroying existing containers
'test-lxc-1' does not exist
'test-lxc-2' does not exist
'test-lxc-3' does not exist
RUNNING

FROZEN

STOPPED

Creating 3 ubuntu containers
Creating 1 ...done
Creating 2 ...done
Creating 3 ...done
Waiting 30s for test to finish

No config file specified, using the default config

No config file specified, using the default config

No config file specified, using the default config
debootstrap is /usr/sbin/debootstrap
debootstrap is /usr/sbin/debootstrap
Checking cache download in /var/cache/lxc/quantal/rootfs-amd64 ...
Copy /var/cache/lxc/quantal/rootfs-amd64 to /var/lib/lxc/test-lxc-1/rootfs ...
Copying rootfs to /var/lib/lxc/test-lxc-1/rootfs ...
failed to execute template 'ubuntu'
debootstrap is /usr/sbin/debootstrap
failed to execute template 'ubuntu'
aborted
aborted

##
# The default user is 'ubuntu' with password 'ubuntu'!
# Use the 'sudo' command to run tasks as root in the container.
##

'ubuntu' template installed
'test-lxc-1' created
RUNNING

FROZEN

STOPPED
  test-lxc-1
=================================

ProblemType: Bug
DistroRelease: Ubuntu 12.10
Package: lxc 0.8.0~rc1-4ubuntu10
ProcVersionSignature: Ubuntu 3.4.0-3.8-generic 3.4.0
Uname: Linux 3.4.0-3-generic x86_64
ApportVersion: 2.1.1-0ubuntu1
Architecture: amd64
Date: Fri Jun 1 17:32:06 2012
ProcEnviron:
 TERM=xterm
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: lxc
UpgradeStatus: Upgraded to quantal on 2012-01-31 (121 days ago)