Documentation
¶
Overview ¶
Package dockerproxy is the per-runner Docker API proxy. It passes every request through (including hijacked attach/exec streams and builds) and only rewrites create calls so that everything a job creates is labelled, placed in the instance cgroup slice and wired to this proxy instead of the real socket.
Index ¶
Constants ¶
const DefaultMaxBody = 10 << 20
DefaultMaxBody bounds the request bodies the proxy buffers for rewriting.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Socket string `json:"socket"` // unix socket the proxy listens on
Upstream string `json:"upstream"` // real Docker socket
Runner string `json:"runner"` // runner name stamped on everything
Instance string `json:"instance"` // instance stamped on everything
HostID string `json:"host_id"` // host id stamped on everything
Slice string `json:"slice"` // HostConfig.CgroupParent for job containers
OOMScoreAdj int `json:"oom_score_adj"` // HostConfig.OomScoreAdj for job containers
CacheBinds []string `json:"cache_binds"` // "host:container[:opts]" appended to job containers
CacheEnv map[string]string `json:"cache_env"` // env appended to job containers
// AllowedBinds are host paths (and everything under them) a job may
// bind-mount; anything else outside named volumes is refused.
AllowedBinds []string `json:"allowed_binds"`
// PersistentNames are path.Match globs on container names. A container
// created with a matching ?name= is labelled role=persistent without a
// runner: it survives runner cleanup and every runner of the instance
// may use it.
PersistentNames []string `json:"persistent_names"`
// PullLock, when set, is the cross-process pull lock file (see package
// pulllock): image pulls and builds hold it shared so image GC, in the
// daemon, can exclude them.
PullLock string `json:"pull_lock"`
MaxBody int64 `json:"max_body"` // 0 = DefaultMaxBody
Log *slog.Logger `json:"-"` // nil = discard
}
Config configures one proxy. The JSON form is the on-disk spec read by the out-of-process proxy (see Spec).
type Gate ¶
type Gate struct {
// contains filtered or unexported fields
}
Gate is a Pause/Resume/InFlight view of a proxy.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy is a running per-runner proxy.
func (*Proxy) InFlightPulls ¶
InFlightPulls is the number of image pulls currently proxied.
func (*Proxy) PausePulls ¶
func (p *Proxy) PausePulls()
PausePulls blocks new image pulls (they wait, they do not fail). Calls nest.
func (*Proxy) ResumePulls ¶
func (p *Proxy) ResumePulls()
ResumePulls undoes one PausePulls; pulls proceed when the last is undone.
type ServeOptions ¶ added in v0.1.2
type ServeOptions struct {
Log *slog.Logger
// PollEvery is how often the runner container is checked; 0 = 10s.
PollEvery time.Duration
// StartGrace is how long the container may stay missing before it was
// ever seen (the proxy starts before the runner is created); 0 = 5m.
StartGrace time.Duration
}
ServeOptions are injectable for tests.
type Spec ¶ added in v0.1.2
type Spec struct {
Config Config `json:"config"`
// RunnerContainer is the runner container's name or ID. The proxy exits
// once that container no longer exists.
RunnerContainer string `json:"runner_container"`
LogLevel string `json:"log_level,omitempty"`
}
Spec is everything `runner-warden proxy --spec <file>` needs to serve one runner's proxy in its own process (outside the daemon, so it survives a daemon restart).