Skip to content

feat: approve live installs explicitly and pull the toolkit system-uri through install-registry - #20

Draft
wgkingk wants to merge 7 commits into
1.9.1-alauda-4.6from
feat/pxe-install
Draft

wgkingk wants to merge 7 commits into
1.9.1-alauda-4.6from
feat/pxe-install

Conversation

@wgkingk

@wgkingk wgkingk commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Draft: test version, not to be merged for now (see the end).

Target branch: 1.9.1-alauda-4.5-pxe, the maintenance branch for bare-metal network installs (PXE / UEFI HTTP Boot) on the ACP 4.5 line, cut from 1.9.1-alauda-4.5 at 059221bc. It is not merged back into 1.9.1-alauda-4.5 for now.

Design: cluster-management-docs docs/baremetal-pxe/ (02 D4 install approval, D5 install from system-uri; 04 F1–F5).

A network-booted host runs the same live system as the ISO, but its install should write the product OS image to disk, not the live system, and it should only start once a person has prepared everything. Two gaps stood in the way:

  • The toolkit backend ignored install-registry: no credentials, a logical cpaas-registry.cpaas-system address no host resolves, a pull that only fails after the disk was partitioned, and the live system on the recovery partition.
  • In inventory mode, picking the disk released the install at the next registration, so spec.network had to be in the same patch and a wrong pick could not be taken back.

What

  • 9fc83f7b feat(install): toolkit installs pull install.system-uri through install-registry.
    • Credentials go to /run/elemental/registry-docker (0700, config.json 0600). elemental install runs with DOCKER_CONFIG pointing there, and the directory is removed once it returns.
    • A real-registry system-uri is kept as it is. One under the logical registry is rewritten to the first endpoint that serves the image.
    • The image is checked with a manifest HEAD before any disk is touched: HTTPS without certificate verification, HTTP fallback, Bearer or Basic auth. This is plain net/http, so go-containerregistry is not added to vendor.
    • --tls-verify=false is passed, and ELEMENTAL_INSTALL_RECOVERY_SYSTEM is set to the same image whenever there is a system-uri.
    • New protocol level MsgToolkitInstallRegistry (19). It is a capability marker only and never sent as a message.
  • 80f142eb feat(server): explicit install approval.
    • baremetal.alauda.io/install-approved: "true" releases the install with what the MachineInventory holds at that moment. It is one-shot and holds for the current live boot. It is discarded (ApprovalDiscarded) when it was set before the boot registered, is not "true", comes without a selection, or the selected disk cannot be used.
    • install-target-device only selects the disk and stays across live boots. A host that has a selection but no approval waits with AwaitingApproval.
    • MachineInventory.spec.install.system-uri overrides the registration's value.
    • The inventory's cpaas.io/registry-reference label overrides the registration's.
    • Old live registers are not released to a toolkit install from a system-uri (LiveTooOld, also written to status.install.message). KubeOS is not affected.
  • 2979a7f4 fix(server): a selection by an unidentified: ID, which names a disk by its kernel path in one boot, is discarded when the live ISO boots again (SelectionDiscarded).
  • 842a21fa fix(server): an installed system's registration removes the selection even when the install already reported itself Installed (found on KVM: the selection stayed after a normal install).
  • 5fdb9683 fix(server): the registry mirror input of system-uri is resolved before the approval is consumed, and the release sends what it resolved (found on KVM: input missing an endpoint's credentials failed the release configuration after the approval was gone, and the inventory did not say why).
    • Input that cannot be used, or a logical system-uri with no mirror input, discards the approval and holds the host with the new reason RegistryInputInvalid and the cause on InstallTargetReady. The selection stays; the install is approved again once the input is fixed.
    • A transient API error keeps the approval and holds the host for a 5-second retry.
  • 228a6841 feat(install): without install-registry (a platform that does not pull through a mirror), the system-uri is pulled anonymously, also without certificate verification and after the same check.
  • CRD regenerated with controller-gen v0.19.0: MachineInventory spec.install, and the MachineRegistration device-selection description.

Testing

GOFLAGS=-mod=mod, envtest assets from the provider's bin/k8s/1.32.0-linux-amd64:

ok  pkg/elementalcli  ok pkg/install  ok pkg/server  ok pkg/registryaccess
ok  api/v1beta1       ok controllers  ok cmd/register  ok cmd/operator/operator
FAIL pkg/register: 61 Passed | 3 Failed (the 3 auth=mac specs, same on 059221bc: no NIC MAC in this container)

New and updated cases:

  • pkg/install: a fake registry with a token service, Basic auth or none, over HTTPS and HTTP. Covered: system-uri forms with and without docker: / docker://, logical rewrite with failover, every endpoint failing, wrong credentials, no install-registry. Each failure case asserts that no disk was touched and no install ran. Also covered: credential permissions, cleanup after success and after an install failure, and reference parsing.
  • pkg/elementalcli: RECOVERY_SYSTEM, DOCKER_CONFIG, --tls-verify=false.
  • pkg/server:
    • Approval: a stale approval, a value other than "true", an approval without a selection, an invalid selection, a conflict while consuming or discarding, and templates or hosts trying to set it.
    • Stable vs unidentified: selections across boots.
    • Release takes the values at approval time (spec.install, spec.network, label).
    • Registry input checked before the release: a credential that does not exist, an endpoint without credentials, a logical system-uri without mirror input (each RegistryInputInvalid, approval discarded, selection kept, released after the fix and a new approval), and a transient read error (approval kept, 5-second retry).
    • Two hosts on different registries, and the template-label pitfall.
    • Old vs new clients in inventory and legacy mode, KubeOS unaffected.
    • Existing tests rewritten for the approval flow.

Tested on KVM on 2026-11-25 with network-booted hosts (iPXE), a Global running the provider test build (acp/cluster-api-provider-baremetal!71) and an M55 image whose register is built from this branch: approval flow, old-client protection, toolkit pull through install-registry (real address and logical prefix with failover, inventory label override), recovery from the same image, spec.network (single NIC, bond), boot from disk afterwards, and a node joining a cluster. Re-tested with 5fdb9683: an inventory label naming a missing credential, and credentials missing the first endpoint, each held the host with RegistryInputInvalid and the cause, discarded the approval and kept the selection, with the disk untouched; after the fix a new approval installed the host.

Other halves

  • provider: acp/cluster-api-provider-baremetal!70 (Draft, into pxe-4.5). Its webhook validates the approval (and requires machineinventories/installtarget), spec.network and spec.install. It also pins and syncs the CRD.
  • os-build: re-pin the register and build an M55 image from this branch for network installs.

Not to be merged for now. The pxe-4.5 line uses this PR's head as a test version: the provider pins the head (now 5fdb9683) directly, and the image build fetches it by SHA. Push new commits here and re-pin the provider; do not merge until that is decided.

🤖 Generated with Claude Code

wgkingk and others added 4 commits November 24, 2026 16:01
The operator sends install-registry (the logical registry, its real
endpoints and their credentials) with every install that pulls a
system-uri, but only the KubeOS backend used it. The toolkit backend
handed the system-uri to elemental install as it was: no credentials, a
logical cpaas-registry.cpaas-system address no host resolves, and a pull
that only fails after the disk was partitioned. The recovery partition
also got the live system, since the toolkit sets the recovery source
before it reads the environment.

With install-registry, the toolkit install now:

- writes the dockerconfigjson to /run/elemental/registry-docker (0700,
  config.json 0600) and runs elemental install with DOCKER_CONFIG there,
  since go-containerregistry does not read registries.conf;
- keeps a system-uri that names a real registry, and rewrites one under
  the logical registry to the first endpoint that serves the image;
- checks the image with a manifest HEAD (HTTPS without certificate
  verification, plain HTTP when HTTPS cannot be spoken, Bearer or Basic
  authentication) before any disk is touched;
- passes --tls-verify=false, as install-registry endpoints are never
  verified;
- removes the credentials once elemental install returns.

elemental install also gets ELEMENTAL_INSTALL_RECOVERY_SYSTEM equal to
the system-uri whenever one is set, so the toolkit snapshots the
installed system for recovery instead of copying the live system.

The register declares the new protocol level MsgToolkitInstallRegistry
(19, never sent as a message) so the operator can tell it from a register
that would partition first.

Without install-registry nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Picking the install disk released the install at the next registration,
so spec.network had to be written in the same patch, a wrong pick could
not be taken back, and nothing said "ready to install". The disk, the
installed network and the system image are now prepared first and the
install is released by an approval:

- baremetal.alauda.io/install-target-device only selects the disk. It
  stays across live boots and is checked against the disks of the boot
  the install is approved in; it is removed once the installed system
  registers.
- baremetal.alauda.io/install-approved: "true" releases the install with
  what the MachineInventory holds at that moment. It is one-shot: it is
  consumed by the release and discarded (ApprovalDiscarded) when it was
  set before this live boot registered, is not "true", comes without a
  selection, or the selected disk cannot be installed to; the selection
  then stays. A discard that runs into a concurrent change still removes
  it. Templates and hosts cannot set it.
- A host with a selection and no approval waits with InstallTargetReady
  reason AwaitingApproval and says which disk is selected, or why it
  will not do.

This applies to every inventory-mode registration, optical media too.

MachineInventory gets spec.install with system-uri: it overrides the
registration's install.system-uri for that host. The
cpaas.io/registry-reference label of the MachineInventory, when present,
selects the install's registry credentials over the registration's.

An install from a system-uri by the toolkit is not released to a live
system whose register predates MsgToolkitInstallRegistry: such a register
ignores install-registry and its toolkit partitions before it pulls. The
host is held (LiveTooOld, also in status.install.message) and an
approval is discarded; a legacy-mode client that cannot be held gets an
error instead. KubeOS installs are not affected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…again

A selection now stays across live boots, but an unidentified: ID names a
disk by its kernel path in the live boot that reported it: after a
reboot the same ID may name another disk, and an approval would then
install to it. When a new live boot registers, such a selection is
discarded (InstallTargetReady reason SelectionDiscarded, event
SelectionDiscarded) together with any approval, and the host waits for
a disk to be picked again. Selections by stable IDs (wwn:, nvme-eui:,
nvme-nguid:, serial:) still carry over.

The discard retries on conflicts like the approval's, so the next
registration of the boot never sees the stale selection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A system-uri was checked and pulled without certificate verification
only through install-registry. On a platform that does not pull through
a mirror the operator sends none, and the toolkit then pulled with
certificate verification and no check beforehand: a registry with a
self-signed certificate failed the install after the disk was
partitioned.

Without install-registry the toolkit install now pulls the system-uri
as written, anonymously, with --tls-verify=false, after the same
manifest check before any disk is touched. A system-uri under the
logical registry cannot be reached that way and fails the install
before the disk is touched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wgkingk
wgkingk marked this pull request as draft November 25, 2026 02:23
wgkingk and others added 2 commits November 25, 2026 11:33
…sters

The release no longer consumes the install-target selection, so it must
go when the installed system registers. settleInstall only did that for
an install it still had to settle (Installing, Failed, or a wait in the
live ISO). The usual end of an install is different: the host reports
the install Installed before it reboots, and the installed system then
registers with nothing left to settle. The selection stayed on the
MachineInventory.

Found on KVM with a network-booted host: after the install the installed
system registered from its static address and the selection was still
there.

An installed system's registration (one with registration state) now
removes the selection and any approval whatever the install phase;
status is only settled as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The approval was consumed before the release configuration resolved the
registry mirror input of install.system-uri. Input that could not be used
then failed the configuration: the approval was gone and the inventory
only showed that the install did not complete, with the cause in the
host's log.

The release now resolves the input first and sends what it resolved.
Input that is missing or does not validate, or a system-uri under the
logical registry with no mirror input, discards the approval and holds
the host with RegistryInputInvalid and the cause on InstallTargetReady;
the selection stays. A transient API error keeps the approval and holds
the host for a short retry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wgkingk
wgkingk changed the base branch from 1.9.1-alauda-4.5-pxe to 1.9.1-alauda-4.6 November 27, 2026 08:14
@wgkingk wgkingk closed this Nov 27, 2026
@wgkingk wgkingk reopened this Nov 27, 2026
Brings in #21 (restore the go-tpm-tools sources the TPM simulator needs)
via #22, so the cgo unit tests compile on this branch too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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