-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(lambda-nodejs): docker build container attempts to use unsupported pnpm version for node runtime #25731
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
Hey, is there a reason you want to run node 12? |
@vinayak-kukreja Not overly, this fixes a bug/framework deficiency I noted as part of an upgrade/modernisation of a legacy stack. But as was pointed out to me on the original issue I opened:
As I see it, the 2 paths forward are either fully deprecate/drop all support for Node As things are currently, a stack that uses Node This is the only part that needs to be finished off for this to be ready to go I believe:
I'd need to look deeper into those existing tests again to be sure of the best way to write one that would have identified this issue ahead of time + ensured it never broke in the first place though. Would seemingly have to be an actual run of the build container though, not just a mock.. so not sure how viable/desirable that is in the current test suite. It would be good to get some guidance as to the best/most acceptable way to add some tests around this. |
Clarification Request |
Hey, thank you for clarifying. It makes sense to me. For unit tests, you can take a look at tests in this file. And, for integration tests, you can take a look at DeployCommand and create a synth only integ test since stack deployment with Node 12 would fail. Let me know if you have any questions. |
@vinayak-kukreja I guess my main question RE: tests was around the nuances of my musings here:
As well as this part:
@vinayak-kukreja Basically.. it feels like there is only sort of limited usefulness that I could get out of implementing unit tests with mocks/etc around this (eg. I could probably ensure that the version supplied is within the expected range for support I suppose, but it's still basically only testing the things I have already added in my code), whereas what feels like a 'proper' useful test would be to actually run the docker build itself, for each of the supported versions of Node, and then not see the failure anymore. The clarity I was seeking (before I put the effort into writing those tests) is whether running a full proper docker build container for each supported version of node as part of these tests would be too 'heavy' to be accepted/acceptable. Most of the existing tests within https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-lambda-nodejs/test/bundling.test.ts are just checking that the appropriate function was called with the appropriate parameters (eg. Ref, which never would have surfaced the original error since the container wasn't actually being run. For just checking that the params I define in the code get passed through appropriately for the given node version I could use a pattern like this one (Ref) But re-skimming through https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-lambda-nodejs/test/bundling.test.ts I don't see any examples where the docker build container is actually run, for us to then be able to see it error. For that part of it, is that where you were suggesting writing the integration tests with
If so, can you recommend any good examples of using Edit: Looking at the other unit tests here, it looks like the ones in It references the Which defines the image to use as: aws-cdk/packages/aws-cdk-lib/aws-lambda-nodejs/lib/Dockerfile Lines 1 to 4 in 830e6d3
So adding some tests in Then that means I could continue to just have the tests in The Edit 2: Looking a little deeper, I came across these old remnants of integration tests:
Which seem like they have been moved here since #24376: @vinayak-kukreja Looking at that, it seems I could use This integration test seems to give a pattern of testing multiple stack variations within the same integration test file, so maybe that would also be helpful for solving this: |
0fdc959
to
53c4b36
Compare
This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error. |
The pull request linter fails with the following errors:
PRs must pass status checks before we can provide a meaningful review. If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing |
sigh closed for lack of being able to add a couple of brief tests when the bulk of the work/fix is already done... what a waste. |
fixes #25710
In the process of upgrading from an old version of CDK
1.x
, to the latest CDK2.x
(2.80.0
), I had some oldNodejsFunction
code that was usingruntime: Runtime.NODEJS_12_X
When running the CDK build, it used the Docker build container, which tried to use a version of
pnpm
that doesn't support running on Node12.x
, producing the following error:This PR introduces the
PNPM_VERSION
ARG
into theDockerfile
used for bundling (following existing CDK patterns used to inject theESBUILD_VERSION
ARG
), which defines aswitch
/case
ofpnpm
versions that should work with the correspondingRuntime.NODEJS_*
versions.You can see far more details of the error + working the proposed solution in:
Previous PRs (potentially non-exhaustive) related to the
pnpm
version + runtime compatibility are:TODO
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license