Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/git/vole.git

Write over SSH with a registered key:

git clone ssh://git@0.0.0.0: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 · 16d 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/server/ci.go +7

@@ -305,6 +305,13 @@ func (s *Server) watchLeases(ctx context.Context) {
305 305 s.Log.Warn(fmt.Sprintf("ci: %d job(s) returned to the queue, %d failed after %d attempts",
306 306 back, failed, runs.MaxAttempts))
307 307 }
308 // Presence is not history: a runner that was killed leaves a row nothing
309 // will ever refresh, so it is forgotten rather than shown as connected.
310 if n, err := s.Runs.PruneSessions(time.Now().UTC().Add(-10 * time.Minute)); err != nil {
311 s.Log.Warn("ci: cannot prune runner presence", "err", err)
312 } else if n > 0 {
313 s.Log.Debug("ci: forgot silent runners", "runners", n)
314 }
308 315 }
309 316 }
310 317 }