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

(@aws-cdk/aws-lambda-python): (docker based bundling does not work on mounted docker socket) #21506

Closed
webratz opened this issue Aug 8, 2022 · 3 comments
Assignees
Labels
@aws-cdk/aws-lambda-python bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@webratz
Copy link
Contributor

webratz commented Aug 8, 2022

Describe the bug

In the case when CDK is running within a container, that has /var/run/docker.sock mounted in from the host system, bundling the python lambda will fail.
This is a bit of a unusual setup, but I've seen in very often in CI/CD systems, so I thinks its very relevant.

This is similar to #11230

Expected Behavior

The bundling and depdency management works as usual, if the docker daemon is running in the same machine.

Current Behavior

error output

Error: Bundling did not produce any output. Check that content is written to /asset-output.
    at AssetStaging.bundle (/builds/webratz/cdk-python-budle/node_modules/aws-cdk-lib/core/lib/asset-staging.js:2:841)
    at AssetStaging.stageByBundling (/builds/webratz/cdk-python-budle/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:4314)
    at stageThisAsset (/builds/webratz/cdk-python-budle/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:1675)
    at Cache.obtain (/builds/webratz/cdk-python-budle/node_modules/aws-cdk-lib/core/lib/private/cache.js:1:242)
    at new AssetStaging (/builds/webratz/cdk-python-budle/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:2070)
    at new Asset (/builds/webratz/cdk-python-budle/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:736)
    at AssetCode.bind (/builds/webratz/cdk-python-budle/node_modules/aws-cdk-lib/aws-lambda/lib/code.js:1:4628)
    at new Function (/builds/webratz/cdk-python-budle/node_modules/aws-cdk-lib/aws-lambda/lib/function.js:1:2803)
    at new PythonFunction (/builds/webratz/cdk-python-budle/node_modules/@aws-cdk/aws-lambda-python-alpha/lib/function.ts:73:5)
    at new MyStack (/builds/webratz/cdk-python-budle/src/main.ts:11:5)

Further output can be found at the job lob at https://gitlab.com/webratz/cdk-python-budle/-/jobs/2828110048

Reproduction Steps

I have created a repo at https://gitlab.com/webratz/cdk-python-budle/ that contains the code and all CI configuration.
The runner there will only be up for 1 week as its in a playground account that gets clean up weekly.
The README there and the .gitlab-ci.yml contains additional info on how things are executed.

Possible Solution

Using --volumes-from=$HOSTNAME docker parameter

I had a quick look through the CDK code, but I'm not sure how it would be possible to pass that in.

Additional Information/Context

This is not directly related to gitlab, i've seen this kind of setup already with several other setups, eg Jenkins.
If you need access to reproduce this I can grant access to the gitlab repo.

CDK CLI Version

2.35.0 (build 5c23578)

Framework Version

No response

Node.js Version 16

OS

Linux / Debian

Language

Typescript

Language Version

No response

Other information

related: #11230

@webratz webratz added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 8, 2022
@webratz
Copy link
Contributor Author

webratz commented Aug 9, 2022

I started to dig around a bit, and added the options in a WIP fork at main...webratz:aws-cdk:master
What is still unclear to me, how I would pass this option through from https://github.com/webratz/aws-cdk/blob/bbc58d70908824a0fcf3adfd98f3830063b7393d/packages/@aws-cdk/aws-lambda-python/lib/bundling.ts#L49

Maybe someone can have a look and give a suggestion, also if the approach in general is valid.
In case thats valid I could try to prepare a proper PR

@corymhall
Copy link
Contributor

@webratz it looks like this is the same issue that we are tracking in
#8799. I'm going to close this in favor of that one. Can you
add a thumbs up to that issue?

@github-actions
Copy link

github-actions bot commented Aug 9, 2022

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda-python bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants