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
exclude tags and reservedConcurrency from version hash #8212
exclude tags and reservedConcurrency from version hash #8212
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8212 +/- ##
==========================================
- Coverage 88.16% 88.03% -0.13%
==========================================
Files 248 248
Lines 9430 9320 -110
==========================================
- Hits 8314 8205 -109
+ Misses 1116 1115 -1
Continue to review full report at Codecov.
|
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.
Thank you @thewizarodofoz ! That looks very promising. Please see my remarks
const functionWideProperties = ['ReservedConcurrentExecutions', 'Tags']; | ||
const properties = _.omit( | ||
_.get(functionResource, 'Properties', {}), | ||
'Code', | ||
...functionWideProperties | ||
); |
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.
What's the added value of creating functionWideProperties
variable.
Isn't it simpler to just do _.omit(..., ['Code', 'ReservedConcurrentExecutions', 'Tags']
?
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.
I thought it would make it more clear as to why these fields are omitted
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.
@thewizarodofoz that's a good point , but it'll probably be fine to solve it with simple inline code comment:
_.omit(..., [
'Code',
// Properties applied to function globally (not specific to version or alias)
'ReservedConcurrentExecutions', 'Tags'
])
@@ -2240,6 +2240,55 @@ describe('AwsCompileFunctions', () => { | |||
}); | |||
}); | |||
|
|||
it('should not create a new version object if only function-wide configuration changed', () => { |
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.
All new tests should be written with help of runServerless
util (see https://github.com/serverless/serverless/blob/master/test/README.md)
In this case I would rely on basic function
fixture as follows
- Setup a fixture with
fixture.setup
, as e.g. it's done here:fixtures.setup('httpApi').then(({ servicePath }) => - Issue first
runServerless
and read all generated lambda version ids - Modify
reservedConcurrency
andtags
with help ofupdateConfig
(returned byfixture.setup()
) as it's done here:serverless/test/integration/apiGateway.test.js
Lines 191 to 204 in d9b91e9
await updateConfig({ provider: { tags: { foo: 'bar', baz: 'qux', }, tracing: { apiGateway: true, }, logs: { restApi: true, }, }, }); - Re-run
runServerless
, and confirm that version id didn't change
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 @medikoo I refactored the test, but it seems to me the second call to runServerless
isn't reading the updated config. I debugged the test and I did see updateConfig
updating the serverless.yml
in the temp dir, but as you can see in this assertion (which fails), runServerless
isn't picking up those changes.
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.
runServerless
isn't picking up those changes.
Thanks for pointing. Indeed there was an issue in memoization setup, due to which, in same process second serverless
instance of same service was relying on previously resolved config. I've fixed that in #8231
Update with master and issue should be gone
_.get(functionResource, 'Properties', {}), | ||
'Code', | ||
// Properties applied to function globally (not specific to version or alias) | ||
// https://github.com/serverless/serverless/issues/7822 |
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.
I think we can remove the link to github issue.
If needed, it's easy to map given code lines to source PR and issue, by GitHub blame feature
…ide-properties-in-version-hash
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.
@thewizarodofoz that looks great! Thank you
I have just one final remark. Last week we've released v2 and dropped support for Node.js v6, which means we can freely now use async/await syntax, and ideally (for better maintenance) if all new code is introduced in that style.
Can you update the fixture so it's configured with async function and await
keywords?
Sorry for late notice
it('should not create a new version object if only function-wide configuration changed', () => { | ||
return fixtures.setup('function').then(({ servicePath, updateConfig }) => |
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.
Can we upgrade this to async/await syntax?
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.
I was really hoping to do that! Yay!
@thewizarodofoz is this ready for re-review? If so, please re-request review in Reviewers box |
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.
Thank you @thewizarodofoz, It's all great, aside of that we should not commit describe.only
.
Can you update it?
@@ -2831,4 +2832,38 @@ describe('AwsCompileFunctions #2', () => { | |||
}); | |||
}); | |||
}); | |||
|
|||
describe.only('function config', () => { |
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.
.only
I believe was committed in by accident
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.
Thank you @thewizarodofoz !
This PR has not resolved the issue. I am still getting |
@azizur see: #7822 (comment) |
Closes: #7822