mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 14:10:49 -05:00
fix(lambda): do not publish a version when nothing has changed (#2941)
"AWS Lambda doesn't publish a version if the function's configuration and code haven't changed since the last version." Publishing was unconditional, so repeated publishes accumulated identical versions. Unchanged is decided by $LATEST's revisionId, which is regenerated on every code and configuration update, so a version records the revision it was cut from and a later publish that finds it unmoved returns that version. Keying on the revision rather than comparing the fields a snapshot copies means a field added later is covered without anyone remembering to update a comparison. Versions published before this carry no source revision and never match, so existing state keeps its previous behaviour. Three carve-outs, each with a test: Description is supplied at publish time rather than carried on $LATEST, so a publish naming a new one is a real publish even when nothing else moved. LambdaVersionIntegrationTest already asserted that and decides the case. Only the most recent version counts, because AWS compares against the last version: a description going A then B then A must publish again rather than matching the older A. A hot-reload function's code lives in a bind-mounted directory that changes with no API call, so revisionId cannot witness it and these always publish. Two existing tests change, because the behaviour they assert is the one this fixes. LambdaServicePersistenceTest reached version 3 by publishing three times with nothing changed; its subject is the counter surviving a restart, so it now varies the description. CodeDeployTest published identical bytes twice to get two versions for a blue/green shift; it now deploys a real change between them, which is what a blue/green deployment does anyway. Closes #2822
This commit is contained in:
1 parent
91d7ab8935
commit
c48b6b0b0a
5 files changed
+183
-3
No files matched your search
@@ -300,6 +300,14 @@ class CodeDeployTest {
|
||||
v1 = pv1.version();
|
||||
assertThat(v1).isNotBlank();
|
||||
|
||||
// A second version needs a real change behind it. AWS does not publish a version when the
|
||||
// code and configuration have not moved since the last one, so two publishes in a row
|
||||
// return the same version. A blue/green deployment shifts between two different builds
|
||||
// anyway, so deploy one here rather than publishing the same bytes twice.
|
||||
lambda.updateFunctionCode(r -> r
|
||||
.functionName(DEPLOY_FUNCTION)
|
||||
.zipFile(SdkBytes.fromByteArray(LambdaUtils.handlerZip())));
|
||||
|
||||
PublishVersionResponse pv2 = lambda.publishVersion(r -> r.functionName(DEPLOY_FUNCTION));
|
||||
v2 = pv2.version();
|
||||
assertThat(v2).isNotBlank().isNotEqualTo(v1);
|
||||
|
||||
Reference in new issue
Block a user