-
Notifications
You must be signed in to change notification settings - Fork 410
Add parameter to power-tune only cold starts #206
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
Merged
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
efd6ad0
Another implementation of onlyColdStarts
mriccia 89a255b
Working implementation
mriccia 711e37d
Addressing PR feedback
mriccia 4720586
add permission required for `functionActiveV2`
mriccia f70677d
add comments and tidy up
mriccia 0445f32
tidy up
mriccia 4d8f554
Fix tests and add more tests
mriccia f6d7ad1
Modify the Terraform template to match the changes in the SAM template
mriccia 32f9533
preserve env vars when optimising
mriccia c0dd5ff
remove redundant logic
mriccia dd14172
Merge branch 'master' into onlycoldstarts
alexcasalboni c0192ec
Merge remote-tracking branch 'origin/master' into onlycoldstarts
mriccia 5a2e515
reintroduce changes that were removed in the merge
mriccia 93802fd
PR feedback
mriccia aa85838
PR feedback
mriccia 1656b7e
PR feedback
mriccia 79bb3b8
fix tests
mriccia 3c4b5d6
fix cleaner.js
mriccia 69edf22
remove singleton for client to avoid breaking existing use cases
mriccia 6b9c85d
change logic to use Description instead of Env Vars
mriccia 331de58
PR Feedback
mriccia aad097c
PR Feedback
mriccia 2a547a6
Fix unit tests and linting
mriccia 4b58451
remove unnecessary permission
mriccia 9a9b243
remove unnecessary permission
mriccia 1979fb6
fix node version in the Terraform template
mriccia 446fff2
remove error catch from initializer state
alexcasalboni e8b7d17
Uupdate analyzer and executor to include init stats and new state mac…
alexcasalboni 71aa0cb
update tests and coverage
alexcasalboni 40c221b
linting
alexcasalboni 6f001da
Improve publisher coverage & linting
alexcasalboni 940ecd8
Update documentation for onlyColdStarts
alexcasalboni 000cd74
PR feedback
mriccia 797f89c
Remove getAlias permission from the Initializer
mriccia 355ea6f
PR Feedback
mriccia 18a8a65
Modify logic for computing duration and cost
mriccia aba4d63
Remove tests for deleted code
mriccia 103786c
Add few TODOs as reminders
mriccia 38f5c96
Add tests for extractDuration
mriccia d837b53
Add more tests
mriccia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict'; | ||
|
||
const utils = require('./utils'); | ||
|
||
|
||
module.exports.handler = async(event, context) => { | ||
const {lambdaConfigurations, currConfig, lambdaARN} = validateInputs(event); | ||
const currentIterator = lambdaConfigurations.iterator; | ||
// publish version & assign alias (if present) | ||
await utils.createPowerConfiguration(lambdaARN, currConfig.powerValue, currConfig.alias, currConfig.description); | ||
|
||
const result = { | ||
powerValues: lambdaConfigurations.powerValues, | ||
initConfigurations: lambdaConfigurations.initConfigurations, | ||
iterator: { | ||
index: (currentIterator.index + 1), | ||
count: currentIterator.count, | ||
continue: ((currentIterator.index + 1) < currentIterator.count), | ||
}, | ||
}; | ||
|
||
if (!result.iterator.continue) { | ||
// clean the list of configuration if we're done iterating | ||
delete result.initConfigurations; | ||
} | ||
|
||
return result; | ||
}; | ||
function validateInputs(event) { | ||
if (!event.lambdaARN) { | ||
throw new Error('Missing or empty lambdaARN'); | ||
} | ||
const lambdaARN = event.lambdaARN; | ||
if (!(event.lambdaConfigurations && event.lambdaConfigurations.iterator && event.lambdaConfigurations.initConfigurations)){ | ||
throw new Error('Invalid iterator for initialization'); | ||
} | ||
const iterator = event.lambdaConfigurations.iterator; | ||
if (!(iterator.index >= 0 && iterator.index < iterator.count)){ | ||
throw new Error(`Invalid iterator index: ${iterator.index}`); | ||
} | ||
const lambdaConfigurations = event.lambdaConfigurations; | ||
const currIdx = iterator.index; | ||
const currConfig = lambdaConfigurations.initConfigurations[currIdx]; | ||
if (!(currConfig && currConfig.powerValue)){ | ||
throw new Error(`Invalid init configuration: ${JSON.stringify(currConfig)}`); | ||
} | ||
return {lambdaConfigurations, currConfig, lambdaARN}; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Looking at what the Initializer is doing (very similarly), I would consider merging utils.getLambdaPower and utils.getLambdaConfig since they are both using
GetFunctionConfigurationCommand
and they're simply retrieving different fields from the result.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.
Not blocking for this PR - just a reminder for myself in the future :)