** Description changed:

- When multiple containers (template ubuntu) are created simultaneously
- only the first container is successfully created, others fail with
- "failed to execute template 'ubuntu'"
+ ========== SRU justification ==============
+ 1. Impact: parallel creations of containers with the same template
+ will result in all but one failing.  They should instead run in
+ parallel without racing in their critical section.
+ 2. Development fix: don't add '-n' to the flock arguments, which causes
+ flock to fail instead of waiting.
+ 3. Stable fix: same as development fix.
+ 4 Test case:
+       for i in `seq 10 12`; do
+               screen -d -m sudo lxc-create -t ubuntu -n p$i
+       done
+       ret=0
+       while [ $ret -eq 0 ]; do
+             sleep 1
+              pidof bash > /dev/null 2>&1
+              ret=$?
+         done
+ 
+       while [ `pidof lxc-create > /dev/null 2>&1` ]; do
+               sleep 1
+       done
+       lxc-ls
+       # make sure p10, p11, and p12 exist
+ 5. Regression potential: none
+ ==============================
+ 
+ 
+ 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 &
+     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"
+     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 
+ $ 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 
... 
+ 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
+   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
+  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)

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to lxc in Ubuntu.
https://bugs.launchpad.net/bugs/1007483

Title:
  lxc fails to create containers concurrently

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1007483/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs

Reply via email to