Skip to content
This repository was archived by the owner on Oct 10, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions migrate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,20 @@ container_export(){
echo $containerBaseImageID>>containerInfo.txt
echo $notruncContainerID>>containerInfo.txt
"$GOTAR" -cf container-metadata.tar $dockerRootDir/containers/$notruncContainerID 2> /dev/null
imageName=$(echo $RANDOM)
docker commit $containerID $imageName 1>/dev/null||exit 1
mkdir -p $tmpDir/temp
docker save $imageName > $tmpDir/temp/image.tar||exit 1
$(cd $tmpDir/temp; "$GOTAR" -xf image.tar)
diffLayerID=$(python -c 'import json; f=open("temp/repositories"); j=json.load(f); print(j[j.keys()[0]]["latest"])')
cd $tmpDir/temp/$diffLayerID
cp layer.tar $tmpDir/container-diff.tar
cd $tmpDir
/usr/bin/tar --delete -f container-diff.tar run/gotar 2>/dev/null || true
rm -rf temp
docker rmi -f $imageName 1>/dev/null||exit 1
if [[ ! -z $(docker diff $containerID) ]];then
imageName=$(echo $RANDOM)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you are only committing a container that has changed, Do we end up having containers that were created but not run in the imported version?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will have all the containers at $DEST that we had at the $SOURCE.
What do you mean by "Do we end up having containers that were created but not run in the imported version?".

Can you give an example?

Shishir

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker create --name foobar fedora /bin/sh
atomic storage export
atomic storage reset
atomic storage import
docker ps -a | grep foobar

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this works. I can see foobar container after atomic storage import.

Shishir

docker commit $containerID $imageName 1>/dev/null||exit 1
mkdir -p $tmpDir/temp
docker save $imageName > $tmpDir/temp/image.tar||exit 1
$(cd $tmpDir/temp; "$GOTAR" -xf image.tar)
diffLayerID=$(python -c 'import json; f=open("temp/repositories"); j=json.load(f); print(j[j.keys()[0]]["latest"])')
cd $tmpDir/temp/$diffLayerID
cp layer.tar $tmpDir/container-diff.tar
cd $tmpDir
/usr/bin/tar --delete -f container-diff.tar run/gotar 2>/dev/null || true
rm -rf temp
docker rmi -f $imageName 1>/dev/null||exit 1
fi
}

container_import(){
Expand Down Expand Up @@ -184,8 +186,12 @@ container_import(){
fi

cd $importPath/containers/migrate-$containerID
dockerBaseImageID=$(sed -n '2p' containerInfo.txt)||exit 1
cat container-diff.tar|docker run -i -v "$GOTAR:/run/gotar" $dockerBaseImageID /run/gotar -xf -
dockerBaseImageID=$(sed -n '2p' containerInfo.txt)||exit 1
if [[ -f container-diff.tar ]];then
cat container-diff.tar|docker run -i -v "$GOTAR:/run/gotar" $dockerBaseImageID /run/gotar -xf -
else
docker run -i $dockerBaseImageID echo "container_import"
fi
newContainerID=$(docker ps -lq)||exit 1
newContainerName=$(docker inspect -f '{{.Name}}' $newContainerID)||exit 1
newNotruncContainerID=$(docker ps -aq --no-trunc|grep $newContainerID)||exit 1
Expand Down
15 changes: 7 additions & 8 deletions tests/integration/test_migrate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
set -euo pipefail
IFS=$'\n\t'

#With the inclusion of this PR (https://github.com/projectatomic/atomic/pull/294)
#atomic storage export/import will only work with docker 1.10 support.
#Skip this test, until we move to docker 1.10.

echo "WARNING: skipping test_migrate.sh since it is only supported with docker 1.10 onwards."
exit 0

#
# 'atomic storage' integration tests (non-live)
# AUTHOR: Shishir Mahajan <shishir dot mahajan at redhat dot com>
Expand All @@ -25,7 +18,13 @@ if [ "$init" != "systemd" ];then
exit 0
fi

dockerPid=$(ps -C docker -o pid=|xargs)
if ! systemctl is-active docker >/dev/null; then
echo "Docker daemon is not running"
exit 1
fi

pid=$(systemctl show -p MainPID docker.service)
dockerPid=$(echo ${pid#*=})
dockerCmdline=$(cat /proc/$dockerPid/cmdline)
if [[ $dockerCmdline =~ "-g=" ]] || [[ $dockerCmdline =~ "-g/" ]] || [[ $dockerCmdline =~ "--graph" ]];then
echo "Docker is not located at the default (/var/lib/docker) root location. Skipping these tests."
Expand Down
4 changes: 0 additions & 4 deletions tests/test-images/Dockerfile.2

This file was deleted.