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

exclude tags and reservedConcurrency from version hash #8212

Conversation

thewizarodofoz
Copy link
Contributor

Closes: #7822

@codecov-commenter
Copy link

codecov-commenter commented Sep 10, 2020

Codecov Report

Merging #8212 into master will decrease coverage by 0.12%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
lib/plugins/aws/package/compile/functions/index.js 97.03% <100.00%> (-0.22%) ⬇️
...plugins/aws/package/compile/events/stream/index.js 98.00% <0.00%> (-0.60%) ⬇️
.../package/compile/events/websockets/lib/validate.js 97.22% <0.00%> (-0.51%) ⬇️
lib/configSchema.js 100.00% <0.00%> (ø)
lib/utils/getCommandSuggestion.js 100.00% <0.00%> (ø)
lib/plugins/aws/invokeLocal/index.js 69.66% <0.00%> (ø)
lib/plugins/aws/provider/awsProvider.js 93.11% <0.00%> (ø)
lib/plugins/interactiveCli/initializeService.js 100.00% <0.00%> (ø)
...ib/plugins/aws/package/compile/events/sns/index.js 100.00% <0.00%> (ø)
... and 5 more

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 3177e40...e29da47. Read the comment docs.

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.

Thank you @thewizarodofoz ! That looks very promising. Please see my remarks

Comment on lines 497 to 502
const functionWideProperties = ['ReservedConcurrentExecutions', 'Tags'];
const properties = _.omit(
_.get(functionResource, 'Properties', {}),
'Code',
...functionWideProperties
);
Copy link
Contributor

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'] ?

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 it would make it more clear as to why these fields are omitted

Copy link
Contributor

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', () => {
Copy link
Contributor

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

  1. Setup a fixture with fixture.setup, as e.g. it's done here:
    fixtures.setup('httpApi').then(({ servicePath }) =>
  2. Issue first runServerless and read all generated lambda version ids
  3. Modify reservedConcurrency and tags with help of updateConfig (returned by fixture.setup()) as it's done here:
    await updateConfig({
    provider: {
    tags: {
    foo: 'bar',
    baz: 'qux',
    },
    tracing: {
    apiGateway: true,
    },
    logs: {
    restApi: true,
    },
    },
    });
  4. Re-run runServerless, and confirm that version id didn't change

Copy link
Contributor Author

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.

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.

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
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 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

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.

@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

Comment on lines 2837 to 2838
it('should not create a new version object if only function-wide configuration changed', () => {
return fixtures.setup('function').then(({ servicePath, updateConfig }) =>
Copy link
Contributor

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?

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 was really hoping to do that! Yay!

@medikoo
Copy link
Contributor

medikoo commented Sep 21, 2020

@thewizarodofoz is this ready for re-review? If so, please re-request review in Reviewers box

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.

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', () => {
Copy link
Contributor

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

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.

Thank you @thewizarodofoz !

@medikoo medikoo merged commit 1fceb89 into serverless:master Sep 22, 2020
@azizur
Copy link

azizur commented Sep 27, 2020

This PR has not resolved the issue. I am still getting A version for this Lambda function exists ( XXX ). Modify the function to create a new version..

@medikoo
Copy link
Contributor

medikoo commented Sep 28, 2020

@azizur see: #7822 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants