Skip to content

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

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

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 5070129290

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 169 of 170 (99.41%) changed or added relevant lines in 6 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 99.8%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lambda/utils.js 31 32 96.88%
Files with Coverage Reduction New Missed Lines %
lambda/utils.js 1 99.61%
Totals Coverage Status
Change from base Build 4937876410: -0.2%
Covered Lines: 1209
Relevant Lines: 1211

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