Documentation ¶
Index ¶
- Constants
- func LabelFilter(key, val string) filters.Args
- type Client
- func (d *Client) CreateContainer(ctx context.Context, id cproto.ID, req cproto.RunSpec, ...) (string, error)
- func (d *Client) Inner() *client.Client
- func (d *Client) ListRunningContainers(ctx context.Context, fs filters.Args) (map[cproto.ID]types.Container, error)
- func (d *Client) PullImage(ctx context.Context, req PullImage, p events.Publisher[Event]) error
- func (d *Client) ReattachContainer(ctx context.Context, id cproto.ID) (*Container, *aproto.ExitCode, error)
- func (d *Client) RemoveContainer(ctx context.Context, id string, force bool) error
- func (d *Client) RunContainer(ctx context.Context, waitCtx context.Context, id string, ...) (*Container, error)
- func (d *Client) SignalContainer(ctx context.Context, id string, sig syscall.Signal) error
- type Container
- type ContainerWaiter
- type Event
- type LogEvent
- type PullImage
- type StatsEvent
Constants ¶
const ( // ContainerTypeLabel describes container type. ContainerTypeLabel = "ai.determined.container.type" // ContainerTypeValue is the corresponding value for 'normal tasks'. ContainerTypeValue = "task-container" // ContainerVersionLabel describes the container version. ContainerVersionLabel = "ai.determined.container.version" // ContainerVersionValue is the current (and only) container version. ContainerVersionValue = "0" // ContainerIDLabel gives the Determined container ID (cproto.ID). ContainerIDLabel = "ai.determined.container.id" // ContainerDevicesLabel describes the devices allocated to the container. ContainerDevicesLabel = "ai.determined.container.devices" // ContainerDescriptionLabel describes the container. ContainerDescriptionLabel = "ai.determined.container.description" // AgentLabel gives the agent the container is managed by. AgentLabel = "ai.determined.container.agent" // ClusterLabel gives the cluster the container is managed by. ClusterLabel = "ai.determined.container.cluster" // MasterLabel gives the master the container is managed by. MasterLabel = "ai.determined.container.master" // ImagePullStatsKind describes the IMAGEPULL event. ImagePullStatsKind = "IMAGEPULL" )
Variables ¶
This section is empty.
Functions ¶
func LabelFilter ¶
LabelFilter is a convenience that takes a key and value and returns a docker label filter.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the Docker client, augmenting it with a few higher level convenience APIs.
func NewClient ¶
NewClient populates credentials from the Docker Daemon config and returns a new Client that uses them.
func (*Client) CreateContainer ¶
func (d *Client) CreateContainer( ctx context.Context, id cproto.ID, req cproto.RunSpec, p events.Publisher[Event], ) (string, error)
CreateContainer creates a container according to the given spec, returning a docker container ID to start it. It takes a caller-provided channel on which docker events are sent. Slow receivers will block the call.
func (*Client) Inner ¶
Inner returns the underlying Docker client, to be used sparingly. TODO(DET-8628): Consolidate around usage of the wrapper client, remove this.
func (*Client) ListRunningContainers ¶
func (d *Client) ListRunningContainers(ctx context.Context, fs filters.Args) ( map[cproto.ID]types.Container, error, )
ListRunningContainers lists running Docker containers satisfying the given filters.
func (*Client) PullImage ¶
PullImage pulls an image according to the given request and credentials initialized at client creation from the Daemon config or credentials helpers configured there. It takes a caller-provided channel on which docker events are sent. Slow receivers will block the call.
func (*Client) ReattachContainer ¶
func (d *Client) ReattachContainer( ctx context.Context, id cproto.ID, ) (*Container, *aproto.ExitCode, error)
ReattachContainer looks for a single running or terminated container that matches the given filters and returns whether it can be reattached or has terminated.
func (*Client) RemoveContainer ¶
RemoveContainer removes a Docker container by ID.
func (*Client) RunContainer ¶
func (d *Client) RunContainer( ctx context.Context, waitCtx context.Context, id string, p events.Publisher[Event], ) (*Container, error)
RunContainer runs a container by docker container ID. It takes a caller-provided channel on which docker events are sent. Slow receivers will block the call. RunContainer takes two contexts: one to govern cancellation of running the container, and another to govern the lifetime of the waiter returned. nolint: golint // Both contexts can't both be first.
type Container ¶
type Container struct { ContainerInfo types.ContainerJSON ContainerWaiter ContainerWaiter }
Container contains details about a running container and waiters to await its termination.
type ContainerWaiter ¶
type ContainerWaiter struct { Waiter <-chan dcontainer.WaitResponse Errs <-chan error }
ContainerWaiter contains channels to wait on the termination of a running container. Results on the Waiter channel indicate changes in container state, while results on the Errs channel indicate failures to watch for updates.
type Event ¶
type Event struct { Log *LogEvent Stats *StatsEvent }
Event describes some Docker-layer event.
func NewBeginStatsEvent ¶
NewBeginStatsEvent initializes a new beginning Event that is of kind 'StatsEvent' for the kind.
func NewEndStatsEvent ¶
NewEndStatsEvent initializes a new ending Event that is of kind 'StatsEvent' for the kind.
func NewLogEvent ¶
NewLogEvent initializes a new Event that is of kind 'LogEvent'. TODO(DET-9076): Logs need agent IDs.