Skip to content

feat(cuttlefish): implement storage flash via HO user artifacts - #1031

Draft
bennyz wants to merge 1 commit into
jumpstarter-dev:mainfrom
bennyz:cuttlefish-storage-flash
Draft

feat(cuttlefish): implement storage flash via HO user artifacts#1031
bennyz wants to merge 1 commit into
jumpstarter-dev:mainfrom
bennyz:cuttlefish-storage-flash

Conversation

@bennyz

@bennyz bennyz commented Aug 27, 2026

Copy link
Copy Markdown
Member

Implement CvdFlasher.flash() to upload image archives to the Cuttlefish Host Orchestrator's user-artifact store and stage them for the next CVD creation.

The flow: stream the source to a temp file while computing its SHA-256 (HO addresses artifacts by checksum), skip the transfer if already present, chunked-multipart PUT to /v1/userartifacts/{checksum}, extract server-side, then create and populate an image directory. The resulting dir id is staged on the parent so the next power.on() references it via HO's @image_dirs/{id} token.

The large streaming upload uses httpx.AsyncClient so a multi-GB transfer never blocks the event loop; the small JSON control-plane calls reuse the existing sync operation-polling helpers via anyio.to_thread.

env_config injection of the staged image dir (_env_config_for_create) is intentionally left as a follow-up decision (which fields, merge vs overwrite); with no staged dirs the configured env_config passes through unchanged, preserving existing behavior.

@bennyz
bennyz marked this pull request as draft August 27, 2026 09:52
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Implement CvdFlasher.flash() to upload image archives to the Cuttlefish
Host Orchestrator's user-artifact store and stage them for the next CVD
creation.

The flow: stream the source to a temp file while computing its SHA-256
(HO addresses artifacts by checksum), skip the transfer if already
present, chunked-multipart PUT to /v1/userartifacts/{checksum}, extract
server-side, then create and populate an image directory. The resulting
dir id is staged on the parent so the next power.on() references it via
HO's @image_dirs/{id} token.

The large streaming upload uses httpx.AsyncClient so a multi-GB transfer
never blocks the event loop; the small JSON control-plane calls reuse the
existing sync operation-polling helpers via anyio.to_thread. A failed
chunk retries at the same offset (the offset scheme makes resume free),
rather than aborting the whole transfer.

power.on() injects the staged image dir via _env_config_for_create(),
which deep-copies the configured env_config and rewrites
common.host_package and each instance's disk.default_build to the
@image_dirs/{id} token (synthesizing an instance when none is
configured). With no staged dirs the configured env_config passes
through unchanged, preserving existing behavior.

Staged image dirs are reclaimed best-effort: re-flashing deletes the
previously staged dir, and close() deletes any remaining dirs at
teardown (a failed DELETE is logged, not raised, since HO refuses to
delete a dir a running CVD still references).

Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
@bennyz
bennyz force-pushed the cuttlefish-storage-flash branch from 2708dd0 to c1adcde Compare August 27, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant