Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aws/microvm-agent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN dnf install -y \

RUN curl -fsSL https://cli.github.com/packages/rpm/gh-cli.repo \
-o /etc/yum.repos.d/gh-cli.repo \
&& dnf install -y gh-2.96.0-1 \
&& dnf install -y gh-2.97.0-1 \
&& dnf clean all \
&& gh --version

Expand Down
37 changes: 34 additions & 3 deletions cli/src/commands/infra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,35 @@ function getImageVersion(awsBin: string, region: string, imageArn: string, image
) as ImageVersionSummary;
}

function latestMicrovmImageBuildReason(
awsBin: string,
region: string,
imageArn: string,
imageVersion: string,
): string | undefined {
try {
const parsed = JSON.parse(
capture(awsBin, [
"lambda-microvms",
"list-microvm-image-builds",
"--image-identifier",
imageArn,
"--image-version",
imageVersion,
"--region",
region,
"--output",
"json",
"--no-cli-pager",
]),
) as { items?: Array<{ stateReason?: string; buildState?: string }> };
const failed = (parsed.items ?? []).filter((item) => item.buildState === "FAILED" && item.stateReason?.trim());
return failed[0]?.stateReason?.trim() || undefined;
} catch {
return undefined;
}
}

async function waitForImageVersion(
awsBin: string,
region: string,
Expand All @@ -369,9 +398,9 @@ async function waitForImageVersion(
}
if (version.state === "SUCCESSFUL" && version.status === "ACTIVE") return;
if (version.state === "FAILED") {
throw new CliError(
`MicroVM image version ${imageVersion} failed${version.stateReason ? `: ${version.stateReason}` : ""}`,
);
const buildReason = latestMicrovmImageBuildReason(awsBin, region, imageArn, imageVersion);
const reason = buildReason || version.stateReason;
throw new CliError(`MicroVM image version ${imageVersion} failed${reason ? `: ${reason}` : ""}`);
}
if (["DELETING", "DELETED", "DELETE_FAILED"].includes(version.state)) {
throw new CliError(`MicroVM image version ${imageVersion} entered unexpected state ${version.state}`);
Expand Down Expand Up @@ -484,6 +513,8 @@ async function buildAwsMicrovmImageLocked(
baseImageArn,
"--build-role-arn",
buildRoleArn,
"--logging",
`cloudWatch={logGroup=/aws/lambda/microvms/${imageName}}`,
"--client-token",
`${digest}-${randomUUID()}`,
"--region",
Expand Down
2 changes: 1 addition & 1 deletion cli/templates/aws/microvm-agent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN dnf install -y \

RUN curl -fsSL https://cli.github.com/packages/rpm/gh-cli.repo \
-o /etc/yum.repos.d/gh-cli.repo \
&& dnf install -y gh-2.96.0-1 \
&& dnf install -y gh-2.97.0-1 \
&& dnf clean all \
&& gh --version

Expand Down