Skip to content

ci(test): make macOS k3s reliable by fixing the colima timeout budget - #2936

Merged
Erik Osterman (Cloud Posse) (osterman) merged 4 commits into
cloudposse:mainfrom
arcaven:fix/macos-k3s-colima-reliability
Aug 14, 2026
Merged

Erik Osterman (Cloud Posse) (osterman) merged 4 commits into
cloudposse:mainfrom
arcaven:fix/macos-k3s-colima-reliability

Conversation

@arcaven

@arcaven Michael Pursifull (arcaven) commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Why

[k3s-macos] is a required check (via [k3s] demo-helmfile) and flakes on unrelated PRs, costing the full step budget each time and blocking merge. The failure is entirely in CI setup: the job dies at "Start Docker-compatible runtime on macOS" without running a single helm test. Closes #2935.

What

The colima setup ladder was longer than the step cap that contained it, so the step was guillotined before the ladder could finish, and a status-propagation bug hid which rung actually failed. This PR makes the ladder shorter than its cap instead of growing the cap:

  • vz only; the qemu fallback is removed. docs/fixes/2026-07-01-macos-k3s-runner-research.md already selected vz for macos-15-intel and records qemu failing there on usernet unable to resolve IP for SSH forwarding before any test ran, and a green run (31723563772) confirms vz starting on attempt 1 with the whole setup step under 6 minutes. The qemu rung (plus its 7-minute brew install qemu cap) was a dead rung that only added minutes to the failure path. Two bounded vz attempts remain as the half-started-VM mitigation.
  • Fix failure propagation in start_colima. status=$? ran after the completed if, which reads the if statement's own zero when no branch executes, so the function returned success after every attempt had failed and the job died later at docker version with a misleading error. The status is now captured in the else branch.
  • docker pull rancher/k3s:latest moves out of the start/retry loop and retries on its own (two independent 5-minute attempts). In the loop, a slow or rate-limited Docker Hub pull counted as a runtime-start failure and forced a full VM delete + rebuild, so registry flakiness masqueraded as hypervisor flakiness.
  • Diagnostics are kept after every failed attempt, including the last, and bounded (colima status and limactl list capped at 30s so they cannot hang the step). Teardown and backoff run only between attempts; after the final failure the runner is discarded, so cleanup is dead time.
  • Step cap 40 minutes; the job-level 60-minute cap is unchanged, preserving fail-fast behavior; the observed healthy setup leaves ample time for both 15-minute test attempts.

Timeout arithmetic

Caps on the setup path: brew installs 7m + initial cleanup 1.5m + two vz start/info attempts 10m each + bounded diagnostics and intermediate cleanup ~3m + docker verify 1m + two 5-minute pull attempts with backoff. Every cap hit simultaneously sums to ~43 minutes; the 40-minute cap deliberately undercuts that. The recovery path fits when the final image pull completes normally; anything past 40 is treated as pathological. The observed healthy path is under 6 minutes.

Cost of merge

CI-only; no product code changes. The failure mode changes shape: instead of a slow crawl through a dead qemu rung, a runner where vz cannot start now fails hard after two bounded attempts, with diagnostics captured both times.

Out of scope (raised in #2935)

Pinning the k3s image would need a change to pkg/emulator/driver/k3s.go (the ref is hardcoded there), so this PR keeps :latest to stay CI-only. And macos-15-intel is on GitHub's deprecation path; a longer-term plan for [k3s-macos] is noted in the issue.

The [k3s-macos] jobs cap "Start Docker-compatible runtime on macOS" at 45
minutes, but the setup-colima fallback ladder needs longer. It tries vz
twice (each up to 480s start + 120s info + 600s k3s pull), so ~40 minutes
goes to vz before qemu is attempted; the 45-minute cap then fires during
the second vz retry and the qemu fallback (the runtime that actually comes
up on the Intel runner) never runs. Every failure costs the full 45
minutes with zero helm tests executed.

- Move `docker pull rancher/k3s:latest` out of the colima start/retry loop
  and pull it once after the runtime verifies. In the loop, a slow or
  rate-limited Docker Hub pull counted as a runtime-start failure and
  forced a full VM delete + rebuild, so registry flakiness masqueraded as
  hypervisor flakiness. It also shortens each start attempt by up to 600s.
  The ref still matches the emulator (pkg/emulator/driver/k3s.go).
- Raise the colima step timeout from 45 to 60 minutes so the vz -> qemu
  fallback ladder can finish.

CI-only; no product code changes.
@arcaven
Michael Pursifull (arcaven) requested a review from a team as a code owner August 13, 2026 17:09
@atmos-pro

atmos-pro Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@github-actions github-actions Bot added the size/s Small size PR label Aug 13, 2026
@mergify

mergify Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Important

Cloud Posse Engineering Team Review Required

This pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes.

To expedite this process, reach out to us on Slack in the #pr-reviews channel.

@mergify mergify Bot added the needs-cloudposse Needs Cloud Posse assistance label Aug 13, 2026
…er fits its cap

The 60-minute step cap still did not cover the worst-case ladder (brew
installs, two vz attempts, two qemu attempts, teardowns, verify, pull:
roughly 79 minutes of caps), and it equaled the job-level 60-minute
budget, leaving no time for the k3s tests themselves. Shrink the ladder
instead of growing the cap:

- Go straight to qemu on x86_64: vz cannot come up on the Intel runners
  this job targets (the matrix uses macos-15-intel precisely because
  M-series runners lack the virtualization path), so the two vz attempts
  were ~27 minutes of guaranteed waste per failure.
- Retry the relocated k3s pull (3 attempts): moving it out of the start
  loop removed its only retry, so one transient registry failure would
  have failed the job after a successful VM start.
- Set the step cap to 35 minutes: a realistic qemu-only pass is 10-15
  minutes, 35 gives 2x headroom, and the remaining job budget stays
  available for the tests.
…us propagation

A green [k3s-macos] run (31723563772) shows vz starting on attempt 1 on
macos-15-intel with the whole setup step under 6 minutes, and
docs/fixes/2026-07-01-macos-k3s-runner-research.md records qemu failing
there on usernet SSH forwarding before any test ran. So the previous
commit had the ladder backwards: it forced qemu, the rung that never
came up, on the runner where vz is the proven runtime.

- Remove the uname -m selection, the qemu rung, and its brew install;
  keep two bounded vz attempts.
- Fix failure propagation: status was captured after the completed if,
  which reads the if statement's own zero when no branch runs, so
  start_colima returned success after every attempt failed and the job
  died later at docker version with a misleading error. Capture in the
  else branch instead.
- Keep diagnostics after both failures, bounded (colima status and
  limactl list capped at 30s); skip teardown and sleep after the final
  attempt since the runner is discarded anyway.
- Pull: two independently retried 5-minute attempts.
- Step cap 40 minutes, job cap stays 60. Every cap hit simultaneously
  sums to ~43m; 40 deliberately undercuts that, while a pass surviving
  one full attempt timeout plus a full retry plus one failed pull (~33m)
  still fits.
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.98%. Comparing base (6c44717) to head (8415308).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2936   +/-   ##
=======================================
  Coverage   82.98%   82.98%           
=======================================
  Files        1881     1881           
  Lines      183067   183067           
=======================================
+ Hits       151925   151927    +2     
- Misses      23317    23319    +2     
+ Partials     7825     7821    -4     
Flag Coverage Δ
unittests 82.98% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@osterman Erik Osterman (Cloud Posse) (osterman) added the no-release Do not create a new release (wait for additional code changes) label Aug 14, 2026
@atmos-pro

atmos-pro Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

Merged via the queue into cloudposse:main with commit 15ec317 Aug 14, 2026
90 of 91 checks passed
@atmos-pro

atmos-pro Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@mergify mergify Bot removed the needs-cloudposse Needs Cloud Posse assistance label Aug 14, 2026
@github-actions

Copy link
Copy Markdown

These changes were released in v1.226.0-rc.8.

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

Labels

no-release Do not create a new release (wait for additional code changes) size/s Small size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[k3s-macos] CI: colima setup times out at 45m before the qemu fallback runs, blocking PRs

2 participants