Skip to content
Fuse
Esc
↑↓navigate↵open⌘Jpreview
On this page

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

def convert(
    self, request: ConvertImageRequest, *, idempotency_key: Optional[str] = None
) -> Image: ...
def get(self, digest: str) -> Image: ...
def get_on_host(self, host_id: str, digest: str) -> Image: ...

convert sends POST /v1/images and returns the image at once (the server answers 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 idempotency_key, and a retry of the same request under the same key attaches to the first convert. The same key with another ref raises 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 raises fuse.ApiError with code == "invalid_argument"; a ref the registry does not have raises it with code == "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 raises it 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 raises fuse.ApiError with code == "not_found". There is no wait: poll get until state is no longer converting.

get_on_host 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 return another host’s ready record while the pinned host is still converting. An unknown host, or a host without the digest, raises fuse.ApiError with code == "not_found"; a QEMU host raises it with code == "invalid_argument".

import time

img = client.images.convert(fuse.ConvertImageRequest(ref="ubuntu:24.04"))
while img.state == fuse.IMAGE_CONVERTING:
    time.sleep(2)
    img = client.images.get(img.digest)
if img.state != fuse.IMAGE_READY:
    raise RuntimeError(img.error)
env = client.environments.create(
    fuse.CreateRequest(task_id="t", spec=fuse.Spec(image_digest=img.digest))
)

ConvertImageRequest

class ConvertImageRequest(BaseModel):
    ref: str = ""
    host_id: Optional[str] = None
    region: Optional[str] = None
    labels: Optional[dict[str, str]] = None
  • ref is required (an empty one raises ValueError): an OCI reference such as ubuntu:24.04 or ghcr.io/org/app@sha256:<digest>.
  • host_id, region and labels pick 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

class Image(BaseModel):
    digest: str = ""
    ref: str = ""
    manifest_digest: str = ""
    host_id: str = ""
    state: str = ""  # IMAGE_CONVERTING, IMAGE_READY or IMAGE_FAILED
    error: str = ""
  • digest is a hex sha256 of the manifest digest for the host’s arch and the fused binary baked into the rootfs, so a moved tag or a new fused is a new image.
  • error says why when state is IMAGE_FAILED.

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 raises fuse.ApiError with status == 409. It is mutually exclusive with Spec.image and seed_snapshot_id, and is refused with Spec.gpus and with a desktop (a 400).

Was this page helpful?