Repository navigation
up --local: Cloud from this machine's source, on a runtime with a budget - #119
Merged
Merged
Conversation
Four faults met on one local runtime, each fixed where it starts. A local build was not what ran. `hanzo up` deploys a published image; `--local` builds the directory's declared image (hanzo.config.json `local`), has the supervisor load the OCI layout into the node's containerd, and writes a Deployment that names it exactly with imagePullPolicy Never. Nothing on that path resolves a name against a registry, so there is no published image it can fall back to. The supervisor answers a control socket for this (load, prune, facts): it is the only process that can reach the guest. Layers the node already holds are not sent again. The scheduler answered Insufficient memory. Cloud requested half the vm, so two pods never fit, and the supervisor deleted the first pod on every boot because it had been created before its pull secret. The request is now half of what the node does not keep for itself, and the workload is applied after its credentials, so there is no first pod to delete. Cloud ran as the namespace's default account and was refused three reads. It runs as hanzo/cloud, granted those reads and nothing else; doctor asks the API server about each. Its data was an emptyDir, gone with every `hanzo down`. It is on a volume claim, and the Deployment is replaced rather than merged so the old volume does not linger beside the new one. Also: `hanzo up` after `hanzo down` read a Deployment scaled to zero as no Deployment (Kubernetes omits spec.replicas when it is 0) and deployed the default image over whatever the stopped one named. An `up` now changes the image only when it names one. `hanzo stop` prunes the stopped vm's disk, which was left behind whole. `hanzo doctor` prints the runtime's shape, budget, image provenance, grants and refused stream declarations. The bus is told its file store (CLOUD_PUBSUB_MAX_STORE). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A load staged the whole archive on the node before importing it, so a build that changed every layer needed the old image, the new one and the archive at once and missed fitting a 32 GiB disk by a hair. Layers now travel in imports of about 256 MiB; every import but the last only stores, and the last names and unpacks the image. That last import always runs, also when no layer is new: holding every layer is not having unpacked them. The deploy plane's health lists apps.hanzo.ai in its own namespace. Granted, a cluster with no such kind answers 404 where it answered 403. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The change still has two active moderate issues in local-build state handling that can cause restarts or resizes to use stale runtime settings and a prior published image.
2 open issues
What changed in this PR
Adds hanzo up --local support so Cloud can be built from the current machine, loaded directly into the microVM's containerd, and deployed with imagePullPolicy: Never. It also updates runtime supervision, lifecycle persistence, Kubernetes identity and storage setup, cleanup, and doctor diagnostics.
Changes:
- Adds
--local[=LAYOUT]CLI handling and local build/layout resolution. - Adds runtime control operations, deferred workload deployment, and VM pruning.
- Persists local-build state, applies resource budgets and persistent storage, and reports runtime health through
hanzo doctor.
| File | Description |
|---|---|
| src/main.rs | Adds the --local option to hanzo up with its relevant conflicts. |
| src/commands/vm.rs | Adds VM disk pruning and guest file-transfer helpers. |
| src/commands/up/supervisor.rs | Applies runtime ground and workload manifests in order and serves the runtime control socket. |
| src/commands/lifecycle/resources.rs | Restores local Cloud layout information when reconstructing runtime state. |
| src/commands/lifecycle/project.rs | Persists local-build metadata and recognizes the Cloud source checkout. |
| src/commands/lifecycle/mod.rs | Implements local environment startup and local-image restoration during lifecycle operations. |
| src/commands/doctor.rs | Adds local runtime resource, image, access, and configuration diagnostics. |
| src/cli_dispatch.rs | Validates and forwards local-mode arguments into lifecycle handling. |
Review effort: Lite
Comment on lines
+439
to
+441
| state.runtime.desired_running = true; | ||
| state.platform.cloud_enabled = true; | ||
| state.platform.cloud_local = Some(layout); |
| let mut state = load_state().unwrap_or_default(); | ||
| state.runtime.desired_running = true; | ||
| state.platform.cloud_enabled = true; | ||
| state.platform.cloud_local = Some(layout); |
…eadiness - Quiesce k3s and workloads via control.sock Request::Stop (cordoning the node so Deployment.spec.replicas stays intact, draining pods so SQLite WAL and NATS JetStream flush cleanly, stopping k3s/containerd, and checkpointing the live ext4 disk via hanzo-vm stdio RPC to k3s-<ver>-state.ext4 via atomic staging rename so macOS clonefile never hits EEXIST). - Resume from k3s-<ver>-state on hanzo start and hanzo up when present, clamping --disk-size to at least the saved ext4 image, uncordoning the node, preserving bound PVC size in GROUND, and keeping hanzo.local/* images and KMS secrets across stop/start without falling back to published images. - Sweep ~/.hanzo/vm/instances/<vm_pid> on supervisor exit and signal fallback so 26-32 GiB transient disks never leak; wipe k3s-<ver>-state on hanzo reset. - Reconcile PR #114 fixes: discover project hanzo.config.{json,ts} before warm reuse, treat --strict-registry as a warm workload override, plant registry pull secrets on warm/resumed clusters, separate runtime-ready from ready, and wait for Deployment generation + ready/available replicas.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What this does
hanzo up --localruns Cloud from the source on this machine, and the local runtime gets a resource budget, an account of its own and a data volume. Four faults met on one runtime, each fixed where it starts. The bus side is hanzoai/cloud#87.hanzo uponly deploys a published imageup --local: run the directory's declared build, load the OCI layout into the node's containerd, deploy that exact name withimagePullPolicy: Neverhanzo down, Kubernetes omitsspec.replicas: 0from the Scale object, which was read as "no Deployment"upchanges the image only when it names oneInsufficient memoryon every first bootis forbidden: User "system:serviceaccount:hanzo:default"hanzo/cloud, granted the four reads Cloud makeshanzo downemptyDirhanzo stopstoprunshanzo-vm pruneup --localThe directory's
hanzo.config.jsondeclares the build:"local": {"build": "<command>", "image": "<OCI layout dir>"}.--local=<dir>names a layout directly and builds nothing.ErrImageNeverPull. A local image must be named underhanzo.local/, which no registry answers to.up/control.rs,~/.hanzo/up/control.sock, 0600). The supervisor is the only process that can run a command in the guest, so it answers three named operations between looks at its vm:load,prune,facts. Never a command a caller wrote. A runtime booted by an olderhanzohas no socket, and--localsays to restart it once.up/load.rs).ctr content lssays what the node holds; only the layers it lacks are sent, in imports of about 256 MiB, and the last import names and unpacks the image. Verified on k3s v1.37.2 / containerd 2.3.7 that an archive without layers the store already has imports cleanly.Budget, account, doctor
up/budget.rs: on the 4 GiB default Cloud requests 1664 MiB (was 2048), floor 1536, and a runtime under 3840 MiB is refused with the arithmetic. The bus is told its file store throughCLOUD_PUBSUB_MAX_STORE. On a warm runtime the shape comes from the supervisor, not the flags of the later invocation.up/manifest.rsground: namespaces, thecloudServiceAccount, its grants and the volume claim. Grants:podslist+watch cluster-wide,jobslist inhanzoandhanzo-build,apps.hanzo.ailist inhanzo. No write verb.up/diagnose.rs:hanzo doctorprints a runtime section: shape, budget, host memory beside the runtime's, node disk, image provenance, whether two pods fit, whether data is on a claim, each grant asked of the API server by SubjectAccessReview, and refused stream declarations in the pod's log.Measured (Linux x86-64, 4 GiB / 32 GiB runtime, hanzo-inc/cloud)
hanzo downthenhanzo upInsufficient memoryeventsTests
cargo clippy --bin hanzois clean. 514 unit tests and the integration suites pass.spec_driftfails here and onmainas cloned (spec/live.jsonand.spec-lockname different releases); this branch touches neither file.Not tested, and limits
hanzo restartrestoring a local build,--local=<layout>, the native-k3s refusal: unit tests only.hanzo stop. hanzo-vm 2.0.2 boots every vm from the checkpoint and keeps no disk (--rootfsis copied and discarded, measured).🤖 Generated with Claude Code