3 # This script is called by arv-migrate-docker19 to perform the actual migration
4 # of a single image. This works by running Docker-in-Docker (dnd.sh) to
5 # download the image using Docker 1.9 and then upgrading to Docker 1.13 and
6 # uploading the converted image.
8 # When using bash in pid 1 and using "trap on EXIT"
9 # it will sometimes go into an 100% CPU infinite loop.
11 # Using workaround from here:
13 # https://github.com/docker/docker/issues/4854
21 # -o pipefail use exit code from 1st failure in pipeline, not last
31 # Print free space in /var/lib/docker
32 function freespace() {
33 df -B1 /var/lib/docker | tail -n1 | sed 's/ */ /g' | cut -d' ' -f4
36 # Run docker-in-docker script and then wait for it to come up
37 function start_docker {
38 /root/dnd.sh $graph_driver &
39 for i in $(seq 1 10) ; do
40 if docker version >/dev/null 2>/dev/null ; then
48 # Kill docker from pid then wait for it to be down
49 function kill_docker {
50 if test -f /var/run/docker.pid ; then
51 kill $(cat /var/run/docker.pid)
53 for i in $(seq 1 10) ; do
54 if ! docker version >/dev/null 2>/dev/null ; then
62 # Ensure that we clean up docker graph and/or lingering cache files on exit
65 rm -rf /var/lib/docker/*
66 rm -rf /root/.cache/arvados/docker/*
67 echo "Available space after cleanup is $(freespace)"
74 echo "Initial available space is $(freespace)"
76 arv-get $image_tar_keepref | docker load
78 docker tag $image_id $image_repo:$image_tag
84 echo "Available space after image load is $(freespace)"
87 dpkg -i libltdl7_2.4.2-1.11+b1_amd64.deb docker-engine_1.13.1-0~debian-jessie_amd64.deb
89 echo "Available space after image upgrade is $(freespace)"
95 UUID=$(arv-keepdocker --force-image-format --project-uuid=$project_uuid $image_repo $image_tag)
97 echo "Available space after arv-keepdocker is $(freespace)"
99 echo "Migrated uuid is $UUID"