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/container.go −38
| @@ -25,17 +25,13 @@ import ( | |||
| 25 | 25 | "context" | |
| 26 | 26 | "encoding/json" | |
| 27 | 27 | "fmt" | |
| 28 | "io" | ||
| 29 | 28 | "os" | |
| 30 | 29 | "os/exec" | |
| 31 | "path/filepath" | ||
| 32 | 30 | "sort" | |
| 33 | 31 | "strconv" | |
| 34 | 32 | "strings" | |
| 35 | 33 | "sync" | |
| 36 | 34 | "time" | |
| 37 | |||
| 38 | "rodent.software/vole/ci" | ||
| 39 | 35 | ) | |
| 40 | 36 | ||
| 41 | 37 | // MaxServiceLogBytes bounds one service's output in an attempt log. A database | |
| @@ -444,40 +440,6 @@ func Exists(runtime, tag string) bool { | |||
| 444 | 440 | return exec.Command(runtime, "image", "inspect", tag).Run() == nil | |
| 445 | 441 | } | |
| 446 | 442 | ||
| 447 | // Build renders an image definition and builds it. It is for callers with nothing | ||
| 448 | // else to keep alive; a runner builds through its own command loop so a long build | ||
| 449 | // keeps its lease. | ||
| 450 | func Build(ctx context.Context, cfg Config, definition, tag string, out io.Writer) error { | ||
| 451 | dockerfile, err := ci.RenderImage(definition) | ||
| 452 | if err != nil { | ||
| 453 | return err | ||
| 454 | } | ||
| 455 | dir, err := os.MkdirTemp("", "vole-image-*") | ||
| 456 | if err != nil { | ||
| 457 | return err | ||
| 458 | } | ||
| 459 | defer os.RemoveAll(dir) | ||
| 460 | if err := os.WriteFile(filepath.Join(dir, "Dockerfile"), []byte(dockerfile), 0o600); err != nil { | ||
| 461 | return err | ||
| 462 | } | ||
| 463 | args := []string{"build", "-t", tag, "-f", filepath.Join(dir, "Dockerfile"), dir} | ||
| 464 | switch { | ||
| 465 | case cfg.Pull == "always" && cfg.Runtime == "podman": | ||
| 466 | args = append(args, "--pull=always") | ||
| 467 | case cfg.Pull == "always": | ||
| 468 | args = append(args, "--pull") | ||
| 469 | } | ||
| 470 | cmd := exec.CommandContext(ctx, cfg.Runtime, args...) | ||
| 471 | cmd.Stdout, cmd.Stderr = out, out | ||
| 472 | if err := cmd.Run(); err != nil { | ||
| 473 | return fmt.Errorf("building image %s: %w", tag, err) | ||
| 474 | } | ||
| 475 | if !Exists(cfg.Runtime, tag) { | ||
| 476 | return fmt.Errorf("building image %s produced no image", tag) | ||
| 477 | } | ||
| 478 | return nil | ||
| 479 | } | ||
| 480 | |||
| 481 | 443 | // ServiceSpec is one server container started beside a job: a database, a queue, | |
| 482 | 444 | // or another process the steps reach by name. It has no job tree and no secrets | |
| 483 | 445 | // file, and it runs the image's own command rather than a keepalive shell. | |