Repository navigation
fix(swm-macos-runner): end an idle runner when an update is pending - #293
Merged
smartwatermelon-agent[bot] merged 1 commit intoNov 19, 2026
Merged
Conversation
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
Bot
requested a review
from twistedmelonman
as a code owner
November 19, 2026 00:22
smartwatermelon-agent
Bot
deleted the
claude/fix-swm-idle-update-0ff2a5bc
branch
November 19, 2026 00:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The updater installs new runner code only when the slot says
job=0. A JIT runner that waits for a job also holdsjob=1. On a quiet repo a merged fix stayed inupdate-pending, and nothing alerted. A human had to start a job to free the slot.What
run_jobwaits on the guest,boundedcallsbounded_checkeverySWM_UPDATE_IDLE_CHECK_S(300 s). Whenupdate-pendingexists, it deletes the runner registration first. Only a 2xx ends the VM. The pass is neutral, and the next pass'supdate_waitletsupdate.shinstall.update_waitgave up never ends runners, so an update that keeps failing to install does not starve the runner.update-pendingnow holds the epoch when it was first written. When it is older thanSWM_UPDATE_PENDING_ALERT_S(6 h),update.shsends one ntfy alert. The alert marker goes away withupdate-pending.install.shpasses that one knob into the updater plist.Evidence that GitHub refuses to delete a busy runner
controllers/actions.summerwind.net/runner_graceful_stop.go) says: "RemoveRunner already has an ability to prevent stopping a busy runner". It quotes422 Bad request - Runner "..." is still running a joband setsrunnerBusy = 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 whoseupdate_waitgave up, and the backstop (threshold, once only, cleared with the marker, failed delivery, env limit, old empty marker).Advances #252