Files
ilkerandClaude Opus 5.5 d07f443d0b
ci / derle (push) Successful in 49s
baremetal: run on SONiC, and the four bugs it found
The sonic driver, tested only against a fake until now, built a cluster
on SONiC 202505 (VS), cleaned two machines at once in its cleaning VLAN,
and released them. Fixed on the way:

- port changes raced: parallel processes both created a cluster's VLAN;
  the driver now locks on the switch around every change
- a cleaning killed between its two switch changes left a dirty machine
  in no VLAN, which looks free; a cleaning now records its start first,
  a machine is free only if its last cleaning finished and passed, and
  one cleaning per machine runs at a time under a lock
- the portal's startup sweep marked a selftest's destroy failed, which
  killed it; builds and destroys hold a lock the sweep respects
- setup wrote the trunk's configuration without applying it

Also selftest -boot-timeout, sonic.sh prepare, and the portal showing an
interrupted cleaning, with Retry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 17:33:34 +01:00

446 lines
24 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Changelog
## Unreleased
### Backends other than Proxmox can be added
Proxmox was assumed everywhere past discovery. Now:
- The variables a cluster is built from (`provision.Contract`) name no
backend: `devices` replaces `hostpci`, and the Proxmox environment
derives `vmid_base` from `cluster_id` itself. A test holds every
`terraform/envs/*` to the contract.
- Each site has its own Terraform environment, in
`/var/lib/hpcod/terraform/template/<site id>/`, and a cluster is built
from its record's site. Before, every cluster was built from one
environment, so one placed on a second site went to the first. Setup
moves an existing flat template into its site's directory; a portal
updated with `make deploy-portal` alone keeps building from the flat one
while exactly one site is configured.
- Setup's Proxmox parts (steps, form fields, packages, configuration,
checks) are a `setup.Backend`. A site names its backend in `SITE_KIND`,
empty meaning `proxmox`. `PVE_SITE_ID` and `PVE_SITE_NAME` are now
`SITE_ID` and `SITE_NAME`; old `site.env` files are still read.
### A libvirt/KVM backend
`SITE_KIND=libvirt` builds clusters on one libvirt host, reached over SSH
with the control plane's key and a pinned host key: an isolated network per
cluster, the head as a qcow2 overlay on a head image built by the same
playbook as the Proxmox template, diskless compute nodes booting from it,
PCI devices as managed hostdevs. Discovery, the Terraform environment and
setup are each the backend's own; the cluster's names, MACs and head
configuration now come from one module (`terraform/modules/layout`) that
both backends use. See DEPLOY.md, "A libvirt host", and
`deploy/site.env.libvirt.example`.
Run end to end on a nested-KVM test host (Debian 13, libvirt 11.3):
setup installed the control plane and built the head image in about six
minutes; `hpcod verify` passed; `hpcod selftest -compute 2` placed,
built and published a cluster in under four minutes, both compute nodes
came up idle in Slurm, `srun -N 2` ran on both, and the release left
nothing behind. PCI passthrough is tested only against device XML: the
test host has no card to pass.
Nothing changes for an existing Proxmox site. Checked offline: the
Proxmox environment plans byte-identical resources for the same cluster
before and after, and setup writes byte-identical configuration. Not yet
run against a real host or Proxmox.
### Bare metal: run on a real switch OS, and what it found
The `sonic` driver had been tested only against a fake. It has now been run
on SONiC 202505 (the VS image), with the simulated rack cabled behind it: a
cluster built through it (both machines network booted through the switch
and the trunk, `srun -N 2` answered from both), two machines cleaned at once
in its cleaning VLAN, and released. That run found four bugs, all fixed:
- **Ports were changed in a race.** Terraform makes a cluster's ports in
parallel, each by its own `hpcod` process, and a VLAN's first member is
read-then-write: both machines of the first cluster found its VLAN
missing, both added it, and the second failed the build. A release
deleting a VLAN as empty could race an assign the same way. The driver
now holds a lock on the switch around every change.
- **A cleaning cut off left a dirty machine looking free.** Moving a port
from the cluster's VLAN to the cleaning one is two switch changes; a
cleaning killed between them left the port in no VLAN, which is what a
free machine looks like - with the last tenant's data on its disks. A
cleaning now records its start before it touches anything, and a machine
is free only if its last cleaning finished and passed. The portal shows
such a machine as "cleaning interrupted", with Retry; a retry takes a port
in no VLAN as well as one in the cleaning VLAN. One cleaning of a machine
runs at a time, under a lock, which is also how a running cleaning is told
from one whose process died.
- **The portal declared another process's destroy dead.** At startup the
portal marks every build or destroy in flight as failed, on the grounds
that its process is gone - but `hpcod selftest` runs its own. A portal
restarted while a selftest destroyed a cluster marked it failed; the
selftest took that as the end, exited, and its destroy, two cleanings
included, was killed with it. Builds and destroys now hold a lock in the
cluster's directory, and the portal leaves a cluster alone whose lock
another process holds.
- **Setup left the trunk empty.** It wrote the uplink into `hpcod-switch`'s
configuration and did not apply it, so the trunk carried no VLAN - the
cleaning one included - until the first port change. Setup now applies it,
and checks the uplink carries the cleaning VLAN.
Also: `hpcod selftest -boot-timeout` (default 15m), for fabrics slower than
the image is big - the VS switch forwards in software at about 0.45 MB/s per
machine; `sonic.sh prepare ADDRESS` makes the VS image an L2 switch (it
boots as a router, every port addressed) and gives hpcod's key its login;
and `sonic.sh` no longer writes fixed names in `/tmp`, where an old file of
another user's stopped it.
### Bare metal: the machines file from NetBox
`hpcod netbox -url URL -site S -role R` writes a bare-metal site's
`machines.yaml` from NetBox: each machine's fabric MAC, the switch and
port its cable goes to, and its BMC (the `hpcod_bmc` custom field, else
its out-of-band IP), with size and login from optional custom fields. It
only reads; a read-only token is enough. Without `-write` it shows what it
would write and what changed.
It does not guess. The fabric switches are the ones the file names, or
`-switch`; a machine with no NIC, or several, cabled to one is an error,
as is one with no MAC or no BMC - and any error means nothing is written.
What NetBox does not hold (the switches section, sizes and logins without
a custom field) is kept from the file. A machine NetBox no longer lists is
kept and reported unless `-prune`. The file is checked before it replaces
the old one, which is kept as `.prev`, and is read back after.
Run against a real NetBox 4.7.5 holding the simulated rack: it reproduced
the hand-written file exactly, and corrected a drifted copy. That run
found one bug, fixed: a device NetBox lists but which could not be
imported was also reported as gone from NetBox, and with `-prune` as
removed.
### Portal: bare-metal machines, their cleanings, and a retry
The sites page lists a bare-metal site's machines with their state - free,
in use (and by which VLAN), cleaning, cleaning failed, unreachable and
why - and each one's last cleaning: when, at whose request, and each
disk's method and level. An administrator can retry a cleaning that
failed, and nothing else: the portal refuses a machine whose last
cleaning passed (a release may be cleaning it), one already being
retried, and the provider refuses, against the switch, one that is not
waiting in the cleaning VLAN. The retry runs in the background,
attributed to whoever pressed it.
Every cleaning now leaves a record, as NIST SP 800-88 asks: one JSON line
per cleaning in `/var/lib/hpcod/cleaning/<site>/<machine>.jsonl`, written
before the machine is freed - a cleaning whose record cannot be written
fails, and the machine stays held. A cleaning run by root by hand first
left the records directory root's, and the portal, which runs as the
service, showed every machine as never cleaned without saying why; setup
now makes the directory the service's, each cleaning sets every level it
creates, and the page says when a record cannot be read.
### Bare metal: several switches, delegated drivers, per-machine logins
The machines file can name the fabric switches (`switches:`), and each
machine its switch and port; one port cannot be given to two machines.
Besides linux-bridge and sonic, a switch can be driven by the site's own
automation: `exec` runs a program (`assign|clear|list SWITCH [PORT [VLAN]]`,
no shell between), `http` calls the same contract over REST with a bearer
token. A machine can have its own BMC login, its password an `env:` or
`file:` reference - a literal password in the file is refused. Setup pins
SSH-driven switches' host keys. Files without `switches:` read as before.
Checked on the simulated rack, with its machines moved to an exec switch
(`deploy/baremetal-sim/netauto-example`) and bm02 given its own login:
`hpcod selftest -compute 2` passed, both machines were cleaned through it,
and their disks read back as zero; a wrong password in bm02's file failed
bm02 alone, with 401, in `hpcod verify`. A program that reports success
without changing anything is caught by the read-back.
### Bare metal: machines are wiped before they are given again
Releasing a bare-metal cluster no longer frees its machines at once. Each
is powered off, moved to a cleaning VLAN (`BM_VLAN_BASE`+255) served only
by `hpcod-clean` on the KVM host, and network booted into a wipe image
built from that host's kernel. Every non-removable disk is purged with the
device's own command (NVMe sanitize or format with secure erase, ATA
sanitize or enhanced secure erase, SCSI sanitize), after removing an ATA
host protected area; a disk with none is overwritten whole and read back
whole, reported as clear rather than purge. Every disk is checked by
markers written with a one-time token at random places before the wipe,
none of which may be readable after. Only a complete report of that
cleaning, with every disk verified, frees the machine's port; anything
else leaves it powered off and held in the cleaning VLAN, and the
cluster's release fails. `hpcod baremetal clean` retries one.
The first version discarded each disk and zeroed its first and last
64 MiB. That freed a disk without discard - any HDD - with 128 MiB of it
wiped, and trusted discard, which a drive may not honour, for the rest; it
is gone, and `clean_mode: metadata` in an existing site entry is moved to
`purge` by setup. Testing the replacement found that its whole-disk
read-back used busybox `cmp -n`, whose count is 32-bit: every disk of
2 GiB or more failed the check (the machine was held, not freed). And the
image first loaded every driver it carries, which brought up `scsi_debug`
and wiped its fake disk; drivers are now loaded by modalias.
Checked on the simulated rack, with tenant data written at the start and
middle of each disk and checked from the host by qemu-io exit codes: a
machine with an NVMe disk (purged by format with secure erase), a SATA
disk and a virtio disk (both cleared by overwrite) was cleaned in 58 s,
the data gone from all three and their first GiB zero, and freed; with the
cleaning service stopped, `clean` gave up at its deadline and left the
machine off and held; a retry freed it; a report with another cleaning's
token is refused. An earlier check of `selftest` releases counted
qemu-io's "read" lines, which it prints whether or not the pattern
matched, so it proved nothing; rechecked by exit code, the two machines
those releases cleaned read as zero over all 2 GiB.
### A bare-metal backend
`SITE_KIND=baremetal` builds clusters whose compute nodes are physical
machines: servers with Redfish BMCs on one fabric, and a libvirt host
beside them for the heads. A compute node gets a whole machine, held in the
database (`cluster_machine`, migration 010) from the moment the cluster is
recorded, so two requests planned together cannot both be given it. Each
cluster has a VLAN; its head's and its machines' switch ports are put in it,
the machines are powered on through Redfish to network boot once from the
head when it is ready, and powered off before their ports are cleared when
it is released. Discovery reads the BMCs and the switch, and takes the
switch as the authority: a machine whose port is in a VLAN is held, and one
powered on in none is not offered. The head is built by the libvirt
module, with its fabric NIC on the host's VLAN-aware bridge.
Setup installs the switch driver (`hpcod-switch`, and a libvirt hook that
keeps a guest's port in its VLAN across restarts) on the KVM host, writes
the machines file from the BMCs when there is none, and keeps the BMC
password in `/etc/hpcod/env` rather than the world-readable `site.env`.
`deploy/baremetal-sim/setup.sh` makes a simulated rack on a libvirt host:
diskless guests, sushy-emulator as their BMCs, and a bridge as their
switch. See DEPLOY.md, "A rack of bare-metal machines".
Run end to end on that simulation (four machines, one too small for the
request): setup enrolled the machines from Redfish and installed the
switch driver; `hpcod verify` passed; `hpcod selftest -compute 2` placed
the head on the KVM host and one machine per node, powered them on through
Redfish, both came up idle in Slurm and `srun -N 2` ran on both, all
within about five minutes, and the release powered them off and cleared
every port. With two clusters up at once, a machine's traffic reached its
own head and not the other (tcpdump on both heads' ports while it network
booted), and a machine powered on behind hpcod's back, in no VLAN, reached
neither head; `hpcod baremetal power` refused to boot it, and discovery
reported it as not free. Only the linux-bridge switch driver exists, so a
physical switch is not yet supported; see Known limits.
The libvirt module gained the two options this needs (`fabric_bridge`,
`compute_vms`); for a libvirt site it plans the same resources as before,
checked with `tofu plan` against the host, apart from the fabric network's
address becoming `fabric[0]` - moved in state by a `moved` block - and the
head output's new `fabric_mac`.
## v0.2.2 — 2026-11-16
### Clusters across the nodes of a Proxmox cluster
A Proxmox VE that is one node of a Proxmox cluster no longer means one
node. Setup lists the cluster's nodes and asks which ones clusters may use
(`PVE_NODES`); the rest are never touched. Compute nodes are spread over
the chosen nodes. Heads stay on `PVE_NODE`, where the template is, so no
shared storage is needed. With more than one node the SDN zone becomes
`vxlan`, with every node a peer and an MTU of 1450 that guests are given
through virtio; setup remakes a `simple` zone only while no cluster uses
it, and `hpcod verify` checks the nodes and the zone. Before this, discovery
already saw every node and placement could pick any of them, while the
template, the snippets and a `simple` zone only worked on one: a cluster
could land where it could not be built.
Run on the simulated Proxmox with the zone forced to vxlan: a two-node
test cluster built and ran a job, both compute NICs came up at 1450, and a
full 1450-byte frame passed between them while 1451 did not. Traffic
between two real Proxmox nodes has not been tested; the lab has one.
### Also
- Setup's step list keeps to its columns on narrow terminals, and the
check says "1 warning", not "1 warnings".
- The documented install works on a fresh host: it now downloads the
release, checks `SHA256SUMS`, sets the execute bit and runs
`sudo ./hpcod setup`. Before, it said `sudo hpcod setup`, which is not
found until setup has installed itself.
- The documentation was brought in line with what is built: section 02
installs hpcod from scratch, and the hand-built lab moved to section 10.
## v0.2.1 — 2026-11-16
A rebuild of v0.2.0 with Go 1.27.4, for GO-2026-6859: a race in net/http's
MaxBytesReader that can crash an HTTP/1 server, which the portal is. The
v0.2.0 binaries were built with 1.27.3. Nothing else changes for anyone
running hpcod; x/crypto moves to v0.59.0 (GO-2026-5932, which hpcod does
not call), and CI takes the latest Go patch instead of a cached one.
## v0.2.0 — 2026-11-16
### One binary installs the control plane
Until now an installation was this one. The deploy scripts and the Ansible
defaults carried one installation's domain, hypervisor address, proxy host
and login account. The Proxmox side, the database and the Terraform
variables had been set up by hand. Deploying meant copying shell scripts
and a tree of roles beside the binary, and keeping all of them in step.
Now the binary is the whole of it:
- **`hpcod setup`** is the installer, for administrators only: root, in a
terminal on the control plane host. It is a full-screen TUI with the
stages of an install down the side. It asks first where clusters are
built, then signs in to Proxmox before asking anything else, with root's
password (used once, never stored) or tokens you made yourself. Nodes and
datastores are picked from what Proxmox has. Every field is checked as it
is typed, including against the others. Then it installs, showing each
step's output live, checks the result, and offers a test cluster.
- **`hpcod setup -yes`** runs the same steps unattended, from a site file.
`make deploy` copies the binary and `deploy/site.env` to the host and
runs it there. Nothing else is sent.
- **The binary carries the tree.** The Ansible roles, the Terraform module,
the schema and the application catalogue are embedded (`embed.go`). A
host always runs the roles and schema of the binary it runs. A test
checks that nothing local leaks into the embedded tree.
- **`hpcod verify`** checks each fact by using it: the tokens against the
API, the template by asking Proxmox, the database as the portal connects,
HTTPS against the installation's CA, DNS as a user's resolver would ask.
It reports READY, or which step fixes what failed.
- **`hpcod selftest`** builds the smallest real cluster by the portal's own
path (placement, allocation, the portal's builder). It waits for Slurm,
runs `srun` across the nodes, checks the portal is published, and takes
the cluster down. A failed test leaves the cluster up and prints how to
remove it.
### Closed networks
For an installation with no public domain, DNS or certificate:
- **Its own CA.** `SERVE_MODE=direct` makes hpcod serve HTTPS itself on
443, with a CA setup creates once. The CA is name-constrained to the
installation's domains, so trusting it trusts nothing else. The portal
issues its own server certificate from it in memory and renews it before
it expires. Users fetch the CA at `http://<portal>/ca.crt`.
- **Its own DNS.** `SERVE_DNS=true` answers for the portal and every
cluster's name, and forwards everything else. With no forwarders it
refuses, so it is never an open resolver.
### A simulated Proxmox, to try it
`PVE_MODE=sim` runs Proxmox VE in QEMU/KVM on the control plane host itself,
on a private bridge with NAT. Setup installs Proxmox VE into a Debian 13
cloud image and fills in every Proxmox and network value. Clusters run
inside it, so the host needs nested virtualization. It is for trying hpcod,
not for tenants.
### What was proven, and what was not
- **End to end, on a simulated Proxmox** (a control plane VM on a real
Proxmox host, with Proxmox VE 9 inside it):
- the install, from the single binary;
- the Proxmox step by the root-password path: SSH key, both tokens, the
SDN zone, the content types, the cloud image;
- the head template (47 tasks, none failed);
- `hpcod verify` READY, with HTTPS from its own CA and its own DNS;
- `hpcod selftest`: `c001` built in about ten minutes, its compute node
idle in Slurm, `srun hostname` answered from it, then destroyed and
released.
- **On a clean Debian 13 host:** the install twice in a row, with nothing
changed the second time. The generated password signs in, and the TUI was
driven through a terminal.
- **Not yet run:**
- setup against a bare-metal Proxmox host;
- the token path, which was tested only against a fake Proxmox API;
- a fresh simulated Proxmox with the last two fixes to it (resolv.conf,
and a clean power-down). Both were verified on the running simulation
only.
### Changes an existing installation should know about
- The Proxmox token moves from `site.auto.tfvars` to `secrets.auto.tfvars`.
Setup moves it the first time and keeps a backup.
- `ci_user` and the portal's `-ssh-user` no longer default to a personal
account. Setup writes both from `CI_USER`.
- `ansible/group_vars/all.yml` is now `group_vars/all/main.yml`. The site's
values are in a generated `site.yml` beside it, and the playbooks refuse
to run without it. The head template only picks them up when it is
rebuilt (`-rebuild-template`). Until then, setup and verify say it is
stale.
- The catalogue now comes from inside the binary. Publishing an application
means rebuilding and deploying the binary. A site that keeps its own
catalogue creates `/etc/hpcod/apps.local`.
- Removed: `scripts/B10`, `B20` and `C20`. Their work is the setup steps.
`/var/lib/hpcod/scripts` on an existing host is no longer used.
## v0.1.0 — 2026-09-21
First tagged release. The repository holds two things: the Warewulf HPC lab
documented in sections 01–09, and **HPC-on-Demand** (`hpcod/`), a control
plane that provisions clusters of that kind on demand. This release is about
the second.
### The chain that works end to end
Someone signs up on the public site, an administrator approves them, and from
there the portal takes a request for a cluster through to a running desktop
with a job on it. Every step below was exercised on `hv01`, not inferred:
1. **Sign up, and wait.** New accounts land in `pending`; nobody gets in until
an administrator approves them. Disabling an account takes effect on the
next request, not when the session happens to expire.
2. **Ask for hardware, not for a flavour.** A request names capabilities —
GPU, InfiniBand, RoCE, NVMe, cores, memory — or just names the software it
wants and lets the application catalogue imply the hardware.
3. **Placement picks a site and a node.** Devices already handed to another
cluster are not offered again, and neither are devices reserved for a
cluster that has been allocated but not yet built. Oversubscription is a
policy an operator sets from the portal, with separate CPU and memory
ratios; turning it off does not lose them.
4. **Allocation is atomic.** Cluster ids, management addresses and PCI devices
come from PostgreSQL under an advisory lock, so two requests racing for the
last GPU produce one cluster and one clear refusal.
5. **Terraform builds it.** An SDN vnet for the cluster fabric, a head node and
compute VMs, with the placement carried straight through from the record.
Teardown removes them in an order that actually works.
6. **Ansible finishes it.** Warewulf 4.7, OpenHPC 3, Slurm 25.11, MUNGE,
Apptainer, shared `/opt/apps`, and Open OnDemand on the head node.
7. **The cluster publishes itself.** It appears at
`c<NNN>.<domain>`, behind the control plane, with the portal's certificate
pinned at the moment it was published.
8. **One sign-in, not two.** The cluster portal trusts the control plane over
mTLS, so a session that may use a cluster reaches it without another
password. A session that may not gets nothing, and a hostname for a cluster
that does not exist says so instead of showing the front page.
9. **A desktop, a terminal, and a job.** XFCE over TurboVNC in a container, a
shell on the head node, and `srun` from inside either.
### Measured
- Cold provision of a tenant cluster: **~134 s**.
- Node image build: ~12 min, done once and shared, not per tenant.
### Known limits
These are absent by decision or by circumstance, not by oversight:
- **Leases are recorded but not enforced.** `store.Expired` returns what has
run out; nothing acts on it yet. No reaper.
- **One Proxmox node.** Placement discriminates between sites and between
hosts, and the Terraform module takes a per-VM host — but `hv01` is a single
node, so multi-site placement is tested against fixtures rather than metal.
- **No central Slurm accounting.** There is no `slurmdbd`, so jobs carry no
cluster name and `sacct` history is per-cluster.
- **Whole-device GPU passthrough only.** MIG and vGPU are out of scope.
- **`/home` only.** No scratch, no parallel filesystem.
- **Nothing bills.** The allocation record is the raw material for it and is
written; no code reads it for that purpose.
- **The API in §20.9 is partly implemented.** The portal and CLI cover what is
built; the REST surface does not yet.
### Operating notes
- `hpcod version` now reports the release tag alongside the revision, e.g.
`v0.1.0 (f6ea30dc1234)`. A binary built outside the Makefile prints the
revision alone rather than guessing.
- The control plane needs `$HPCOD_DB_DSN` or `-db`; the CLI and the service
resolve it the same way.
- `make deploy-portal` builds for Linux and installs it on the Caddy host.