vole
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software:2222/vole.git
A free and open-source forge that lives in your Git repo.
Phase 4: a runners page, built from the queue's own presence
ac43353160989ae56b6a92ae8f1df1017c2c20c4 · Keenan Nemetz · 17d ago · parent 760b523a
Phase 4: a runners page, built from the queue's own presence "Nobody is connected and eleven jobs are waiting" is the sentence somebody needs when a build does not start, and until now nothing could say it: a runner existed only as an SSH channel, invisible to both the web and the queue. `runs.db` could already answer "who holds this lease" (lease_owner, lease_until) and "who ran this" (the attestation), but not "who is connected and idle". Presence is now a row per channel in the queue — `runner_sessions` — written by events a runner already sends: connect, lease (which records the run it holds), heartbeat (a long build must not look gone), and finish (which clears it). A clean disconnect drops the row, and `watchLeases` forgets rows silent for ten minutes, which is the only trace a killed process leaves. Nothing here is authoritative: presence is a derived fact about a live channel, which is why the page applies its own two-minute window rather than trusting a stored "online" flag. GET /runners shows the connected runners (account, the job it is building and its repository, or "waiting for work") and the queue depth per repository. It follows the clone rule like every other page: a session building a private repository is not shown at all, and a private repository's queue is not counted, because naming either would confirm the repository exists. The header now links to it from every page. Measured: TestARunnerSessionIsVisibleWhileItIsConnected (a connected runner is one row, idle, then "building <run>" once it leases), TestRunnersPageShowsTheRunnerHoldingAJob AndTheQueueDepth (the page names the account, links the run it is building and counts one waiting and one running), TestRunnersPageKeepsAPrivateRepositoryOut (no repository name, account, job or run id from a private repository appears).
internal/sshserver/lease_wait_test.go +38
| @@ -36,6 +36,44 @@ func (h *harness) enqueueJob(t *testing.T, jobName string) { | |||
| 36 | 36 | } | |
| 37 | 37 | } | |
| 38 | 38 | ||
| 39 | // A connected runner is a row the page can show, and the row says what it is doing. | ||
| 40 | // Nothing else records that a runner exists, so this is the only proof it is visible. | ||
| 41 | func TestARunnerSessionIsVisibleWhileItIsConnected(t *testing.T) { | ||
| 42 | h := newHarness(t) | ||
| 43 | c := h.runner(t, h.keyPath) | ||
| 44 | if rep := c.call(runnerRequest{Op: "ping"}); rep.Error != "" { | ||
| 45 | t.Fatal(rep.Error) | ||
| 46 | } | ||
| 47 | |||
| 48 | sessions, err := h.runs.Sessions(time.Time{}) | ||
| 49 | if err != nil { | ||
| 50 | t.Fatal(err) | ||
| 51 | } | ||
| 52 | if len(sessions) != 1 { | ||
| 53 | t.Fatalf("%d session(s) recorded for one connected runner", len(sessions)) | ||
| 54 | } | ||
| 55 | if sessions[0].Account != h.writerID { | ||
| 56 | t.Fatalf("the session is recorded for %q, want the account the key resolves to", sessions[0].Account) | ||
| 57 | } | ||
| 58 | if sessions[0].RunID != "" { | ||
| 59 | t.Fatalf("an idle runner is recorded as building %q", sessions[0].RunID) | ||
| 60 | } | ||
| 61 | |||
| 62 | h.enqueueJob(t, "visible") | ||
| 63 | lease := c.call(runnerRequest{Op: "lease"}) | ||
| 64 | if lease.Run == nil { | ||
| 65 | t.Fatalf("no job was leased: %+v", lease) | ||
| 66 | } | ||
| 67 | sessions, err = h.runs.Sessions(time.Time{}) | ||
| 68 | if err != nil { | ||
| 69 | t.Fatal(err) | ||
| 70 | } | ||
| 71 | if sessions[0].RunID != lease.Run.ID || sessions[0].Repo != h.repoName { | ||
| 72 | t.Fatalf("the session shows run %q in %q, want %q in %q", | ||
| 73 | sessions[0].RunID, sessions[0].Repo, lease.Run.ID, h.repoName) | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 39 | 77 | // The reply to a parked lease arrives because a job was queued, not because the wait | |
| 40 | 78 | // ran out: the wait is 30 seconds and the assertion is five, so a poll would fail it. | |
| 41 | 79 | func TestALeaseWaitsForWorkInsteadOfPolling(t *testing.T) { | |