Documentation ¶
Index ¶
Constants ¶
const ( AgentIDEnvVar = "DET_AGENT_ID" TaskIDEnvVar = "DET_TASK_ID" AllocationIDEnvVar = "DET_ALLOCATION_ID" ContainerIDEnvVar = "DET_CONTAINER_ID" )
Environment variable names for various Determined container vars.
Variables ¶
var ErrKilledBeforeRun = aproto.NewContainerFailure( aproto.ContainerAborted, errors.New("killed before run"), )
ErrKilledBeforeRun indicates a container was aborted before we were able to run it.
var ErrMissing = aproto.NewContainerFailure( aproto.ContainerMissing, errors.New("container is gone on reattachment"), )
ErrMissing indicates a container was missing when we tried to reattach it after a crash.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container is a layer for managing a single Docker container. It can be constructed by launching a new container or reattaching an existing one. Once constructed, it provides an interface to interact with a running container.
func Reattach ¶
func Reattach( container cproto.Container, cl ContainerRuntime, pub events.Publisher[Event], ) *Container
Reattach an existing container and receive a handle to interact with it.
func Start ¶
func Start( req aproto.StartContainer, cl ContainerRuntime, pub events.Publisher[Event], ) *Container
Start a container asynchronously and receive a handle to interact with it.
func (*Container) Detach ¶
func (c *Container) Detach()
Detach the monitoring loops without affecting the Docker container.
func (*Container) Signal ¶
Signal asynchronously delivers the signal. Delivery failures are surfaced in logs.
func (*Container) Stop ¶
func (c *Container) Stop()
Stop the Docker container by killing it and awaiting its exit.
func (*Container) Wait ¶
func (c *Container) Wait() *aproto.ContainerStateChanged
Wait until the container exits. Always returns a ContainerExit unless canceled by Detach.
type ContainerRuntime ¶
type ContainerRuntime interface { ReattachContainer( ctx context.Context, id cproto.ID, ) (*docker.Container, *aproto.ExitCode, error) PullImage(ctx context.Context, req docker.PullImage, p events.Publisher[docker.Event]) error // TODO(DET-9075): Refactor Create and Run to not be separate calls. CreateContainer( ctx context.Context, id cproto.ID, req cproto.RunSpec, p events.Publisher[docker.Event], ) (string, error) // TODO(DET-9075): Make a custom return type rather than just reusing the Docker type. RunContainer( ctx context.Context, waitCtx context.Context, id string, p events.Publisher[docker.Event], ) (*docker.Container, error) SignalContainer(ctx context.Context, id string, sig syscall.Signal) error RemoveContainer(ctx context.Context, id string, force bool) error ListRunningContainers(ctx context.Context, fs filters.Args) (map[cproto.ID]types.Container, error) }
ContainerRuntime is our interface for interacting with runtimes like Docker.
type Event ¶
type Event struct { StateChange *aproto.ContainerStateChanged Log *aproto.ContainerLog StatsRecord *aproto.ContainerStatsRecord }
Event is the union of all events emitted by a container. When used, only one should be set.