-
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): fix so that the commandHook
function is called only once during bundling.
#32776
fix(lambda): fix so that the commandHook
function is called only once during bundling.
#32776
Conversation
Fix so that the
commandHook` function is called only once during bundling.commandHook
function is called only once during bundling.
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.
commandHook
function is called only once during bundling.commandHook
function is called only once during bundling.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
@Mergifyio update |
✅ Branch has been successfully updated |
commandHook
function is called only once during bundling.commandHook
function is called only once during bundling.
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.
commandHook
function is called only once during bundling.commandHook
function is called only once during bundling.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
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.
Thanks 👍
A couple of comments:
- I'd classify the PR as a
fix(lambda)
instead of achore
(that will require an integration test update as well to verify the change) - Do we need to fix the behavior for Python runtimes as well?
commandHook
function is called only once during bundling.commandHook
function is called only once during bundling.
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 fails with the following errors:
❌ Fixes must contain a change to an integration test file and the resulting snapshot.
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.
✅ A exemption request has been requested. Please wait for a maintainer's review.
Thank you for the review! 👍
I fixed the PR title. Thanks. I have a question about integration testing. a. Deploy the Lambda stack and confirm that the In the case of a, I'm wondering how to test it. Can I use
I think this logic is unnecessary for the Python runtime because there is no distinction between Docker bundling and Local bundling. |
@ayame113 Thanks for the follow up 👍
Looking at the docs, following
I guess an update/re-run to this Node test and this GO test should be enough. |
Thanks for the clarification! 👍 Please let me know if there are any other changes that should be added.
|
@ayame113
Can we use an |
Understood. Thanks for pointing that out!
I think it's difficult. The test I can think of is the following. @@ -15,11 +15,30 @@ class TestStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
+ let afterBundlingCallCount = 0;
+ let beforeBundlingCallCount = 0;
+
this.lambdaFunction = new lambda.GoFunction(this, 'go-handler-docker', {
entry: path.join(__dirname, 'lambda-handler-vendor', 'cmd', 'api'),
bundling: {
forcedDockerBundling: true,
goBuildFlags: ['-mod=readonly', '-ldflags "-s -w"'],
+ commandHooks: {
+ afterBundling() {
+ if (1 < afterBundlingCallCount) {
+ throw new Error('afterBundling should called only once');
+ }
+ afterBundlingCallCount++;
+ return [];
+ },
+ beforeBundling() {
+ if (1 < beforeBundlingCallCount) {
+ throw new Error('afterBundling should called only once');
+ }
+ beforeBundlingCallCount++;
+ return [];
+ },
+ },
},
});
} |
@ayame113 Thanks a lot for looking into this! |
@lpizzinidev |
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.
👍
Hi! Can I get a review from the maintainer for this PR? @pahud |
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. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #32776 +/- ##
==========================================
- Coverage 81.52% 81.39% -0.14%
==========================================
Files 222 225 +3
Lines 13715 13714 -1
Branches 2417 2411 -6
==========================================
- Hits 11181 11162 -19
- Misses 2254 2277 +23
+ Partials 280 275 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I have already addressed this change request. Exemption Request Is there anything else I should change? Or can I get it reviewed by the maintainers? |
@Mergifyio update |
❌ Mergify doesn't have permission to updateFor security reasons, Mergify can't update this pull request. Try updating locally. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Closing this PR in regards to the discussion #31973. Feel free to draft up a new PR. Thank you! |
Comments on closed issues and PRs are hard for our team to see. |
This is my first contribution to aws-cdk! So please let me know if I'm doing something wrong.
Issue # (if applicable)
Closes #31973.
Reason for this change
When using local bundling, the
commandHook
function was being called twice.This PR fixes it so that it is only called once.
Description of changes
When the variable
shouldBuildImage
is true, acreateBundlingCommand
for the Docker build will be created as before.When the variable
shouldBuildImage
is false, acreateBundlingCommand
for the local build will be created whenbundler.local.tryBundle()
is called. (Previously, both acreateBundlingCommand
for the Docker build and for the local build were created.)After making this change, some tests failed because they were expecting the
createBundlingCommand
to be called immediately, so I addedforcedDockerBundling: true
to some of the tests.Note: I was going to send a patch to aws-cdk-lib, but I found a similar code in aws-lambda-go-alpha, so I fixed it at the same time. Is that okay?
Description of how you validated changes
I've added a unit test.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license