-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix(lambda-python): asset hash is non-deterministic #12984
Conversation
When a Python handler uses external dependencies, the hash calculated on the output is non-determinstic due to the fact that it includes timestamps. To resolve that, change the asset hash strategy to `SOURCE` which means that the bundle will only be re-created if one of the source files changes. Fixes #12770 Fixes #12684
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.
This means effectively forcing users to modify their requirements
in order to push an updated version of a dependency. Maybe make this configurable?
What do you mean by configurable? What kind of API would you imagine? Technically, they don't need to modify Let me know how do you propose to model this. |
…ction-use-source-hash
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.
This conflicts with one of the foundational tenets we have in the CDK which says that only when the source changes your app changes.
Yeah, and I'm all for it. But we do have this option of using OUTPUT
, which presumably addresses changes in dependencies (?). I'm just wondering if we should address the use case of users explicitly not locking their dependencies, expecting them to update on build, which is what happens now.
As far as API, yeah something like deployOnEveryUpdate
, or maybe even straight up expose hashType
for advanced users. I can try to come up with something less awkward if you choose to pursue it. But i'm also good with using SOURCE
for now and possibly extending later.
Added do-not-merge
.
@eladb thanks for working on this! I think the best solution would be to allow to set |
I'll add a way to control this, but I think the default should be |
…ction-use-source-hash
…ction-use-source-hash
Image hash was not deterministic because it had the full path of the Dockerfile in it. Create a staging directory which contains the docker build context files instead.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
set `assetHashType: AssetHashType.SOURCE`, see aws/aws-cdk#12984
When a Python handler uses external dependencies, the hash calculated on the output is non-determinstic due to the fact that it includes timestamps. To resolve that, change the asset hash strategy to
SOURCE
which means that the bundle will only be re-created if one of the source files changes.Additionally, the Python image hash, which is also included in the asset hash (to ensure that if the build image changes, the bundle is invalidated) included the absolute path for the
Dockerfile
. This caused the image hash itself to change every time the image was built on a different system. To fix this, we stage the dependency files & dockerfile into a temp directory and build the image from there.Fixes #12770
Fixes #12684
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license