Sign in

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

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Put job execution behind an interface

de3eec162f93a697575c8bc756bd496fe4020376 · Keenan Nemetz · 2h ago · parent f784d769

Put job execution behind an interface

Job execution was container-shaped all the way into the runner: ci/agent
created the network, started the services and the job container, and held
*container.Container and *container.Network values directly, and
`vole workflow run` kept its own copy of the same orchestration. The only
abstraction was Config.Runtime, a string naming one of three flag-compatible
CLIs, which is enough for docker, podman and nerdctl and nothing else.

ci/execute is that seam. An Executor prepares the job's image, starts its
environment, runs one step while the caller keeps the lease alive, stops it,
reclaims what a killed runner left behind, and bounds its own storage. A
Sandbox is one job's environment: the job, the services beside it, and the
network they share. Capabilities is what a backend can honour, so a job that
asks for a network or for services is refused before it starts rather than
quietly given less.

ci/container implements it and takes over the orchestration that was in
ci/agent and cmd/vole: the per-attempt network, the service containers and
their log collection, the stale-container and stale-network reclamation, and
the image build and prune coordination. The isolation flags are unchanged.

This is the boundary a virtual-machine backend needs: a macOS guest behind
Tart (#356), a Windows guest, or a Linux microVM disagree with a container
about pids limits, user namespaces, tmpfs, capabilities and mounts, so they
cannot be expressed as another runtime string. Nothing about the image or
workflow schema changes here.

closes: 01M8Z2M9PVKPNH923S3VJ5FR5E

ci/container/images.go +38

@@ -15,6 +15,7 @@ import (
15 15 "os/exec"
16 16 "strconv"
17 17 "strings"
18 "sync"
18 19 "time"
19 20 )
20 21
@@ -114,3 +115,40 @@ func runtimeBytes(text string) (int64, bool) {
114 115 }
115 116 return int64(n * mult), true
116 117 }
118
119 // imageUse is the boundary between a job acquiring an image and a prune pass.
120 // A job holds it from before the image is prepared (which may build it) until the
121 // job's environment is up; a prune takes it exclusively, so an image cannot
122 // disappear between the prepare and the start.
123 //
124 // It lives beside PruneImages rather than in the caller because both sides of the
125 // boundary are the container backend's: a second backend bounds its own storage its
126 // own way, and the runner only asks.
127 type imageUse struct {
128 mu sync.RWMutex
129 }
130
131 // hold marks an image as in use and returns the release. A nil guard means the
132 // caller never asked for one (a Backend built by hand in a test), so holding and
133 // releasing are no-ops rather than a panic.
134 func (u *imageUse) hold() func() {
135 if u == nil {
136 return func() {}
137 }
138 u.mu.RLock()
139 return u.mu.RUnlock
140 }
141
142 // exclusive takes the guard for a prune pass. It does not wait: a job that is
143 // building or starting an image may hold it for minutes, and a trimmer that
144 // blocked a pass would be a goroutine waiting on a build rather than a runner
145 // doing work. A skipped pass costs nothing; the next beat tries again.
146 func (u *imageUse) exclusive() (func(), bool) {
147 if u == nil {
148 return func() {}, true
149 }
150 if !u.mu.TryLock() {
151 return nil, false
152 }
153 return u.mu.Unlock, true
154 }