Documentation
¶
Index ¶
- Constants
- Variables
- func ShouldRestart(policy string) bool
- func ShouldRestartOnSuccess(policy string) bool
- func ValidStateTransition(from, to State) bool
- func ValidateEnv(env []string) error
- func ValidatePortMappings(mappings []PortMapping) error
- func ValidateRestartPolicy(p string) error
- func ValidateSecurity(s *Security) error
- type Action
- type Config
- type Docker
- type DockerInspectResponse
- type DockerResult
- type HealthCheck
- type HealthCheckType
- type PortMapping
- type Result
- type Security
- type State
- type Task
- type TaskEvent
- type TaskLogs
- type Ulimit
Constants ¶
const ( ActionStart Action = "start" ActionStop Action = "stop" ResultSuccess Result = "success" )
const ( RestartPolicyNone = "no" RestartPolicyAlways = "always" RestartPolicyOnFailure = "on-failure" RestartPolicyUnlessStopped = "unless-stopped" )
restart policies a task can declare
Variables ¶
var ( HealthCheckDefaultInterval = 30 HealthCheckDefaultTimeout = 5 HealthCheckDefaultRetries = 3 HealthCheckDefaultStartPeriod = 0 )
Functions ¶
func ShouldRestart ¶
reports whether a Failed task with this policy may be restarted by the orchestrator
func ShouldRestartOnSuccess ¶
reports whether a cleanly exited task with this policy may be restarted by the orchestrator
func ValidStateTransition ¶
func ValidatePortMappings ¶
func ValidatePortMappings(mappings []PortMapping) error
SCTP is intentionally unsupported, since the worker has no reliable SCTP inventory
func ValidateRestartPolicy ¶
accepts an empty policy, defaults to on-failure
func ValidateSecurity ¶ added in v0.1.1
validates a Security block; nil is valid ("no security options")
Types ¶
type Config ¶
type Docker ¶
func (*Docker) Inspect ¶
func (d *Docker) Inspect(containerID string) DockerInspectResponse
func (*Docker) Logs ¶
fetches the demultiplexed stdout+stderr of a container into a single buffer a missing container yields (nil, nil) so callers can fall back to stored logs without treating that as an error
func (*Docker) Pull ¶
makes sure image exists on the local daemon, pulling it from the registry only when missing
it reports whether the image had to be pulled
the pull's progress stream is drained rather than printed, callers get a plain success/error
func (*Docker) Run ¶
func (d *Docker) Run() DockerResult
func (*Docker) Stop ¶
func (d *Docker) Stop(id string) DockerResult
type DockerInspectResponse ¶
type DockerInspectResponse struct {
Response *container.InspectResponse
Error error
}
type DockerResult ¶
type HealthCheck ¶
type HealthCheck struct {
Type HealthCheckType
Port int
Path string
Command []string
Interval int
Timeout int
Retries int
StartPeriod int
}
func (*HealthCheck) Normalized ¶
func (h *HealthCheck) Normalized() HealthCheck
type HealthCheckType ¶
type HealthCheckType string
const ( HealthCheckHTTP HealthCheckType = "http" HealthCheckTCP HealthCheckType = "tcp" HealthCheckExec HealthCheckType = "exec" )
type PortMapping ¶
type PortMapping struct {
ContainerPort int
HostPort int
Protocol network.IPProtocol
}
func PortMappingsFromPortMap ¶
func PortMappingsFromPortMap(ports network.PortMap) []PortMapping
type Security ¶ added in v0.1.1
type Security struct {
// "uid", "uid:gid"
User string
// extra groups the container process belongs to
GroupAdd []string
// kernel capabilities
CapAdd []string
CapDrop []string
// mount an empty tmpfs at each path. "<path>:<options>"
Tmpfs []string
ReadOnlyRootfs bool
NoNewPrivileges bool
Privileged bool
PidsLimit int64
// per-resource rlimits for the container process, e.g. nofile
Ulimits []Ulimit
// "", "private", "shareable", "none" or "host"
IpcMode string
// re-map the container's UIDs through a user namespace
UsernsMode string
}
mirrors compose's hardening-related options
type Task ¶
type Task struct {
ID uuid.UUID
ContainerID string
Name string
State State
Image string
Cpu float64
Memory int64
Disk int64
Ports []PortMapping
Cmd []string
Env []string
RestartPolicy string
HostPorts []PortMapping // resolved bindings reported by the daemon
HealthCheck *HealthCheck
Security *Security `json:",omitempty"` // container hardening options
RestartCount int
MaxRestarts int // per-task restart cap; 0 = fall back to manager.MaxRestarts
FailureReason string `json:",omitempty"`
ManuallyStopped bool `json:",omitempty"` // by user
// earliest time the orchestrator will attempt the next restart
// zero means immediately eligible
NextRetryAt time.Time `json:",omitempty"`
StartTime time.Time
FinishTime time.Time
Timeout int64 // max seconds a task may run before the worker kills it, 0 = unlimited
}
func ResolveRef ¶
resolves a task reference (UUID or name) against a snapshot of tasks
func (Task) AtRestartCap ¶
func (Task) EffectiveMaxRestarts ¶
func (Task) IsTerminal ¶
type TaskLogs ¶
type TaskLogs struct {
TaskID uuid.UUID
ExitCode *int // nil if still running/unknown
Logs []byte // demultiplexed stdout+stderr, bounded at capture time
CapturedAt time.Time
Source string // "exit" | "stop" | "unhealthy"
}
captured snapshot of a task's container output, stored on the worker so logs survive container removal