mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(lambda): preserve each MicroVM version build specification (#8600)
Each MicroVM image version now records the build inputs it was created with (code artifact URI, base image ARN and version, build role) as an immutable BuildSpec. GetMicrovmImageVersion and ListMicrovmImageVersions read that snapshot instead of the image's latest inputs, so an update no longer rewrites what older versions report. Versions stored before this change have no snapshot and fall back to their image's last known inputs; the docs note that their original inputs cannot be recovered. Closes #7312
This commit is contained in:
1 parent
975632df5c
commit
06a5ce4219
5 files changed
+151
-7
No files matched your search
@@ -9,6 +9,7 @@ import io.floci.aws.core.common.AwsArnUtils;
|
||||
import io.floci.aws.core.common.AwsException;
|
||||
import io.floci.aws.core.common.EpochSeconds;
|
||||
import io.floci.aws.core.common.RegionResolver;
|
||||
import io.floci.aws.services.lambdamicrovms.LambdaMicrovmsService.BuildSpec;
|
||||
import io.floci.aws.services.lambdamicrovms.LambdaMicrovmsService.Microvm;
|
||||
import io.floci.aws.services.lambdamicrovms.LambdaMicrovmsService.MicrovmBuild;
|
||||
import io.floci.aws.services.lambdamicrovms.LambdaMicrovmsService.MicrovmImage;
|
||||
@@ -399,9 +400,8 @@ public class LambdaMicrovmsController {
|
||||
}
|
||||
|
||||
private ObjectNode versionNode(MicrovmImage image, MicrovmImageVersion version) {
|
||||
// A version response repeats the parent image's whole build spec. The
|
||||
// data is all on the image, which this method already receives; it was
|
||||
// simply never written out.
|
||||
// Older records have no snapshot, so only their parent's last known inputs remain available.
|
||||
BuildSpec buildSpec = version.buildSpec != null ? version.buildSpec : BuildSpec.from(image);
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("imageArn", image.imageArn);
|
||||
node.put("imageVersion", version.imageVersion);
|
||||
@@ -409,10 +409,10 @@ public class LambdaMicrovmsController {
|
||||
node.put("status", version.status);
|
||||
node.put("createdAt", EpochSeconds.fromInstant(version.createdAt));
|
||||
node.put("updatedAt", EpochSeconds.fromInstant(image.updatedAt));
|
||||
node.put("baseImageArn", image.baseImageArn);
|
||||
node.put("baseImageVersion", image.baseImageVersion);
|
||||
node.put("buildRoleArn", image.buildRoleArn);
|
||||
node.putObject("codeArtifact").put("uri", image.codeArtifactUri);
|
||||
node.put("baseImageArn", buildSpec.baseImageArn());
|
||||
node.put("baseImageVersion", buildSpec.baseImageVersion());
|
||||
node.put("buildRoleArn", buildSpec.buildRoleArn());
|
||||
node.putObject("codeArtifact").put("uri", buildSpec.codeArtifactUri());
|
||||
// A version's description is its own and nothing sets it. It stays null
|
||||
// even once the parent image has one, which is why it cannot simply be
|
||||
// read off the image.
|
||||
|
||||
@@ -130,6 +130,13 @@ public class LambdaMicrovmsService implements ResourceProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterForReflection
|
||||
public record BuildSpec(String baseImageArn, String baseImageVersion, String buildRoleArn, String codeArtifactUri) {
|
||||
static BuildSpec from(MicrovmImage image) {
|
||||
return new BuildSpec(image.baseImageArn, image.baseImageVersion, image.buildRoleArn, image.codeArtifactUri);
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterForReflection
|
||||
public static final class MicrovmImage {
|
||||
public String name;
|
||||
@@ -155,6 +162,7 @@ public class LambdaMicrovmsService implements ResourceProvider {
|
||||
public String status;
|
||||
public Instant createdAt;
|
||||
public final List<MicrovmBuild> builds = new ArrayList<>();
|
||||
public BuildSpec buildSpec;
|
||||
public RuntimeSettings runtimeSettings;
|
||||
}
|
||||
|
||||
@@ -223,6 +231,7 @@ public class LambdaMicrovmsService implements ResourceProvider {
|
||||
version.state = "SUCCESSFUL";
|
||||
version.status = "ACTIVE";
|
||||
version.createdAt = Instant.now();
|
||||
version.buildSpec = BuildSpec.from(image);
|
||||
version.runtimeSettings = image.runtimeSettings;
|
||||
// A version is built once per Graviton generation the service targets,
|
||||
// newest first. Recorded live: two builds per version, not one.
|
||||
|
||||
Reference in new issue
Block a user