aws / aws/aws-cdk

(core): Docker stdout is not printed on error during bundling

Open
#20,892 5 comments 1 reaction 0 assignees View on GitHub
@aws-cdk/assets bug effort/small good first issue p2 package/tools
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

In quite a few different scenarios, Docker errors simply happen and "Docker returned 1" gets spat out.

I suspect Docker is writing to stderr but it is getting squashed somewhere.

### Expected Behavior

Docker outputs (both stdout and stderr are preserved)

### Current Behavior

Docker's error status isn't printed

### Reproduction Steps

* Run `cdk synth` on a stack that requires docker, but without permissions to talk to Docker's control plane
* watch as it crashes and burns:

```
39907defbe84: Pull complete
8f7631647f07: Pull complete
d83e11d24ec9: Pull complete
b09b92bf5cf8: Pull complete
[WARNING]
software.amazon.jsii.JsiiException: docker exited with status 1
Error: docker exited with status 1
at dockerExec (/tmp/jsii-kernel-ENBrAx/node_modules/@aws-cdk/core/lib/bundling.js:355:15)
at Function.fromBuild (/tmp/jsii-kernel-ENBrAx/node_modules/@aws-cdk/core/lib/bundling.js:243:9)
at new Bundling (/tmp/jsii-kernel-ENBrAx/node_modules/@aws-cdk/aws-lambda-python/lib/bundling.js:28:86)
at Function.bundle (/tmp/jsii-kernel-ENBrAx/node_modules/@aws-cdk/aws-lambda-python/lib/bundling.js:43:50)
at new PythonFunction (/tmp/jsii-kernel-ENBrAx/node_modules/@aws-cdk/aws-lambda-python/lib/function.js:43:39)
```

The error that is being quashed here was `Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/create?fromImage=public.ecr.aws%2Fsam%2Fbuild-python3.7&tag=latest": dial unix /var/run/docker.sock: connect: permission denied`

Contributor guide

Open the contributing guide

Research direction

Start at the dockerExec entry point in @aws-cdk/core/lib/bundling.js, identified in the reproduction stack trace, and reproduce the failure with cdk synth when Docker access is denied. Done means the bundling error preserves and prints Docker's stdout and stderr, including the daemon permission message instead of only reporting status 1.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, typescript
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.