From e637152eeff1ade1e0e499a5910f2d49fd79b12d Mon Sep 17 00:00:00 2001 From: Jay Faulkner Date: Thu, 17 Apr 2014 11:15:29 -0700 Subject: [PATCH] Uniquely identify builds to prevent race In the original implementation of this, the latest running container containing "PICKME" was selected for the container to export. This creates a race condition. Instead we now identify the image by a UUID created each run, so that they will not overlap if multiple builds happen simultaneously. Change-Id: Iaaf5683435f424517774067a1d95732ad096c988 --- coreos/docker_build.bash | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/coreos/docker_build.bash b/coreos/docker_build.bash index 5bde97d..f3c7476 100755 --- a/coreos/docker_build.bash +++ b/coreos/docker_build.bash @@ -19,11 +19,14 @@ cd ../../ docker build -t oemdocker . cd - +# Create a UUID to identify the build +CONTAINER_UUID=`uuidgen` + # Export the oemdocker repository to a tarball so it can be embedded in CoreOS # TODO: Investigate running a container and using "export" to flatten the # image to shrink the CoreOS fs size. This will also require run.sh to # use docker import instead of docker load as well. -docker run oemdocker echo PICKME -CONTAINER=`docker ps -a |grep PICKME|awk '{print $1}'|head -n1` +docker run oemdocker echo $CONTAINER_UUID +CONTAINER=`docker ps -a --no-trunc |grep $CONTAINER_UUID|awk '{print $1}'|head -n1` echo $CONTAINER docker export $CONTAINER | gzip > ${OUTPUT_FILE}