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-lambda-python] Automatic bundling failing for PythonFunction #13245

Closed
lsli8888 opened this issue Feb 24, 2021 · 8 comments
Closed

[aws-lambda-python] Automatic bundling failing for PythonFunction #13245

lsli8888 opened this issue Feb 24, 2021 · 8 comments
Assignees
Labels
@aws-cdk/aws-lambda-python guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@lsli8888
Copy link

lsli8888 commented Feb 24, 2021

The Question

PythonFunction won't bundle files when executing cdk synth.

I created a simple project to demonstrate this and have attached. It's basically a project created cdk init in python with an invocation of PythonFunction in the stack.py file.

test-aws-lambda-python-2.zip

The error I get when executing "cdk synth" is not very descriptive. Executing cdk synth with the "--verbose" and "--trace" options don't reveal much either. I can surmise something is going wrong with building the Docker image, but I can't determine the exact Docker build command used and it doesn't return a detailed stack trace as to why the Docker build failed.

$ cdk synth
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /tmp/jsii-kernel-oyassh: no such file or directory
jsii.errors.JavaScriptError: 
  Error: docker exited with status 1
      at dockerExec (/tmp/jsii-kernel-oyassh/node_modules/@aws-cdk/core/lib/bundling.js:164:15)
      at Function.fromAsset (/tmp/jsii-kernel-oyassh/node_modules/@aws-cdk/core/lib/bundling.js:50:9)
      at Object.bundle (/tmp/jsii-kernel-oyassh/node_modules/@aws-cdk/aws-lambda-python/lib/bundling.js:33:43)
      at new PythonFunction (/tmp/jsii-kernel-oyassh/node_modules/@aws-cdk/aws-lambda-python/lib/function.js:39:30)
      at /tmp/tmp3c4u0sd1/lib/program.js:2720:58
      at Kernel._wrapSandboxCode (/tmp/tmp3c4u0sd1/lib/program.js:3148:24)
      at Kernel._create (/tmp/tmp3c4u0sd1/lib/program.js:2720:34)
      at Kernel.create (/tmp/tmp3c4u0sd1/lib/program.js:2461:29)
      at KernelHost.processRequest (/tmp/tmp3c4u0sd1/lib/program.js:9457:36)
      at KernelHost.run (/tmp/tmp3c4u0sd1/lib/program.js:9420:22)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "app.py", line 9, in <module>
    TestAwsLambdaPython2Stack(app, "test-aws-lambda-python-2")
  File "/home/my_username/PycharmProjects/test-aws-lambda-python-2/.venv/lib/python3.6/site-packages/jsii/_runtime.py", line 83, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/home/my_username/PycharmProjects/test-aws-lambda-python-2/test_aws_lambda_python_2/test_aws_lambda_python_2_stack.py", line 14, in __init__
    handler="handler", runtime=aws_lambda.Runtime.PYTHON_3_6)
  File "/home/my_username/PycharmProjects/test-aws-lambda-python-2/.venv/lib/python3.6/site-packages/jsii/_runtime.py", line 83, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/home/my_username/PycharmProjects/test-aws-lambda-python-2/.venv/lib/python3.6/site-packages/aws_cdk/aws_lambda_python/__init__.py", line 243, in __init__
    jsii.create(PythonFunction, self, [scope, id, props])
  File "/home/my_username/PycharmProjects/test-aws-lambda-python-2/.venv/lib/python3.6/site-packages/jsii/_kernel/__init__.py", line 272, in create
    for iface in getattr(klass, "__jsii_ifaces__", [])
  File "/home/my_username/PycharmProjects/test-aws-lambda-python-2/.venv/lib/python3.6/site-packages/jsii/_kernel/providers/process.py", line 348, in create
    return self._process.send(request, CreateResponse)
  File "/home/my_username/PycharmProjects/test-aws-lambda-python-2/.venv/lib/python3.6/site-packages/jsii/_kernel/providers/process.py", line 330, in send
    raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: docker exited with status 1
Subprocess exited with error 1
`

Environment

  • CDK CLI Version: 1.91.0
  • Module Version: 1.91.0
  • Node.js Version: v12.15.0
  • OS: Ubuntu 18.04.5 LTS
  • Language (Version): Python 3.6.9
  • Docker: 19.03.13, build cd8016b6bc (note, this is installed from snap)

Other information

Related issue: possibly #9349

@lsli8888 lsli8888 added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Feb 24, 2021
@lsli8888
Copy link
Author

I solved the issue by removing and purging docker from my Snap Docker install and installed Docker from the repository using the instructions from the official Docker website: https://docs.docker.com/engine/install/ubuntu/

I'm not sure what the root cause is - there certainly is something different with the Docker version in Snap.

@eladb eladb removed their assignment Feb 25, 2021
@misterjoshua
Copy link
Contributor

I solved the issue by removing and purging docker from my Snap Docker install and installed Docker from the repository using the instructions from the official Docker website: https://docs.docker.com/engine/install/ubuntu/

I'm not sure what the root cause is - there certainly is something different with the Docker version in Snap.

I had this problem too. It boils down to the fact that Docker from Snap has a different /tmp than the CDK app, so the files staged by CDK in /tmp are not accessible.

@peterwoodworth
Copy link
Contributor

Docker from Snap has a different /tmp than the CDK app, so the files staged by CDK in /tmp are not accessible.

Hmm that's unfortunate, have you found this to be the case as well @lsli8888?

@peterwoodworth peterwoodworth added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Jun 23, 2021
@peterwoodworth
Copy link
Contributor

Ping me if you have additional concerns with this issue and i'll try to work through it, I'll be closing this issue now.

@github-actions
Copy link

github-actions bot commented Jul 7, 2021

⚠️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.

@lsli8888
Copy link
Author

lsli8888 commented Jul 9, 2021

@peterwoodworth Sorry for the late reply. Sorry, I'm not familiar or knowledgeable enough with Snap to know where it even has a temp directory. The error I saw didn't give have enough logs to help me diagnose the issue that @misterjoshua might have. But it would definitely be nice if this issue could be fixed though!

@peterwoodworth peterwoodworth reopened this Jul 9, 2021
@peterwoodworth
Copy link
Contributor

If anyone has more information about this or wants to see it fixed, feel free to open a bug report and reference this issue.

@github-actions
Copy link

⚠️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 guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

4 participants