Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Lambda revisions #7482

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 22 commits into from
Jan 18, 2023
Merged

Lambda revisions #7482

merged 22 commits into from
Jan 18, 2023

Conversation

joe4dev
Copy link
Member

@joe4dev joe4dev commented Jan 13, 2023

Test + implement revisions (i.e., RevisionId) for lambda in general (with versions,
aliases, layers, etc). It seems that the revision id of permissions is
the same as for qualified lambdas (i.e., VersionFunctionConfiguration).

Motivation

  • Follow-up from Lambda permissions #7336
  • Mentioned in skip_snapshot_verify and TODO comments at multiple places
    • CloudFormation tests also mentions: “seems the revision id of the policy actually corresponds to the one of the function version”

Behavior

  • CreateFunction: RevisionId The latest updated revision of the function or alias.
  • Non-matching revision id raises a PreconditionFailedException

Overview of Actions / API Operations with RevisionId support:

Request Response Both
AddPermission ✔️ CreateAlias ✔️ AddLayerVersionPermission ✔️
RemoveLayerVersionPermission ✔️ CreateFunction ✔️ PublishVersion ✔️
RemovePermission ✔️ GetAlias ✔️ UpdateAlias ✔️
GetFunction ✔️ UpdateFunctionCode ✔️
GetFunctionConfiguration UpdateFunctionConfiguration ✔️
GetLayerVersionPolicy ✔️
GetPolicy ✔️
ListAliases
ListFunctions
ListVersionsByFunction

Scope

  • LayerVersionPolicy: have their own RevisionId independent of functions as they can exist without functions.
  • RevisionId per function configuration. Aliases and versions have their own function configuration but lambda permissions don’t.
    • The fact that the permissions only require the RevisionId in the request but don’t contain it in the reply, could hint that it’s not part of their entity and only stored per function configuration
    • Also fits together with DeleteAlias not mentioning any RevisionId because it’s gone with the associated function configuration after deleting the alias

Questions

  • Do we need locking to ensure atomic updates across entities?

Details

For more details: See Revisions in the Notion Lambda Board.

Follow Up (out of scope)

  • Consider updating the data model such that property updates automatically trigger a revision_id update within the right entity such that we a) don't need locks for ensuring atomic updates b) simplify code for retrieval and updates.

@joe4dev joe4dev temporarily deployed to localstack-ext-tests January 13, 2023 11:27 — with GitHub Actions Inactive
@github-actions
Copy link

github-actions bot commented Jan 13, 2023

LocalStack integration with Pro

       3 files  ±0         3 suites  ±0   1h 24m 39s ⏱️ -6s
1 644 tests +2  1 328 ✔️ ±0  316 💤 +2  0 ±0 
2 340 runs  +6  1 696 ✔️ ±0  644 💤 +6  0 ±0 

Results for commit 4278da8. ± Comparison against base commit 6dda0b1.

♻️ This comment has been updated with latest results.

@joe4dev joe4dev temporarily deployed to localstack-ext-tests January 13, 2023 18:03 — with GitHub Actions Inactive
@joe4dev joe4dev temporarily deployed to localstack-ext-tests January 16, 2023 13:43 — with GitHub Actions Inactive
Copy link
Member

@dominikschubert dominikschubert left a comment

Choose a reason for hiding this comment

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

Looks great!

Love the additional comments you added where the context was a bit obscure 👍

I know there are a few new TODOs and things we've encountered here that will need to be fixed in the future, but I'd propose we move forward for now and tackle this later when polishing 👍

@joe4dev joe4dev temporarily deployed to localstack-ext-tests January 18, 2023 10:22 — with GitHub Actions Inactive
@joe4dev
Copy link
Member Author

joe4dev commented Jan 18, 2023

I agree on bundling these TODOs in the polishing round 👍
Let's prioritize the layers and roadmap for now

@joe4dev joe4dev merged commit d617162 into master Jan 18, 2023
@joe4dev joe4dev deleted the lambda-revisions branch January 18, 2023 10:30
Copy link
Member

@dfangl dfangl left a comment

Choose a reason for hiding this comment

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

LGTM, good work (little too late :D)

@@ -402,6 +404,11 @@ def _publish_version_from_existing_version(
self.lambda_service.publish_version(new_version)
state = lambda_stores[account_id][region]
function = state.functions.get(function_name)
# TODO: re-evaluate data model to prevent this dirty hack just for bumping the revision id
Copy link
Member

Choose a reason for hiding this comment

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

Yes, the intention was to have a transparent mechanism to change revision ids without manually doing it, but publishing versions is the perfect counterexample for that.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see. Commendable efforts as it works most of the time and makes it easier for these cases.

Comment on lines +200 to +201
"""Utility method to create a new function via the Lambda API
CAVEAT: Does NOT wait until the function is ready/active. The fixture create_lambda_function waits until ready."""
Copy link
Member

Choose a reason for hiding this comment

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

This method is actually the base of create_lambda_function, as the fixture was meant as a drop in replacement. Nobody should use this function directly anymore (or almost anything in testutil, for that matter)

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense.
I just saw it used in other services (17x in localstack and 21x in -ext) and therefore added the clarification and reference to the fixture.

@joe4dev
Copy link
Member Author

joe4dev commented Jan 18, 2023

LGTM, good work (little too late :D)

Thank you 🙏

Sorry for the timing 😬

joe4dev added a commit that referenced this pull request Jan 25, 2023
Resolves misleading naming especially for latest_version (pretends it is $LATEST) but actually refers to the resolved qualifier.
Fixes Daniel's comment: #7482 (comment)
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