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

Onlycoldstarts #2

Closed
wants to merge 10 commits into from
Closed

Onlycoldstarts #2

wants to merge 10 commits into from

Conversation

mriccia
Copy link
Owner

@mriccia mriccia commented May 11, 2023

No description provided.

Copy link

@alexcasalboni alexcasalboni left a comment

Choose a reason for hiding this comment

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

I think the overall approach makes sense, but I'd try to limit the amount of info we need to pass around as input/output while looping (see more detailed comment).

// run invocations in series
const {invocationResults, actualPayload} = await utils.invokeLambdaWithProcessors(lambdaARN, lambdaAlias, payloads[i], preARN, postARN);
if (onlyColdStarts){
await utils.waitForAliasActive(lambdaARN, aliasToInvoke);

Choose a reason for hiding this comment

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

no try-catch needed here? if it's not needed, I'd remove it above too :)

Copy link
Owner Author

Choose a reason for hiding this comment

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

The one above was for debug purposes - I will remove both


return powerValues;
module.exports.versionPublisher = async(event, context) => {

Choose a reason for hiding this comment

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

ideally this would be in a new file, to keep the one-function-per-file convention :)

Copy link
Owner Author

Choose a reason for hiding this comment

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

I will fix this

template.yml Outdated
- Version: '2012-10-17' # allow Lambda actions
Statement:
- Effect: Allow
Action:

Choose a reason for hiding this comment

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

Let's check which of these actions are still needed for the Initializer function above.

I think now the initializer is only reading and the publisher is only writing?

for (let powerValue of powerValues){
const baseAlias = 'RAM' + powerValue;
if (!onlyColdStarts){
lambdaFunctionsToSet.push({lambdaARN: lambdaARN, powerValue: powerValue, envVars: envVars, alias: baseAlias});

Choose a reason for hiding this comment

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

Splitting this logic into two separate function has a few security/privacy implications.

My concern here is that we are not only reading/modifying the environment variables of the given Lambda Function, but also passing them into the state machine input/output (and will likely end up into the overall state machine output too?). This could create complications when it comes to logging potentially sensitive variables/secrets to CloudWatch.

At the same time, I cannot think of a great alternative, besides refactoring this to be within the same Initializer function, with the same iterator logic, but then reading/updating the configuration on the spot.

In other words, instead of reading everything upfront to generate the full initConfigurations list, we would still iterate num times, and invoke utils.getLambdaPower and utils.createPowerConfiguration each time. I know it's a waste of time to invoke utils.getLambdaPower every time, but I think that's a better problem to have than passing around env variables & secrets.


// wait for functoin update to complete
await utils.waitForFunctionUpdate(lambdaARN);

const {Version} = await utils.publishLambdaVersion(lambdaARN);
if (typeof alias === 'undefined'){

Choose a reason for hiding this comment

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

When can this happen?

Copy link
Owner Author

Choose a reason for hiding this comment

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

This happens when we want to create a lambda version with the original power values (before Power Tuner modifications), and we don't want to setup an Alias for it (e.g. it'll be $LATEST)

Choose a reason for hiding this comment

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

ok cool, I'd add a comment about it :) it will be harder to guess/remember in 6 months

@coveralls
Copy link

coveralls commented May 24, 2023

Pull Request Test Coverage Report for Build 5070838536

  • 170 of 170 (100.0%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 5070168895: 0.0%
Covered Lines: 1207
Relevant Lines: 1207

💛 - Coveralls

@mriccia
Copy link
Owner Author

mriccia commented May 24, 2023

Closing this PR, please refer to the PR on the main project repo alexcasalboni#206

@mriccia mriccia closed this May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants