Documentation
¶
Overview ¶
Package supervisor is the container runtime of ADR 0046: images and container records kept by the agent itself, containers supervised by armada-shim. Work in progress; nothing uses it yet.
Index ¶
- Constants
- func NotFound(err error) bool
- type Bundles
- type Image
- type Images
- func (s *Images) Close() error
- func (s *Images) Delete(ctx context.Context, name string) error
- func (s *Images) Get(name string) (Image, bool)
- func (s *Images) List() []Image
- func (s *Images) OCI(img Image) (oci.Image, oci.Client)
- func (s *Images) Prepare(ctx context.Context, key string, img Image) ([]mount.Mount, error)
- func (s *Images) Pull(ctx context.Context, ref string, resolver remotes.Resolver, ...) (Image, error)
- func (s *Images) Release(ctx context.Context, key string) error
- func (s *Images) SetLabel(name, key, value string) error
- type Record
- type Shim
- func (sh *Shim) Create(ctx context.Context, id, bundle, logDir string) (int, error)
- func (sh *Shim) Delete(ctx context.Context, id string) error
- func (sh *Shim) Kill(ctx context.Context, id string, sig int) error
- func (sh *Shim) KillAll(ctx context.Context, id string, sig int) error
- func (sh *Shim) List(ctx context.Context) (map[string]TaskState, error)
- func (sh *Shim) Start(ctx context.Context, id string) error
- func (sh *Shim) State(ctx context.Context, id string) (TaskState, error)
- func (sh *Shim) Wait(ctx context.Context, id string) (int, error)
- type Shims
- type Store
- func (s *Store) CheckLayers(context.Context, client.Image) error
- func (s *Store) Close() error
- func (s *Store) Containers(_ context.Context, filters ...string) ([]client.Container, error)
- func (s *Store) ContentStore() content.Store
- func (s *Store) DeleteImage(ctx context.Context, name string, _ bool) error
- func (s *Store) GetImage(_ context.Context, name string) (client.Image, error)
- func (s *Store) ListImages(context.Context) ([]images.Image, error)
- func (s *Store) LoadContainer(_ context.Context, id string) (client.Container, error)
- func (s *Store) NewContainer(ctx context.Context, id string, img client.Image, labels map[string]string, ...) (client.Container, error)
- func (s *Store) Ping(context.Context) error
- func (s *Store) Pull(ctx context.Context, ref string, resolver remotes.Resolver, ...) (client.Image, error)
- func (s *Store) SetImageLabel(_ context.Context, name, key, value string) error
- func (s *Store) Tasks(ctx context.Context) (map[string]*task.Process, error)
- type TaskState
Constants ¶
const GroupAnnotation = "io.containerd.runc.v2.group"
GroupAnnotation names the shim a container shares; the driver sets it in the spec. A container without it gets a shim of its own.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bundles ¶
type Bundles struct{ Dir string }
Bundles keeps containers' OCI bundles under Dir/<id>: config.json, the root filesystem mounted at rootfs, and record.json.
func (Bundles) Create ¶
Create mounts the root filesystem, writes spec (its root set to the mounted rootfs), then the record last, so a bundle without a record is one that was never finished.
type Image ¶
type Image struct {
Name string `json:"name"`
Target ocispec.Descriptor `json:"target"`
Config ocispec.Descriptor `json:"config"`
ChainID digest.Digest `json:"chainID"`
// Platforms the image offers, as "os/arch".
Platforms []string `json:"platforms,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
}
Image is what the store records about a pulled image name.
type Images ¶
type Images struct {
// contains filtered or unexported fields
}
Images keeps a node's images without a daemon: blobs in a content store under <root>/content, unpacked layers as overlay snapshots under <root>/snapshots, and one record per image name in <root>/images.json.
func OpenImages ¶
OpenImages opens (creating) the store under root for this node's platform.
func (*Images) Delete ¶
Delete forgets an image, then removes layers and blobs no remaining image needs. Layers under a container's root filesystem stay: the snapshotter refuses to remove a parent.
func (*Images) OCI ¶
OCI returns what containerd's spec options read of an image and its snapshots (the image's configuration, its users and groups).
func (*Images) Prepare ¶
Prepare makes a writable root filesystem for container key on top of img's layers and returns its mounts.
func (*Images) Pull ¶
func (s *Images) Pull(ctx context.Context, ref string, resolver remotes.Resolver, wrap func(images.Handler) images.Handler) (Image, error)
Pull resolves ref with resolver, fetches the manifest for this node's platform with its config and layers, unpacks the layers, and records the image under ref. The record keeps the labels of the record it replaces only when both name the same target. wrap, when set, wraps the handler that fetches each descriptor and finds its children.
type Record ¶
type Record struct {
ID string `json:"id"`
Image string `json:"image"`
Labels map[string]string `json:"labels,omitempty"`
Group string `json:"group"`
Created time.Time `json:"created"`
}
Record is what the agent keeps about a container it created, next to its OCI bundle: enough to list, adopt, and remove it after a restart.
type Shim ¶
type Shim struct {
Group string
Socket string
// Root is runc's state directory for the shim's containers.
Root string
}
Shim is one running armada-shim.
func (*Shim) Create ¶
Create creates container id from bundle (not started); its output goes to armada-log in logDir. It returns the container's process ID.
type Shims ¶
type Shims struct {
// Dir holds each shim's socket and state (tmpfs: nothing in it
// outlives a reboot, like the containers).
Dir string
// Bin, Runc, and Logger are the programs a shim runs.
Bin, Runc, Logger string
// Launch starts a shim; nil runs it with systemd-run.
Launch func(ctx context.Context, unit string, argv []string) error
// Active reports whether a shim's unit still runs; nil asks systemd.
Active func(ctx context.Context, unit string) (bool, error)
// contains filtered or unexported fields
}
Shims starts and reaches armada-shim processes, one per group (an app and runtime pack on this node, ADR 0046). Each runs as a transient systemd service of its own, so restarting the agent's service leaves it, and the containers it supervises, alone.
func (*Shims) Abandon ¶
Abandon ends the containers a shim left behind once it is really gone, and reports whether it was. A shim that is slow or busy is not gone: its containers keep running, and the caller tries again later.
type Store ¶
type Store struct {
Images *Images
Bundles Bundles
Shims *Shims
// Logs is the directory armada-log writes container output to.
Logs string
// contains filtered or unexported fields
}
Store is the agent's own container runtime (ADR 0046): images, bundles, and armada-shim processes. It offers containers, tasks, and images through containerd's client interfaces, so the driver's logic is the same on either runtime.
func (*Store) CheckLayers ¶
CheckLayers reports nil: Images.Pull records an image only once its layers were checked.
func (*Store) Containers ¶
Containers returns recorded containers matching every filter.
func (*Store) ContentStore ¶
ContentStore holds the images' blobs.
func (*Store) DeleteImage ¶
DeleteImage forgets an image and removes what no other image or container uses, always at once.
func (*Store) ListImages ¶
ListImages lists pulled images.
func (*Store) LoadContainer ¶
LoadContainer returns a recorded container.
func (*Store) NewContainer ¶
func (s *Store) NewContainer(ctx context.Context, id string, img client.Image, labels map[string]string, opts []oci.SpecOpts) (client.Container, error)
NewContainer records a container from img with labels and the spec opts make, and prepares its root filesystem. Its task is created by NewTask.
func (*Store) Pull ¶
func (s *Store) Pull(ctx context.Context, ref string, resolver remotes.Resolver, wrap func(images.Handler) images.Handler) (client.Image, error)
Pull pulls and unpacks ref; wrap, when set, wraps the handler that fetches each descriptor.
func (*Store) SetImageLabel ¶
SetImageLabel sets one label of a pulled image.