This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 1284877 - return message and code are incorrect for atomic migrate import command
return message and code are incorrect for atomic migrate import command
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: atomic (Show other bugs)
7.3
x86_64 Linux
medium Severity medium
: rc
: ---
Assigned To: smahajan@redhat.com
atomic-bugs@redhat.com
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-11-24 06:30 EST by Alex Jia
Modified: 2016-06-29 22:45 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-06-03 15:57:31 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Alex Jia 2015-11-24 06:30:24 EST
Description of problem:
Although atomic migrate import command is succesful, the command return message and code are error.

Version-Release number of selected component (if applicable):
# rpm -q docker atomic
docker-1.9.0-9.el7.x86_64
atomic-1.7-2.git68be076.el7.x86_64

# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.1 (Maipo)

How reproducible:
always

Steps to Reproduce:
1. atomic migrate export 
2. atomic migrate import


Actual results:
# atomic images
 REPOSITORY                          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
 registry.access.redhat.com/openshift3/ose latest              2eb816e9a7d0        2015-11-12 05:29    395.32 MB 

# atomic migrate export
Exporting image with id: 2eb816e9a7d0

# ll /var/lib/atomic/migrate/images/
total 397288
-rw-r--r--. 1 root root 406822400 Nov 24 19:01 2eb816e9a7d0.tar

# docker rmi -f 2eb816e9a7d0
Untagged: registry.access.redhat.com/openshift3/ose:latest
Deleted: 2eb816e9a7d05f6d5816be42ba21cf272770a9be1d15e839e7474c0541a40bc7
Deleted: f38f7d43a5dadc570dca81bf39f24e257d71c384262038e5fac6e65acc4781fd
Deleted: 6883d5422f4ec2810e1312c0e3e5a902142e2a8185cd3a1124b459a7c38dc55b

# atomic images | grep 2eb816e9a7d0
# atomic migrate import
Importing image with id: 2eb816e9a7d0
<type 'exceptions.SystemExit'>
# echo $?
1
# atomic images | grep 2eb816e9a7d0
 registry.access.redhat.com/openshift3/ose latest              2eb816e9a7d0        2015-11-12 05:29    395.32 MB  

Expected results:
Fix it

Additional info:

In addition, if can't delete image id 2eb816e9a7d0 then directly run atomic migrate import, the command is successful w/o any error like 'image has existed'.
Comment 1 Alex Jia 2015-11-24 08:56:48 EST
In Atomic/Import.py, the function import_docker will try to execute import_images(), import_containers() and import_volumes() in turn whatever whether images, containers and volumes exist, it means users must successfully import images, containers and volumes together then can get atomic import completed successfully, moreover, the error "<type 'exceptions.SystemExit'>" is very hard to debug for users.

<slice>

def import_docker(graph, import_location):
    """
    This is a wrapper function for importing docker images, containers
    and volumes.
    """

    if not os.path.isdir(import_location):
        sys.exit("{0} does not exist".format(import_location))
    try:
        #import docker images
        import_images(import_location)
        #import docker containers
        import_containers(graph, import_location)
        #import docker volumes
        import_volumes(graph, import_location)
    except:
        error = sys.exc_info()[0]
        sys.exit(error)

    util.writeOut("atomic import completed successfully")

</slice>
Comment 3 smahajan@redhat.com 2016-01-15 14:27:34 EST
I tried this and this is working fine for me.

docker images: 1
docker containers: 0 
docker volumes: 0

sh-4.3# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
docker.io/fedora    latest              3fc68076e184        10 days ago         206.3 MB

sh-4.3# atomic migrate export
Exporting image: 3fc68076e184
Exporting volumes
atomic export completed successfully
sh-4.3# atomic migrate import
Importing image: 3fc68076e184
Importing volumes
atomic import completed successfully
Would you like to cleanup (rm -rf /var/lib/atomic/migrate) the temporary directory [y/N]
N
Please restart docker daemon for the changes to take effect.

Please try this on atomic master branch and this should work for you.
Comment 4 smahajan@redhat.com 2016-01-15 14:31:33 EST
Also, atomic migrate is intended for users who are trying to switch underlying docker storage (e.g. devicemapper to overlay) and not loose their existing docker content (images, containers, volumes).

We are expecting that the user would do:

1) atomic migrate export 
2) switch the underlying storage. THIS STEP IS MANUAL, and the user is expected to have knowledge of how to switch storage.
3) atomic migrate import.

You can do `man atomic-migrate` and read more on the intended usecase.
docker-storage-setup is needed to switch storage.

Shishir
Comment 5 Daniel Walsh 2016-01-15 15:12:17 EST
Yes we need to document this with a step by step guide.

Easy test environment would be

atomic migrate export
mount -t tmpfs none /var/lib/docker
systemctl restart docker
atomic migrate import

I think this would work.
Comment 6 Alex Jia 2016-01-19 03:49:43 EST
(In reply to Daniel Walsh from comment #5)
> Yes we need to document this with a step by step guide.
> 
> Easy test environment would be
> 
> atomic migrate export
> mount -t tmpfs none /var/lib/docker
> systemctl restart docker
> atomic migrate import
> 
> I think this would work.

Daniel, I gave a try on docker-1.9.1-11.el7.x86_64, it seems everything is okay, the previous existing images can work like before on new storage, but I got a error like this '/run/gotar: /run/gotar: cannot execute binary file <class 'subprocess.CalledProcessError'>',

# atomic migrate import
Importing image: fc0db02f3072
Importing image: c8a648134623
Importing image: fc918be8d896
Importing image: fd2acbeb2b97
Importing container: 65159e44cf48
Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Importing container: 04e682b4026f
Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Importing container: f24b303722df
Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
/run/gotar: /run/gotar: cannot execute binary file
<class 'subprocess.CalledProcessError'>
Comment 7 Daniel Walsh 2016-01-19 08:12:52 EST
Shishir, any ideas?
Comment 8 smahajan@redhat.com 2016-01-19 09:16:43 EST
I tried the steps mentioned by Dan, and it's working for me.

a) atomic migrate export
b) mount -t tmpfs none /var/lib/docker
c) systemctl restart docker
d) atomic migrate import

I am able to export and import successfully. If you can share the tar of your `atomic migrate export` with me, I can try to import that on my system and see if it fails.

If you have not changed the default location. you can tar up the directory `/var/lib/atomic`.

Shishir
Comment 9 Alex Jia 2016-01-20 05:56:42 EST
(In reply to smahajan@redhat.com from comment #8)

> I am able to export and import successfully. If you can share the tar of

In fact, I am able to export and import successfully too, only got a extra error message like this "/run/gotar: /run/gotar: cannot execute binary file
<class 'subprocess.CalledProcessError'>", I think it's not a big deal.

> your `atomic migrate export` with me, I can try to import that on my system
> and see if it fails.
> 

Well, I will send a email to you separately.
Comment 10 smahajan@redhat.com 2016-01-20 09:44:51 EST
Hi Alex,

Your import was not successful :) hence the error message.
I got your ssh details (e-mail). I ll take a look into this.

Shishir
Comment 11 Alex Jia 2016-01-20 09:53:13 EST
(In reply to smahajan@redhat.com from comment #10)
> Hi Alex,
> 
> Your import was not successful :) hence the error message.
> I got your ssh details (e-mail). I ll take a look into this.
> 
> Shishir

oh, I did this test based on different docker version, I forgot which version works well, okay, you may debug it on my rhel7 system further, I'm not sure if rhel7 system w/ atomic/docker installation is different from atomic host.
Comment 12 Daniel Walsh 2016-01-20 09:55:16 EST
Perhaps this only works with docker-1.9.1 version, RHEL has docker-1.8.2
Comment 13 smahajan@redhat.com 2016-02-09 15:51:32 EST
Alex,

Can we close this bugzilla now ?
Based on our e-mail discussion, I believe `atomic migrate` is working successfully.

Shishir
Comment 14 smahajan@redhat.com 2016-02-15 10:45:39 EST
Issue fixed with this PR: 
https://github.com/projectatomic/atomic/pull/295
Will be available in atomic 1.9.

Shishir
Comment 16 Alex Jia 2016-03-10 05:48:07 EST
The docker images can been successfully exported and imported on atomic-1.9-4.gitff44c6a.el7.x86_64 per Comment 8, but I got a new error "sed: can't read config.v2.json: No such file or directory", the details as follows.

# atomic migrate import 
Importing image: fc0db02f3072
Importing image: c8a648134623
Importing image: fc918be8d896
Importing image: fd2acbeb2b97
Importing image: b400a4e19136
Importing image: b175bcb79023
The image docker.io/busybox:latest already exists, renaming the old one with ID fc0db02f3072 to empty string
Importing image: 75b632339385
Importing image: 3e7ae7fa2964
Importing image: 3fc68076e184
Importing image: 747646c0f4e5
Importing image: 8b6b2421fd83
Importing container: 65159e44cf48
Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
sed: can't read config.v2.json: No such file or directory

# echo $?
2

# atomic images
REPOSITORY                                           TAG    IMAGE ID     CREATED             VIRTUAL SIZE
 centos_label                                        latest 8b6b2421fd83 2016-02-04 11:23    196.63 MB 
 httpd-atomic                                        latest 747646c0f4e5 2016-02-03 18:21    459.95 MB 
 atomic-test-secret                                  latest 75b632339385 2016-02-03 13:49    68.0 B    
 centos_stop_label                                   latest 3e7ae7fa2964 2016-02-01 11:41    196.63 MB 
 busybox_label                                       latest b400a4e19136 2016-01-21 11:40    1.11 MB   
 docker.io/busybox                                   latest b175bcb79023 2016-01-16 02:06    1.11 MB   
 docker.io/fedora                                    latest 3fc68076e184 2016-01-05 05:26    206.28 MB 
 docker.io/centos                                    latest c8a648134623 2015-12-24 23:30    196.63 MB 
 registry.access.redhat.com/rhel7/rhel-tools         latest fd2acbeb2b97 2015-12-04 18:44    1.16 GB   
 docker-registry.usersys.redhat.com/micah/fedora-uat latest fc918be8d896 2015-07-17 00:12    1.26 GB 


# git show 299fe3b9 | grep config.v2.json
+	sed -i "s|\"Driver\":\"$oldStorageDriver\"|\"Driver\":\"$newStorageDriver\"|g" config.v2.json	
+	sed -i "s|$oldDockerRootDir/containers/$oldNotruncContainerID|$dockerRootDir/containers/$oldNotruncContainerID|g" config.v2.json

NOTE: I haven't seen the file config.v2.json is created in migrate.sh
Comment 17 smahajan@redhat.com 2016-03-11 03:30:50 EST
This error seems like you are using docker 1.9 or lower.
Atomic migrate command is supported from docker 1.10 onwards.

We do read from config.v2.json in migrate.sh.
https://github.com/projectatomic/atomic/blob/master/migrate.sh#L206-L207

However this file is only created in docker 1.10 onwards. With lower versions of docker it used to be config.json.

Shishir
Comment 18 Daniel Walsh 2016-03-11 08:24:32 EST
Which means the version of atomic that is going out with docker-1.9 is too new.  

shishir, can you write a patch to disable migrate from atomic-1.9 so it does not show up until docker-1.10.
Comment 23 Daniel Walsh 2016-03-22 12:53:00 EDT
THis should be a release note.
Comment 25 smahajan@redhat.com 2016-06-29 13:37:32 EDT
Alex,

Can you please open a new bugzilla for this?
This bz has a different title, problem description which was solved earlier.

This seems to be a different problem.

Shishir
Comment 26 Alex Jia 2016-06-29 22:45:46 EDT
(In reply to smahajan@redhat.com from comment #25)
> Can you please open a new bugzilla for this?

Sure, here is new bug 1351397.

Note You need to log in before you can comment on or make changes to this bug.