Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker_image - "docker_image Detected no loaded images. Archive potentially corrupt?" when loading tar with ID only #86

Closed
n1kofr opened this issue Feb 17, 2021 · 6 comments · Fixed by #90
Labels
docker-plain plain Docker (no swarm, no compose, no stack)

Comments

@n1kofr
Copy link

n1kofr commented Feb 17, 2021

SUMMARY

Since Ansible 2.9.17, we cannot load docker image exported as a TAR and containing only ID.
It seems related to the change done by ansible/ansible#73067

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Module: docker_image

ANSIBLE VERSION
ansible 2.9.17
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/ops/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Aug 18 2020, 08:33:21) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
CONFIGURATION
ANSIBLE_PIPELINING(/opt/ops/ansible/ansible.cfg) = True
ANSIBLE_SSH_ARGS(/opt/ops/ansible/ansible.cfg) = -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=1200s>
ANSIBLE_SSH_RETRIES(/opt/ops/ansible/ansible.cfg) = 5
CACHE_PLUGIN(/opt/ops/ansible/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/opt/ops/ansible/ansible.cfg) = /home/ops/.facts_cache
CACHE_PLUGIN_TIMEOUT(/opt/ops/ansible/ansible.cfg) = 7200
DEFAULT_CALLBACK_WHITELIST(/opt/ops/ansible/ansible.cfg) = ['timer', 'yaml', 'profile_tasks']
DEFAULT_FORKS(/opt/ops/ansible/ansible.cfg) = 100
DEFAULT_GATHERING(/opt/ops/ansible/ansible.cfg) = smart
DEFAULT_LOG_PATH(/opt/ops/ansible/ansible.cfg) = /opt/ops/logs/bootstrap.log
DEFAULT_MODULE_PATH(/opt/ops/ansible/ansible.cfg) = ['/opt/ops/ansible/library']
DEFAULT_ROLES_PATH(/opt/ops/ansible/ansible.cfg) = ['/opt/ops/ansible/roles', '/opt/ops/ansible/roles']
DEFAULT_SCP_IF_SSH(/opt/ops/ansible/ansible.cfg) = True
DEFAULT_STDOUT_CALLBACK(/opt/ops/ansible/ansible.cfg) = yaml
DEFAULT_TIMEOUT(/opt/ops/ansible/ansible.cfg) = 60
DISPLAY_SKIPPED_HOSTS(/opt/ops/ansible/ansible.cfg) = False
HOST_KEY_CHECKING(/opt/ops/ansible/ansible.cfg) = False
INVENTORY_ENABLED(/opt/ops/ansible/ansible.cfg) = ['ini', 'k8s', 'host_list', 'advanced_host_list', 'auto', 'yaml']
RETRY_FILES_ENABLED(/opt/ops/ansible/ansible.cfg) = False
OS / ENVIRONMENT

Red Hat Enterprise Linux release 8.3 (Ootpa)

STEPS TO REPRODUCE

1 - export a docker image from docker using ID and compress as TAR GZIP

docker save <IMAGE_ID1> <IMAGE_ID2> | gzip > /tmp/docker_images.tar.gz

2 - import the TAR GZIP file using the ansible task

- name: "Load images"
  docker_image:
    name: "tmp"
    load_path: "/tmp/docker_images.tar.gz"
    source: "load"
    timeout: 600
EXPECTED RESULTS

We expect to have all images loaded into docker and the task succeed (as it was working with Ansible 2.9.16).

ACTUAL RESULTS

Images are loaded into docker but the task fails with the following error (as there is now a check of the output performed by the task):

TASK [kubernetes : Load images] ************************************************
fatal: [k8smaster002]: FAILED! => changed=false
  msg: Detected no loaded images. Archive potentially corrupt?
  stdout: |-
    Loaded image ID: sha256:a772c0a6b6970536854d8b25a79868f9fb900a2512c7e7722d8249355ee24995
    Loaded image ID: sha256:0006090afe17698c6d4c64ab9fb5d6a77912807db737aa965089fa112f537604
    Loaded image ID: sha256:202c83f32437a7270220d8db65e17085b2c759d32ed2ce835c4a766c2d791b13
    Loaded image ID: sha256:e27f1eb731dd03a6b30b77152aa8c87fcd11964451e2aeb400837d7cb589520c
    Loaded image ID: sha256:e9c95c1de8404480efb7d0f5d2f6fe692ecf781ddaafa6e487112fbb7288a19a
    Loaded image ID: sha256:b37570dce525e93531496eb18b07635db2cb0e0cd98562930cf0d977a2dbea21
    Loaded image ID: sha256:4abe5470b80167eae01ca007102b49e1e8eda90e431c3b4bced0b72249a81fe1
    Loaded image ID: sha256:016e6e6f604d625ae0a7bbffed6808e46ce437633ad7b77f392528033e6fc332
    Loaded image ID: sha256:6f4174115a27ecc0c7713b9ee06bb039641b231f9800402504155f1f23fcd955
    Loaded image ID: sha256:1d001206527c084cb857769c0b87b84c987b3c2ab71bc84e230216b2dc634009
    Loaded image ID: sha256:f630d629ed73564f8af7ab8b133352bd6561d0c3e544aef7b4f3e9aacd32fa88
    Loaded image ID: sha256:89e7a55fa2e83aa411e328fe0ff60ab36c2fdfe46aa0064197d0afcbba44e186
    Loaded image ID: sha256:2c67b10d0c17d4f2f240b06a46b76b21c0d9ee10c87a795b7c28f2273f978cce
    Loaded image ID: sha256:111b67af3a76d774f59824f42739d8cbb90b5e8897469f5c0aded91629bd0c2b
    Loaded image ID: sha256:26761ac77fe85e86b5a64a51a686f0ff8b04e717de3b91eebfdb6cba4ab3ca31
    Loaded image ID: sha256:455ebecc46b0904869b012a88c3f354a175cd0a6a560ea6974ce911487d89875
    Loaded image ID: sha256:2628440ab85ab609b36a17a98e733bcbe6d3f75223768a6ef9de3db4157152bf
    Loaded image ID: sha256:2ed114dfd08fe68e45dc8e729f67a0a06c1b5d9ad2a371d1a9f05c97db518704
    Loaded image ID: sha256:173872f9f0ff8e40e276f54eda5b6050931a80251413c423b3ac741becdd8676
    Loaded image ID: sha256:cbdd2d819df6566ff17cd3c78f01365c004dcf9dfe11861da4e962f97e1f7e3c
    Loaded image ID: sha256:5a23357a37a112d9b7375986154f472eca0a9a40d8610b5759b7113f71d77e41
    Loaded image ID: sha256:671242462c5788c5a31ca9d49d1c27ad70f83365174d4b4dc747148921cf4ad5
    Loaded image ID: sha256:37aa658148529e6181002cc8c0c45ead188878ad19ba9a0546a0c4e89f342d69
    Loaded image ID: sha256:f45a55d78d7879ca639834bd3817323559f8b9515a64852e17e1d85c80c948b1
    Loaded image ID: sha256:6812591c1f787e89e31017bdaa12795dc15bfc43c1c7b210fca37fcafdf5e034
    Loaded image ID: sha256:9a4cbad0d9d55d40127a89ae4ed3854199a6a0fb559c9ff1769ccb386d17ab19
    Loaded image ID: sha256:a36f0a3124309549a33af4783f728e3ec54b52ad30130436daaf861069a267f2
    Loaded image ID: sha256:78e71c07329025a038d0fea4d75717604ebdbf549d8ab7f5d83d1c1301548680
    Loaded image ID: sha256:84459a28087ea8bceae6148ac4b1e90f7f3c5170f662fae03675341967e4b991
    Loaded image ID: sha256:54fab954e15277003a6d438572bfe3b22d0d472311c0f40159a40758980f7c3d
    Loaded image ID: sha256:53370188d7b759642c0ef52e8e77303eb0871c97777437e1a0b2bddbaa260501
    Loaded image ID: sha256:e55a07f3f28ceec20c78c2536b17cdc4441df18e2225cb215e8fbf24cbc03916
  stdout_lines: <omitted>

From the source code, it seems the check is done on "Loaded image:" but when loading by ID, the output of the docker command returns: "Loaded image ID:"

@felixfontein
Copy link
Collaborator

There are two problems:

  1. docker_image does not support loading images by ID, only by name. That's something we can fix, by allowing name to be an image ID, and looking in the output for IDs and not only named images.
  2. it does not support loading multiple images. You need to load an archive containing one image, and specify the image's name in name:. Your archive contains multiple images, not a single image. The module cannot really enforce this, but read the description: https://docs.ansible.com/ansible/latest/collections/community/general/docker_image_module.html#parameter-load_path it says "an image", not "multiple images".

@n1kofr
Copy link
Author

n1kofr commented Feb 17, 2021

Thanks Felix for your feedback. we were using "docker_image" to load multiple image by ID since over a year. And i just realized about point number 2 thanks to your comment. I guess we got lucky to be able to load a file containing multiple image until now.

Does it mean we could ask for an improvement or new module to handle this case?

@felixfontein
Copy link
Collaborator

@n1kofr yes, until recently the module didn't check the output and simply assumed that the load worked. Which wasn't really good either ;-)

About supporting loading images by ID, that's something that can be added (I can work on that if nobody else does). About supporting loading multiple images, I think that should be part of another (i.e. new) module. The docker_image module is oriented towards handling one (specific) image, and its interface is already pretty cluttered.

I guess a new module could be called docker_image_load, and allow to load images from a file and return information on the images it contained (IDs, names, ...), errors found, etc.

@felixfontein
Copy link
Collaborator

(For now, command: docker load -i ... is probably the only good workaround.)

@n1kofr
Copy link
Author

n1kofr commented Feb 17, 2021

Thanks for the update and I will follow your advice in my current playbook for the load of multiple image. FYI, our goal to have multiple image in the same file is to ensure we save space and having all the common layers only once in the Tgz.

Looking forward to have a new module for that :)

@felixfontein
Copy link
Collaborator

@n1kofr I created a PR for adding a docker_image_load module: #90

@felixfontein felixfontein added the docker-plain plain Docker (no swarm, no compose, no stack) label Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker-plain plain Docker (no swarm, no compose, no stack)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants