Skip to content

Creating backend abstraction for self hosted worker #29

Merged
ianhodge merged 4 commits intomainfrom
03-10-ian_creating_backend_abstraction_for_self_hosted_worker
Mar 18, 2026
Merged

Creating backend abstraction for self hosted worker #29
ianhodge merged 4 commits intomainfrom
03-10-ian_creating_backend_abstraction_for_self_hosted_worker

Conversation

@ianhodge
Copy link
Member

@ianhodge ianhodge commented Mar 10, 2026

What

Pure refactor: introduces a Backend interface and extracts all Docker logic from worker.go into a separate DockerBackend implementation. No behavior change.

Changes

  • internal/worker/backend.go — New Backend interface with ExecuteTask and Shutdown methods
  • internal/worker/docker.goDockerBackend struct with all Docker-specific logic extracted from worker.go (image pulling, sidecar management, container lifecycle, registry auth, etc.)
  • internal/worker/worker.go — Slimmed down: Worker struct now holds a backend Backend field instead of dockerClient/platform. New() creates a DockerBackend, executeTask delegates to w.backend.ExecuteTask(), Shutdown calls w.backend.Shutdown()

Testing

  • Builds clean (go build ./...)
  • Manually verified against staging — worker connects, receives task assignments, and executes them in Docker identically to before

Overall plan: non-containerized self-hosted agents

This PR is 1 of 3 to add direct (non-Docker) execution support:

  1. PR 1 (this PR): Backend interface + Docker extraction — pure refactor to enable the next two PRs
  2. PR 2: YAML config file support (--config-file) — adds gopkg.in/yaml.v3, config parsing/merging for worker_id, cleanup, docker.volumes, docker.environment
  3. PR 3: Direct backend (--backend direct) — runs agents directly on the host via the Oz CLI, with setup/teardown scripts, per-agent workspace directories, and environment file injection

Co-Authored-By: Oz oz-agent@warp.dev

@ianhodge ianhodge changed the title ian/creating_backend_abstraction_for_self_hosted_worker Backend interface + Docker extraction for direct backend support Mar 10, 2026
@ianhodge ianhodge changed the title Backend interface + Docker extraction for direct backend support Creating backend abstraction for self hosted worker Mar 10, 2026
@ianhodge ianhodge requested a review from bnavetta March 10, 2026 22:39
@ianhodge ianhodge marked this pull request as ready for review March 10, 2026 22:39
ianhodge and others added 3 commits March 16, 2026 16:52
Introduces a TaskParams struct that decouples the Backend interface from
the wire-format TaskAssignmentMessage. Common concerns (resolving env
vars, default Docker image, base CLI args) are now handled by
worker.prepareTaskParams() rather than individual backend implementations.

Co-Authored-By: Oz <oz-agent@warp.dev>
Copy link
Collaborator

@bnavetta bnavetta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

SidecarImage string

// AdditionalSidecars is the list of extra sidecar images from the assignment.
AdditionalSidecars []types.SidecarMount
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the TaskParams abstraction, we should be able to flatten all sidecars into a single list, so backends don't need duplicate logic for the main sidecar vs. other sidecars

@ianhodge ianhodge merged commit 9f67bb2 into main Mar 18, 2026
4 checks passed
@ianhodge ianhodge deleted the 03-10-ian_creating_backend_abstraction_for_self_hosted_worker branch March 18, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants