Skip to content

feat(role): size a Colima node VM from the inventory through the quorum guard - #212

Merged
Mearman merged 5 commits into
mainfrom
feat/colima-vm-size
Nov 3, 2026
Merged

Mearman merged 5 commits into
mainfrom
feat/colima-vm-size

Conversation

@Mearman

@Mearman Mearman commented Nov 3, 2026

Copy link
Copy Markdown
Member

Closes #208

A Colima host's VM memory and CPUs now come from the inventory and are applied through the quorum guard, one node at a time: check the cluster stays safe without the node, take the fleet-regrade Lease (refused while another step holds it), cordon, wait for runner pods, drain, check again, colima stop, colima start --activate=false --memory <GiB> --cpus <n>, wait for Ready (and an etcd voter on a server), uncordon, give the Lease back. A VM already at the wanted size is only read, --check reports and changes nothing, and a host whose runtime is not Colima is left alone.

The memory is either set (github_runner_cluster_colima_memory_gib) or derived from what the host must keep: host memory less github_runner_cluster_colima_memory_reserved_gib (other workloads) and github_runner_cluster_colima_memory_host_reserve_gib (macOS), rounded down to a whole GiB, never below the node floor of github_runner_cluster_colima_guest_baseline_gib plus github_runner_cluster_colima_runner_memory_limit_gib rounded up. A derivation below the floor is sized at the floor with a warning. The runner limit is a variable because the cluster role does not install the runners; a derivation requires it.

The size is fixed at provisioning time rather than ballooned at runtime for the reason in the issue: the node VM's balloon device does not offer free page reporting, so a balloon cannot give memory back to macOS.

tests/unit/test_cluster_colima_size.py runs the role against stand-ins for docker and colima and covers the argv, the no-op when sizes match, a held Lease, the drain order, an unhealthy or not-Ready voter, check mode, the derivation, the clamp and its warning, and the non-Colima no-op. Each rule's test was seen failing with that rule broken on purpose. A real VM's resize is shown only by its first run on a Mac.

The checks that refuse to recreate a node on the other network unless
the cluster stays safe without it move to tasks/restart_guard.yml, so
any step that restarts a running node uses the same reads and refusal.
The step says what it does in the refusal, and whether runner pods on
the node block it: a step that cordons the node and waits for them
itself checks the cluster before that with the pods left out.
…um guard

github_runner_cluster_colima_memory_gib and github_runner_cluster_colima_cpus
set a Colima host's VM size; empty keeps the profile's own. The role
reads the VM Lima runs with colima list --json, and when a size differs
it resizes one host at a time, each in its own turn: it checks the
cluster stays safe without the node, takes the fleet-regrade Lease
(refusing while another step holds it), cordons the node, waits for its
runner pods and drains it, checks the cluster again, stops the profile,
starts it with --memory and --cpus, waits for the node to be Ready (and
an etcd voter on a server), uncordons it and gives the Lease back.

A value that is not a positive whole number, or a size set on a host
that does not run Colima, fails before anything is read. A VM of the
size set is only read, so a rerun changes nothing, and --check reports
the resize and changes nothing. The native role switch's drain and
Ready wait are reused, the drain's refusal naming the step it serves.

Closes #208
…keep

github_runner_cluster_colima_memory_reserved_gib, the memory a host's
other workloads need, derives the VM's memory when no memory is set: the
host's memory (memtotal_mb) less it and
github_runner_cluster_colima_memory_host_reserve_gib, macOS's own,
rounded down to a whole GiB, since colima takes whole GiB and rounding
up would take memory a reserve keeps.

The VM is never smaller than the node floor: the guest's baseline,
github_runner_cluster_colima_guest_baseline_gib, plus one runner pod's
memory limit, github_runner_cluster_colima_runner_memory_limit_gib,
rounded up to a whole GiB. The cluster role does not install the
runners, so it is told that limit, and a derivation without it fails
before the VM is read. A derivation below the floor is sized at the
floor, and the run prints a warning that the host keeps less than its
reserves. A memory set explicitly wins, and with neither declared the
profile is left as it is.

A host whose runtime is not Colima is now left alone instead of failing,
so the sizes and reserves can be set for a group that mixes runtimes.
The host's memory is read from the hardware facts only when a derivation
needs it and the caller did not gather them.
… derived defaults

github_runner_cluster_native_drain_for is what tasks/native/drain.yml says
was not done when it cannot empty the node, set by each caller and never
by the inventory, so it is derived like the native units' names: the
defaults test now lists it, and the README describes it with them.
…aults

The runtime tasks' guard test holds every ansible_facts read in the
defaults to the subsets runtime.yml gathers. The reserve's comment named
the memory fact in that form, though only tasks/colima_size.yml reads it,
after gathering the hardware subset itself, so the comment now names the
fact and the task that gathers it.
@Mearman
Mearman marked this pull request as ready for review November 3, 2026 23:31
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ⚠️ Failed 2026-11-03T23:31:55.144855Z
We couldn’t complete this review. Comment @codex security review to try again.
e40622d Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins.

@Mearman
Mearman merged commit 52d0d47 into main Nov 3, 2026
33 checks passed
@Mearman
Mearman deleted the feat/colima-vm-size branch November 3, 2026 23:32
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.35.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cluster: set a Colima node VM's memory and CPUs from inventory, applied through the quorum guard

1 participant