Images
Convert OCI images into bootable rootfs images with the images service
The images service converts an OCI image, such as ubuntu:24.04, into a
rootfs on a Firecracker host, the step a Fusefile’s
from: runs inside
fuse up. A create boots the result by naming its digest in
spec.image_digest. Public registries only, and only apt and dnf based images
convert.
client.images
convert(req: ConvertImageRequest, opts?: MutatingCallOptions): Promise<Image>
get(digest: string, opts?: CallOptions): Promise<Image>
getOnHost(hostId: string, digest: string, opts?: CallOptions): Promise<Image>
convert sends POST /v1/images and resolves at once with the image (a
202), usually still converting. The bake keeps running on the host if your
process goes away. Converting a ref that is already converting or ready returns
that image; one that failed is converted again. The convert runs as an
operation: each call sends an
Idempotency-Key, a fresh one unless you pass opts.idempotencyKey, and a
retry of the same request under the same key attaches to the first convert.
The same key with another ref rejects with a 409 whose details.reason is
idempotency_key_reused. A convert that answered 5xx, such as the 507 below,
runs again when retried under its key. One that outlasts the server’s wait is
followed until it answers. A malformed ref, a registry
that needs credentials, or a host_id that runs the QEMU backend rejects with
a FuseApiError whose code is invalid_argument; a ref the registry does
not have rejects with not_found. A host whose image cache is full evicts its
least recently used images first; when every one is converting or used by a vm
or snapshot the convert rejects with status 507 and code unavailable. An
evicted image reads as not found again until it is converted again.
get reads an image by digest. When more than one host holds it, the most
usable record wins: ready, then converting, then failed. An unknown digest
rejects with a FuseApiError whose code is not_found. There is no wait:
poll get until state is no longer converting.
getOnHost reads one host’s record (GET /v1/hosts/{hostId}/images/{digest}).
To wait on a convert pinned with host_id, region or labels, poll it with
the host_id the convert returned: get could resolve with another host’s
ready record while the pinned host is still converting. An unknown host, or a
host without the digest, rejects with not_found; a QEMU host rejects with
invalid_argument.
import { ImageState } from "@folsom/fuse";
let img = await client.images.convert({ ref: "ubuntu:24.04" });
while (img.state === ImageState.Converting) {
await new Promise((r) => setTimeout(r, 2000));
img = await client.images.get(img.digest);
}
if (img.state !== ImageState.Ready) throw new Error(img.error);
const env = await client.environments.create({
task_id: "t",
spec: { image_digest: img.digest },
});
ConvertImageRequest
interface ConvertImageRequest {
ref: string;
host_id?: string;
region?: string;
labels?: Record<string, string>;
}
refis required: an OCI reference such asubuntu:24.04orghcr.io/org/app@sha256:<digest>.host_id,regionandlabelspick the Firecracker host the way a create’s placement does. Convert where the environment will run: a create lands only on a host where the image is ready.
Image
interface Image {
digest: string;
ref: string;
manifest_digest: string;
host_id: string;
state: string; // one of ImageState: "converting", "ready" or "failed"
error?: string;
}
digestis a hex sha256 of the manifest digest for the host’s arch and thefusedbinary baked into the rootfs, so a moved tag or a newfusedis a new image.errorsays why whenstateisfailed.
spec.image_digest
spec.image_digest boots a converted image. The create is pinned to a host
where the image is ready; one that is not ready on any host rejects with a
409 conflict. It is mutually exclusive with spec.image and
seed_snapshot_id, and is refused with spec.gpus and with a desktop (a
400).