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

feat(AWS Deploy): Ensure consistent function state in deploy function #10288

Merged
merged 1 commit into from Nov 30, 2021

Conversation

pgrzesik
Copy link
Contributor

After doing a bit of more research I've noticed that at the moment, updateFunctionConfiguration is already resilient and does retries in situations where function is still being updated, so I've decided to stick to only ensuring that function is in updated state at the end of deploy function.

@codecov
Copy link

codecov bot commented Nov 29, 2021

Codecov Report

Merging #10288 (5a59236) into master (5b61b41) will increase coverage by 0.01%.
The diff coverage is 95.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10288      +/-   ##
==========================================
+ Coverage   85.39%   85.40%   +0.01%     
==========================================
  Files         339      339              
  Lines       13854    13877      +23     
==========================================
+ Hits        11830    11852      +22     
- Misses       2024     2025       +1     
Impacted Files Coverage Δ
lib/plugins/aws/deployFunction.js 96.86% <95.00%> (-0.19%) ⬇️
lib/plugins/aws/package/compile/events/stream.js 98.23% <0.00%> (+0.04%) ⬆️

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 5b61b41...5a59236. Read the comment docs.

@pgrzesik pgrzesik force-pushed the ensure-fn-state-in-deploy-function branch from 3373379 to 407cd6b Compare November 29, 2021 15:50
@@ -22,6 +22,8 @@ class AwsDeployFunction {
path.join(this.serverless.serviceDir || '.', '.serverless');
this.provider = this.serverless.getProvider('aws');

this._shouldEnsureFunctionState = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

This internal plugin is considered private in its own, so I think there's no need to additionally prefix internal properties with _

Also why do we need that property? If it's to differentiate between scenarios when there was no need for update, so no need to confirm on state, wouldn't it be better to update updateFunctionConfiguration so it returns true/false depending on whether update was made, and then follow up with state confirmation only when true is returned?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe we can simplify it this way 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I've just noticed my push didn't go through - we need to record it both for updateFunctionCode and updateFunctionConfiguration because configuration update can be skipped and function might be still in bad state after only code update - I've changed the variable a little bit

@@ -76,6 +78,9 @@ class AwsDeployFunction {
await this.deployFunction();
}
await this.updateFunctionConfiguration();
if (this._shouldEnsureFunctionState) {
await this.ensureFunctionState();
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought the issue on our side is that we need to confirm on function state after this.deployFunction() is done and before doing this.updateFunctionConfiguration() (as it may fail if it's not settled).

While all we do in this PR is simply prolonging command execution so it doesn't exit until the function state settles. If that's the case, then the only thing we're fixing is that following up with another command won't crash due to function being in interim state due to effect of previous command. Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought the same thing, but after finally being able to reproduce this issue, I've realized and noticed that in recent versions of the Framework, the retry for updateFunctionConfiguration is already handling that very well so there's no need to add any extra steps which will pretty much do the same thing.

While all we do in this PR is simply prolonging command execution so it doesn't exit until the function state settles. If that's the case, then the only thing we're fixing is that following up with another command won't crash due to function being in interim state due to effect of previous command. Is that correct?

Correct 👍

@pgrzesik pgrzesik force-pushed the ensure-fn-state-in-deploy-function branch from 407cd6b to 5a59236 Compare November 30, 2021 12:53
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 merged commit d52526b into master Nov 30, 2021
@pgrzesik pgrzesik deleted the ensure-fn-state-in-deploy-function branch November 30, 2021 14:34
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