ansible / ansible-container

DEPRECATED -- Ansible Container was a tool to build Docker images and orchestrate containers using only Ansible playbooks.
GNU Lesser General Public License v3.0
2.19k stars 392 forks source link

Handle image not found #469

Open chouseknecht opened 7 years ago

chouseknecht commented 7 years ago
ISSUE TYPE
container.yml
version: "2"
settings:
  conductor_base: debian:stretch-slim
services:
  web:
    from: nginx
    roles:
      - trivial

registries: {}
SUMMARY

See the discussion at https://groups.google.com/forum/#!topic/ansible-container/ItpBPMVFKQY

When the from image for a service does not match the conductor base image, it fails to pull the from image.

Specifically, right after line 624 of container/core.py, we fail to handle the possibility that the image may be None.

chouseknecht commented 7 years ago

Here's the actual error reported by the user:

$ ansible-galaxy init -p roles trivial
$ ansible-container build

Building Docker Engine context...
Starting Docker build of Ansible Container Conductor image (please be patient)...
Parsing conductor CLI args.
Dockerâ„¢ daemon integration engine loaded. Build starting.   project=quickstart
Building service... project=quickstart service=web
Traceback (most recent call last):
  File "/usr/local/bin/conductor", line 11, in <module>
    load_entry_point('ansible-container', 'console_scripts', 'conductor')()
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/cli.py", line 349, in conductor_commandline
    **params)
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/core.py", line 682, in conductorcmd_build
    container_id = engine.run_container(cur_image_id, service_name, **run_kwargs)
  File "/_ansible/container/docker/engine.py", line 81, in __wrapped__
    return fn(self, *args, **kwargs)
  File "/_ansible/container/__init__.py", line 19, in __wrapped__
    return fn(*args, **kwargs)
  File "/_ansible/container/docker/engine.py", line 189, in run_container
    **run_kwargs
  File "/usr/local/lib/python2.7/dist-packages/docker/models/containers.py", line 666, in run
    container.start()
  File "/usr/local/lib/python2.7/dist-packages/docker/models/containers.py", line 312, in start
    return self.client.api.start(self.id, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/decorators.py", line 21, in wrapped
    return f(self, resource_id, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/docker/api/container.py", line 1068, in start
    self._raise_for_status(res)
  File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 216, in _raise_for_status
    raise create_api_error_from_http_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/docker/errors.py", line 30, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 500 Server Error: Internal Server Error ("linux spec user: unable to find user root: no matching entries in passwd file")
Conductor terminated. Cleaning up.  command_rc=1 conductor_id=87f520d6d93a7b5d82fcdc43066ee844dd03c3831421ad361e883f23f9525936 save_container=False
ERROR   Conductor exited with status 1
chouseknecht commented 7 years ago

It turns out, after reviewing this with @j00bar, that the intention is for AC to not pull images. So I think the work here is:

lorin commented 7 years ago

@chouseknecht What about for the base image of the conductor? Will Ansible Container automatically pull that, or is it the user's responsibility to pull the image first?

Voronenko commented 7 years ago

UPD:

Ok, for those interested, it most likely issue in ansible-container logic, but workaround is to docker pull service base image BEFORE ansible-container build command.

But would be cool to validate image existance in advance, and provide better user guidance.

============================================

I also experience the same issue.

Demo case:

I build alpine php-enabled user:

conductor_base: alpine:3.5
...
   php:
     from: alpine:3.5
     roles:
       - softasap.sa-php-container

builds and works like a charm, but when I try

conductor_base: debian:jessie
...
   php:
     from: php:5.6.30-fpm
     roles:
       - softasap.sa-php-container

I get the error:

docker.errors.APIError: 500 Server Error: Internal Server Error ("linux spec user: unable to find user root: no matching entries in passwd file")

Any ideas how to deal right ?

remyleone commented 7 years ago

I'm also affected by this.

cs2629207 commented 7 years ago

I had just received this error as well. Indeed @Voronenko if we pull the images before we run the build command then it gets past this error.

chouseknecht commented 7 years ago

@cs2629207

Thanks for your feedback on this issue.

I'm curious what version of Ansible Container you're running. I thought we addressed this issue in PR #645

To get that update you would need to be running from source.

Voronenko commented 7 years ago

@chouseknetch , if you believe it is fixed, make sure you closed issue here as well, once you release pypi version.

chouseknecht commented 7 years ago

@Voronenko

Agreed. Was hoping to get you or another commenter on this issue to test and confirm that we're pulling images as expected. We probably also need to update docs.