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

fix(AWS Lambda): Ensure function update works when image used #8786

Merged
merged 2 commits into from
Jan 20, 2021

Conversation

pgrzesik
Copy link
Contributor

In relation to discussion started in #8778.

This PR adds:

  • Retrying for up to one minute when updateFunctionConfiguration fails due to another update in progress
  • Skipping updateFunctionCode call when image did not change
  • Skipping updateFunctionConfiguration when nothing changed/there's nothing to update
  • Tests refactoring

@pgrzesik pgrzesik force-pushed the ensure-that-deploy-function-works-properly-for-image branch from 9586c88 to 8f4e46b Compare January 19, 2021 15:51
@codecov
Copy link

codecov bot commented Jan 19, 2021

Codecov Report

Merging #8786 (665e6d0) into master (e4f368c) will increase coverage by 0.02%.
The diff coverage is 96.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8786      +/-   ##
==========================================
+ Coverage   87.74%   87.76%   +0.02%     
==========================================
  Files         264      264              
  Lines        9780     9822      +42     
==========================================
+ Hits         8581     8620      +39     
- Misses       1199     1202       +3     
Impacted Files Coverage Δ
lib/plugins/aws/deployFunction.js 94.51% <96.77%> (-1.36%) ⬇️
lib/Serverless.js 96.49% <0.00%> (-0.88%) ⬇️
lib/plugins/aws/deploy/lib/extendedValidate.js 100.00% <0.00%> (ø)
lib/plugins/aws/deploy/lib/uploadArtifacts.js 89.55% <0.00%> (+0.15%) ⬆️
lib/plugins/aws/deploy/index.js 98.18% <0.00%> (+1.81%) ⬆️
lib/plugins/aws/info/index.js 100.00% <0.00%> (+3.84%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e4f368c...665e6d0. Read the comment docs.

@pgrzesik pgrzesik self-assigned this Jan 19, 2021
@pgrzesik pgrzesik requested a review from medikoo January 19, 2021 16:52
Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pgrzesik looks great! I have just few minor suggestions

Comment on lines 124 to 128
if (didOneMinutePass) {
throw new ServerlessError(
'Retry timed out. Please try to deploy your function once again.'
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this belongs within below if condition (otherwise we risk hiding an error that anyway was supposed to be exposed)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call 👍

Comment on lines 166 to 167
'description' in functionObj &&
!_.isObject(functionObj.description) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it reflects the original logic, but as we're updating it, I would improve it:

  1. In case of string property more natural to check for existence with functionObj.description
  2. By schema this value can't be an object, so I would skip that check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great call, I believe I've applied it whenever it made sense and dropped checks for isObject in places where schema prevents it

Comment on lines 174 to 175
'handler' in functionObj &&
!_.isObject(functionObj.handler) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

expect(stdoutData).to.include('Successfully updated function');
});

it('should cast non-string env variables to strings during update', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's skip this test. String coercion is done at configuration validation step. This functionality in all cases receives property values coerced to defined types

@pgrzesik pgrzesik requested a review from medikoo January 20, 2021 12:25
Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍

@pgrzesik pgrzesik changed the title fix(AWS Lambda): Ensure that function update works when image used fix(AWS Lambda): Ensure function update works when image used Jan 20, 2021
@pgrzesik pgrzesik merged commit 420e937 into master Jan 20, 2021
@pgrzesik pgrzesik deleted the ensure-that-deploy-function-works-properly-for-image branch January 20, 2021 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants