aws-cloudformation / cloudformation-cli-python-plugin

The CloudFormation Provider Development Toolkit Python Plugin allows you to autogenerate Python code based on an input schema.
Apache License 2.0
108 stars 47 forks source link

Docker errors are hidden #211

Closed ericzbeard closed 12 months ago

ericzbeard commented 1 year ago

In codegen.py, auto_remove is set to True when running the pip install command. This results in the process exiting before stderr can be read, so for example you see something like this:

docker.errors.ContainerError: Command 'pip install --no-cache-dir --no-color --disable-pip-version-check --upgrade --requirement /project/requirements.txt --target /project/build' in image 'public.ecr.aws/lambda/python:3.7' returned non-zero exit status 1

If you change it to auto_remove=False, you get a useful error message:

docker.errors.ContainerError: Command 'pip install --no-cache-dir --no-color --disable-pip-version-check --upgrade --requirement /project/requirements.txt --target /project/build' in image 'public.ecr.aws/lambda/python:3.7' returned non-zero exit status 1: b"ERROR: Could not install packages due to an OSError: [Errno 28] No space left on device: '/tmp/pip-unpack-zw24lvnb'\n\n"

(The fix for this particular error is to run docker image prune)

mmaeng commented 1 year ago

214 should resolve

Repro

import docker
client = docker.from_env()
client.containers.run('alpine:2.7', 'echo hello world')
b'hello world\n'

client.containers.run('alpine:2.7', 'echo hello world', auto_remove=True)
<Trace removed>
HTTPError: 404

client.containers.run('alpine:2.7', 'echo hello world', remove=True)
b'hello world\n'
kddejong commented 1 year ago

Some details related to the docker-py package: https://github.com/docker/docker-py/issues/2684 https://github.com/docker/docker-py/issues/2503