Skip to content

fix(swm-macos-runner): end an idle runner when an update is pending - #293

Merged
smartwatermelon-agent[bot] merged 1 commit into
mainfrom
claude/fix-swm-idle-update-0ff2a5bc
Nov 19, 2026
Merged

smartwatermelon-agent[bot] merged 1 commit into
mainfrom
claude/fix-swm-idle-update-0ff2a5bc

Conversation

@smartwatermelon-agent

Copy link
Copy Markdown
Contributor

Why

The updater installs new runner code only when the slot says job=0. A JIT runner that waits for a job also holds job=1. On a quiet repo a merged fix stayed in update-pending, and nothing alerted. A human had to start a job to free the slot.

What

  • Idle runner gives way. While run_job waits on the guest, bounded calls bounded_check every SWM_UPDATE_IDLE_CHECK_S (300 s). When update-pending exists, it deletes the runner registration first. Only a 2xx ends the VM. The pass is neutral, and the next pass's update_wait lets update.sh install.
  • Busy runner keeps its job. A 422 (GitHub refuses to delete a busy runner), an API failure or a 404 keeps the wait as today. Both outcomes are logged. A pass whose update_wait gave up never ends runners, so an update that keeps failing to install does not starve the runner.
  • Backstop alert. update-pending now holds the epoch when it was first written. When it is older than SWM_UPDATE_PENDING_ALERT_S (6 h), update.sh sends one ntfy alert. The alert marker goes away with update-pending. install.sh passes that one knob into the updater plist.

Evidence that GitHub refuses to delete a busy runner

  • The REST docs for "Delete a self-hosted runner from an organization" say only "Forces the removal..." and list 204 and a generic 422. They say nothing about busy runners.
  • GitHub's actions-runner-controller (controllers/actions.summerwind.net/runner_graceful_stop.go) says: "RemoveRunner already has an ability to prevent stopping a busy runner". It quotes 422 Bad request - Runner "..." is still running a job and sets runnerBusy = errRes.Response.StatusCode == 422.

So the guard depends on API behavior that ARC relies on. It is not a documented contract.

Tests

bash scripts/swm-macos-runner/tests/run-tests.sh: 501 PASS, 0 FAIL. New cases cover idle end and the next pass waiting, a busy 422, a 404, no pending marker, a pass whose update_wait gave up, and the backstop (threshold, once only, cleared with the marker, failed delivery, env limit, old empty marker).

Advances #252

The updater installs only when the slot says job=0. A JIT runner that
waits for a job also holds job=1, so on a quiet repo a merged fix sat
in update-pending and nothing alerted. A human had to start a job to
free the slot.

While run_job waits on the guest, bounded now calls bounded_check every
SWM_UPDATE_IDLE_CHECK_S (300 s). With update-pending present, the check
deletes the runner registration first. Only when the DELETE returns 2xx
does it end the VM. The pass then counts as neutral, and the next pass's
update_wait lets update.sh install. A refused DELETE (422 while the
runner runs a job, or an API failure) keeps the job wait as before. So
does a 404, because GitHub also answers 404 when access is missing; a
runner that really left ends its guest by itself. Both outcomes are
logged. SWM_UPDATE_IDLE_CHECK_S=0 turns the check off. A pass
whose update_wait gave up does not end runners, so an update that keeps
failing to install cannot stop every runner from taking a job.

Backstop: update.sh writes the first-seen epoch into update-pending and
no longer rewrites it on each waiting pass. When the marker is older
than SWM_UPDATE_PENDING_ALERT_S (21600 s), it sends one "an update has
been pending" alert. The alert marker goes away with update-pending.
install.sh also passes that one knob into the updater plist.

GitHub evidence for "a busy runner cannot be deleted":
- REST docs, "Delete a self-hosted runner from an organization"
  (docs.github.com/en/rest/actions/self-hosted-runners): "Forces the
  removal of a self-hosted runner from an organization." Responses:
  204, and 422 "Validation failed, or the endpoint has been spammed."
  The docs say nothing about busy runners.
- GitHub's actions-runner-controller,
  controllers/actions.summerwind.net/runner_graceful_stop.go (master),
  has this comment: "we learned that RemoveRunner already has an ability
  to prevent stopping a busy runner" and "Trying to remove a busy runner
  can result in errors like the following: ... 422 Bad request - Runner
  "example-runnerset-0" is still running a job". It also sets
  runnerBusy = errRes.Response.StatusCode == 422.
So the guard depends on observed API behavior that ARC relies on. It is
not a documented contract.

Advances #252
@smartwatermelon-agent
smartwatermelon-agent Bot merged commit 593a730 into main Nov 19, 2026
6 checks passed
@smartwatermelon-agent
smartwatermelon-agent Bot deleted the claude/fix-swm-idle-update-0ff2a5bc branch November 19, 2026 00:30
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.

0 participants