From d6d30df90b4459f6699da03fbd6c1e254a8aed6b Mon Sep 17 00:00:00 2001 From: atlas Date: Sun, 22 Nov 2026 20:44:16 +0100 Subject: [PATCH] docs: migrate status reads the gate from the pod's status --- docs/2-handbook/swarm/swarmctl-cli.md | 34 +++++++++++++++++++++++++++ docs/4-implementation/k8s/migrate.md | 18 +++++++++----- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/docs/2-handbook/swarm/swarmctl-cli.md b/docs/2-handbook/swarm/swarmctl-cli.md index 822ef46c8..dc9b2d461 100644 --- a/docs/2-handbook/swarm/swarmctl-cli.md +++ b/docs/2-handbook/swarm/swarmctl-cli.md @@ -40,6 +40,8 @@ This document contains the help content for the `swarmctl` command-line program. * [`swarmctl bao`↴](#swarmctl-bao) * [`swarmctl bao init`↴](#swarmctl-bao-init) * [`swarmctl bao grant-bootstrap`↴](#swarmctl-bao-grant-bootstrap) +* [`swarmctl migrate`↴](#swarmctl-migrate) +* [`swarmctl migrate status`↴](#swarmctl-migrate-status) * [`swarmctl login`↴](#swarmctl-login) * [`swarmctl completions`↴](#swarmctl-completions) @@ -57,6 +59,7 @@ swarm-level operator CLI * `forge` — Manage human accounts on the swarm's forge * `setup` — Walk through the first-run setup, interactively * `bao` — Initialise the swarm's secret store and bootstrap its granter +* `migrate` — Move the swarm's services from this host onto its k3s cluster * `login` — Log in to the swarm named by `--swarm` as your own SSO account * `completions` — Generate a shell completion script for `swarmctl` and print it to stdout @@ -742,6 +745,37 @@ Reads the root token from a hidden prompt, or from stdin when stdin isn't a term +## `swarmctl migrate` + +Move the swarm's services from this host onto its k3s cluster. + +`docs/4-implementation/k8s/migrate.md` describes the move. Only `status` exists yet, and it moves nothing and creates no pod. + +**Usage:** `swarmctl migrate + migrate ` + +###### **Subcommands:** + +* `status` — Report where each service stands: its runtime, its host units, its pod and the start gate's answer, and which step comes next + + + +## `swarmctl migrate status` + +Report where each service stands: its runtime, its host units, its pod and the start gate's answer, and which step comes next. + +Read-only: it creates no pod and changes nothing. Run it as root; it reads `/etc/hyperhive/migrate.json`, asks systemd about the host units and lists the pods in the swarm's namespace with the k3s admin kubeconfig. + +Exits 0 when every check ran, whatever the answers, and 1 when a check failed to run. A script reads the report from `--json`. + +**Usage:** `swarmctl migrate status [OPTIONS]` + +###### **Options:** + +* `--json` — Print the report as JSON: the services as the module renders them, one entry per step with its status, and the next step + + + ## `swarmctl login` Log in to the swarm named by `--swarm` as your own SSO account. diff --git a/docs/4-implementation/k8s/migrate.md b/docs/4-implementation/k8s/migrate.md index 876bfe350..8a52aca8f 100644 --- a/docs/4-implementation/k8s/migrate.md +++ b/docs/4-implementation/k8s/migrate.md @@ -33,6 +33,7 @@ The command moves the swarm's own daemons and the queue into the cluster: | `services.hyperhive.deploy..runtime` | `"host"` or `"k8s"`, per service | | `/etc/hyperhive/migrate.json` | the module's render of each service's runtime, state paths, PVC | | `/var/lib/hyperhive-migrate/` | host record: pre-move snapshots and copy digests, root `0700` | +| `SWARMCTL_KUBECTL`, `SWARMCTL_KUBECONFIG` | the `swarmctl` wrapper's `kubectl` and the k3s admin kubeconfig | | `.hyperhive-migrated` in a PVC | the copy marker the pod's start gate checks for | | `swarmctl migrate` `status` / `rollback` / `finish` | the verbs | @@ -154,12 +155,17 @@ stopped, and the loop offers retry, skip or quit on a failed step. ### What's observed and what's recorded -| fact | observed from | -| ---------------------------------- | --------------------------------------------------------- | -| where the config wants the service | `/etc/hyperhive/migrate.json`, which the rebuild renders | -| host unit active or not | `systemctl is-active` | -| workload, pod phase, Ready | `kubectl` | -| copy done | `.hyperhive-migrated` in the PVC, read through a copy pod | +| fact | observed from | +| ---------------------------------- | ---------------------------------------------------------- | +| where the config wants the service | `/etc/hyperhive/migrate.json`, which the rebuild renders | +| host unit active or not | `systemctl is-active` | +| workload, pod phase, Ready | `kubectl` | +| copy done | the pod's `state-gate` init container, in the pod's status | + +`swarmctl migrate status` reads the gate's answer from the pod's status: the +gate exited 0 when the marker is in the volume, and a refusal puts its reason +in the container's termination message. Status never starts a pod, so it +creates nothing and reads only. Two facts vanish once the host unit stops, so `/var/lib/hyperhive-migrate/` records them: the step 1 snapshot, and the digest of the copied tree. Without