driver

package
v0.0.0-...-d1e0373 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2017 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTag defines the default tag used when performing images related actions and no tag or digest is specified
	DefaultTag = "latest"
	// DefaultHostname is the default built-in hostname
	DefaultHostname = "docker.io"
	// DefaultRepoPrefix is the prefix used for default repositories in default host
	DefaultRepoPrefix = "library/"
)

much of this code is copied from docker/docker/reference.go

Variables

This section is empty.

Functions

func TypeToString

func TypeToString(dtype Type) string

TypeToString converts a driver Type into its string representation

Types

type CRIContainer

type CRIContainer struct {
	// contains filtered or unexported fields
}

CRIContainer is an implementation of the container metadata needed for CRI implementation

func (*CRIContainer) Command

func (ctr *CRIContainer) Command() string

Command returns an optional command that overrides the default image "CMD" or "ENTRYPOINT" for the Docker and Containerd (gRPC) drivers

func (*CRIContainer) Detached

func (ctr *CRIContainer) Detached() bool

Detached returns whether the container is to be started in detached state

func (*CRIContainer) GetPodID

func (ctr *CRIContainer) GetPodID() string

GetPodID return pod-id associated with container.

func (*CRIContainer) Image

func (ctr *CRIContainer) Image() string

Image returns either a bundle path (used by runc, containerd) or image name (used by Docker) that will be used by the container runtime to know what image to run/execute

func (*CRIContainer) Name

func (ctr *CRIContainer) Name() string

Name returns the name of the container

func (*CRIContainer) Trace

func (ctr *CRIContainer) Trace() bool

Trace returns whether the container should be traced (using any tracing supported by the container runtime)

type CRIDriver

type CRIDriver struct {
	// contains filtered or unexported fields
}

CRIDriver is an implementation of the driver interface for using k8s Container Runtime Interface. This uses the provided client library which abstracts using the gRPC APIs directly.

func (CRIDriver) Clean

func (c CRIDriver) Clean() error

Clean will clean the operating environment of a specific driver

func (*CRIDriver) Close

func (c *CRIDriver) Close() error

Close allows the driver to free any resources/close any connections

func (*CRIDriver) Create

func (c *CRIDriver) Create(name, image, cmdOverride string, detached bool, trace bool) (Container, error)

Create will create a container instance matching the specific needs of a driver

func (*CRIDriver) Info

func (c *CRIDriver) Info() (string, error)

Info returns a string with information about the container engine/runtime details

func (*CRIDriver) Path

func (c *CRIDriver) Path() string

Path returns the binary (or socket) path related to the runtime in use

func (*CRIDriver) Pause

func (c *CRIDriver) Pause(ctr Container) (string, int, error)

Pause will pause a container not supported in CRI API

func (*CRIDriver) Remove

func (c *CRIDriver) Remove(ctr Container) (string, int, error)

Remove will remove a container

func (*CRIDriver) Run

func (c *CRIDriver) Run(ctr Container) (string, int, error)

Run will execute a container using the driver

func (*CRIDriver) Stop

func (c *CRIDriver) Stop(ctr Container) (string, int, error)

Stop will stop/kill a container

func (*CRIDriver) Type

func (c *CRIDriver) Type() Type

Type returns a driver type to identify the driver

func (*CRIDriver) Unpause

func (c *CRIDriver) Unpause(ctr Container) (string, int, error)

Unpause will unpause/resume a container not supported in CRI API

type Container

type Container interface {
	// Name returns the name of the container
	Name() string

	// Detached returns whether the container is to be started in detached state
	Detached() bool

	// Trace returns whether the container should be traced (using any tracing supported
	// by the container runtime)
	Trace() bool

	// Image returns either a bundle path (used by runc, containerd) or image name (used by Docker)
	// that will be used by the container runtime to know what image to run/execute
	Image() string

	// Command returns an optional command that overrides the default image
	// "CMD" or "ENTRYPOINT" for the Docker and Containerd (gRPC) drivers
	Command() string

	//GetPodID returns podid associated with the container
	//only used by CRI-based drivers
	GetPodID() string
}

Container represents a generic container instance on any container engine

type ContainerdContainer

type ContainerdContainer struct {
	// contains filtered or unexported fields
}

ContainerdContainer is an implementation of the container metadata needed for containerd

func (*ContainerdContainer) Command

func (c *ContainerdContainer) Command() string

Command returns the override command that will be executed instead of the default image-specified command

func (*ContainerdContainer) Detached

func (c *ContainerdContainer) Detached() bool

Detached always returns true for containerd as IO streams are always detached

func (*ContainerdContainer) GetPodID

func (c *ContainerdContainer) GetPodID() string

GetPodID return pod-id associated with container. only used by CRI-based drivers

func (*ContainerdContainer) Image

func (c *ContainerdContainer) Image() string

Image returns the bundle path that runc will use

func (*ContainerdContainer) Name

func (c *ContainerdContainer) Name() string

Name returns the name of the container

func (*ContainerdContainer) Process

func (c *ContainerdContainer) Process() string

Process returns the process name in cases where this container instance is wrapping a potentially running container

func (*ContainerdContainer) State

func (c *ContainerdContainer) State() string

State returns the queried state of the container (if available)

func (*ContainerdContainer) Trace

func (c *ContainerdContainer) Trace() bool

Trace returns whether the container should be started with tracing enabled

type ContainerdDriver

type ContainerdDriver struct {
	// contains filtered or unexported fields
}

ContainerdDriver is an implementation of the driver interface for using Containerd. This uses the provided client library which abstracts using the gRPC APIs directly. IMPORTANT: This implementation does not protect instance metadata for thread safely. At this time there is no understood use case for multi-threaded use of this implementation.

func (*ContainerdDriver) Clean

func (r *ContainerdDriver) Clean() error

Clean will clean the environment; removing any remaining containers in the runc metadata

func (*ContainerdDriver) Close

func (r *ContainerdDriver) Close() error

Close allows the driver to handle any resource free/connection closing as necessary.

func (*ContainerdDriver) Create

func (r *ContainerdDriver) Create(name, image, cmdOverride string, detached bool, trace bool) (Container, error)

Create will create a container instance matching the specific needs of a driver

func (*ContainerdDriver) Info

func (r *ContainerdDriver) Info() (string, error)

Info returns

func (*ContainerdDriver) Path

func (r *ContainerdDriver) Path() string

Path returns the address (socket path) of the gRPC containerd API endpoint

func (*ContainerdDriver) Pause

func (r *ContainerdDriver) Pause(ctr Container) (string, int, error)

Pause will pause a container

func (*ContainerdDriver) Remove

func (r *ContainerdDriver) Remove(ctr Container) (string, int, error)

Remove will remove a container; in the containerd case we simply call kill which will remove any container metadata if it was running

func (*ContainerdDriver) Run

func (r *ContainerdDriver) Run(ctr Container) (string, int, error)

Run will execute a container using the containerd driver.

func (*ContainerdDriver) Stop

func (r *ContainerdDriver) Stop(ctr Container) (string, int, error)

Stop will stop/kill a container (specifically, the tasks [processes] running in the container)

func (*ContainerdDriver) Type

func (r *ContainerdDriver) Type() Type

Type returns a driver.Type to indentify the driver implementation

func (*ContainerdDriver) Unpause

func (r *ContainerdDriver) Unpause(ctr Container) (string, int, error)

Unpause will unpause/resume a container

type CtrContainer

type CtrContainer struct {
	// contains filtered or unexported fields
}

CtrContainer is an implementation of the container metadata needed for containerd

func (*CtrContainer) Command

func (c *CtrContainer) Command() string

Command is not implemented for the legacy `ctr` driver type as the command is embedded in the config.json of the rootfs

func (*CtrContainer) Detached

func (c *CtrContainer) Detached() bool

Detached always returns true for containerd as IO streams are always detached

func (*CtrContainer) GetPodID

func (c *CtrContainer) GetPodID() string

GetPodID return pod-id associated with container. only used by CRI-based drivers

func (*CtrContainer) Image

func (c *CtrContainer) Image() string

Image returns the bundle path that runc will use

func (*CtrContainer) Name

func (c *CtrContainer) Name() string

Name returns the name of the container

func (*CtrContainer) Process

func (c *CtrContainer) Process() string

Process returns the process name in cases where this container instance is wrapping a potentially running container

func (*CtrContainer) State

func (c *CtrContainer) State() string

State returns the queried state of the container (if available)

func (*CtrContainer) Trace

func (c *CtrContainer) Trace() bool

Trace returns whether the container should be started with tracing enabled

type CtrDriver

type CtrDriver struct {
	// contains filtered or unexported fields
}

CtrDriver is an implementation of the driver interface for using Containerd in "legacy" mode via the `ctr` client binary (meant for testing purposes only). IMPORTANT: This implementation does not protect instance metadata for thread safely. At this time there is no understood use case for multi-threaded use of this implementation.

func (*CtrDriver) Clean

func (r *CtrDriver) Clean() error

Clean will clean the environment; removing any remaining containers in the runc metadata

func (*CtrDriver) Close

func (r *CtrDriver) Close() error

Close allows the driver to handle any resource free/connection closing as necessary. Ctr has no need to perform any actions on close.

func (*CtrDriver) Create

func (r *CtrDriver) Create(name, image, cmdOverride string, detached bool, trace bool) (Container, error)

Create will create a container instance matching the specific needs of a driver

func (*CtrDriver) Info

func (r *CtrDriver) Info() (string, error)

Info returns

func (*CtrDriver) Path

func (r *CtrDriver) Path() string

Path returns the binary path of the ctr binary in use

func (*CtrDriver) Pause

func (r *CtrDriver) Pause(ctr Container) (string, int, error)

Pause will pause a container

func (*CtrDriver) Remove

func (r *CtrDriver) Remove(ctr Container) (string, int, error)

Remove will remove a container; in the containerd case we simply call kill which will remove any container metadata if it was running

func (*CtrDriver) Run

func (r *CtrDriver) Run(ctr Container) (string, int, error)

Run will execute a container using the containerd driver.

func (*CtrDriver) Stop

func (r *CtrDriver) Stop(ctr Container) (string, int, error)

Stop will stop/kill a container

func (*CtrDriver) Type

func (r *CtrDriver) Type() Type

Type returns a driver.Type to indentify the driver implementation

func (*CtrDriver) Unpause

func (r *CtrDriver) Unpause(ctr Container) (string, int, error)

Unpause will unpause/resume a container

type DockerContainer

type DockerContainer struct {
	// contains filtered or unexported fields
}

DockerContainer is an implementation of the container metadata needed for docker

func (*DockerContainer) Command

func (c *DockerContainer) Command() string

Command returns the optional overriding command that Docker will use when executing a container based on this container's image

func (*DockerContainer) Detached

func (c *DockerContainer) Detached() bool

Detached returns whether the container should be started in detached mode

func (*DockerContainer) GetPodID

func (c *DockerContainer) GetPodID() string

GetPodID return pod-id associated with container. only used by CRI-based drivers

func (*DockerContainer) Image

func (c *DockerContainer) Image() string

Image returns the image name that Docker will use

func (*DockerContainer) Name

func (c *DockerContainer) Name() string

Name returns the name of the container

func (*DockerContainer) Trace

func (c *DockerContainer) Trace() bool

Trace returns whether the container should be started with tracing enabled

type DockerDriver

type DockerDriver struct {
	// contains filtered or unexported fields
}

DockerDriver is an implementation of the driver interface for the Docker engine. IMPORTANT: This implementation does not protect instance metadata for thread safely. At this time there is no understood use case for multi-threaded use of this implementation.

func (*DockerDriver) Clean

func (d *DockerDriver) Clean() error

Clean will clean the environment; removing any exited containers

func (*DockerDriver) Close

func (d *DockerDriver) Close() error

Close allows the driver to handle any resource free/connection closing as necessary. Docker has no need to perform any actions on close.

func (*DockerDriver) Create

func (d *DockerDriver) Create(name, image, cmdOverride string, detached bool, trace bool) (Container, error)

Create will create a container instance matching the specific needs of a driver

func (*DockerDriver) Info

func (d *DockerDriver) Info() (string, error)

Info returns

func (*DockerDriver) Path

func (d *DockerDriver) Path() string

Path returns the binary path of the docker binary in use

func (*DockerDriver) Pause

func (d *DockerDriver) Pause(ctr Container) (string, int, error)

Pause will pause a container

func (*DockerDriver) Remove

func (d *DockerDriver) Remove(ctr Container) (string, int, error)

Remove will remove a container

func (*DockerDriver) Run

func (d *DockerDriver) Run(ctr Container) (string, int, error)

Run will execute a container using the driver

func (*DockerDriver) Stop

func (d *DockerDriver) Stop(ctr Container) (string, int, error)

Stop will stop/kill a container

func (*DockerDriver) Type

func (d *DockerDriver) Type() Type

Type returns a driver.Type to indentify the driver implementation

func (*DockerDriver) Unpause

func (d *DockerDriver) Unpause(ctr Container) (string, int, error)

Unpause will unpause/resume a container

type Driver

type Driver interface {

	// Type returns a driver type to identify the driver
	Type() Type

	// Info returns a string with information about the container engine/runtime details
	Info() (string, error)

	// Path returns the binary (or socket) path related to the runtime in use
	Path() string

	// Create will create a container instance matching the specific needs
	// of a driver
	Create(name, image, cmdOverride string, detached bool, trace bool) (Container, error)

	// Clean will clean the operating environment of a specific driver
	Clean() error

	// Run will execute a container using the driver
	Run(ctr Container) (string, int, error)

	// Stop will stop/kill a container
	Stop(ctr Container) (string, int, error)

	// Remove will remove a container
	Remove(ctr Container) (string, int, error)

	// Pause will pause a container
	Pause(ctr Container) (string, int, error)

	// Unpause will unpause/resume a container
	Unpause(ctr Container) (string, int, error)

	// Close allows the driver to free any resources/close any
	// connections
	Close() error
}

Driver is an interface for various container engines. The integer returned from container operations is the milliseconds elapsed for any command

func New

func New(dtype Type, path string) (Driver, error)

New creates a driver instance of a specific type

func NewCRIDriver

func NewCRIDriver(path string) (Driver, error)

NewCRIDriver creates an instance of the CRI driver

func NewContainerdDriver

func NewContainerdDriver(path string) (Driver, error)

NewContainerdDriver creates an instance of the containerd driver, providing a path to the ctr client

func NewCtrDriver

func NewCtrDriver(binaryPath string) (Driver, error)

NewCtrDriver creates an instance of the containerd driver, providing a path to the ctr client

func NewDockerDriver

func NewDockerDriver(binaryPath string) (Driver, error)

NewDockerDriver creates an instance of the docker driver, providing a path to the docker client binary

func NewRuncDriver

func NewRuncDriver(binaryPath string) (Driver, error)

NewRuncDriver creates an instance of the runc driver, providing a path to runc

type RuncContainer

type RuncContainer struct {
	// contains filtered or unexported fields
}

RuncContainer is an implementation of the container metadata needed for runc

func (*RuncContainer) Command

func (c *RuncContainer) Command() string

Command is not implemented for the runc driver type as the command is embedded in the config.json of the rootfs

func (*RuncContainer) Detached

func (c *RuncContainer) Detached() bool

Detached returns whether the container should be started in detached mode

func (*RuncContainer) GetPodID

func (c *RuncContainer) GetPodID() string

GetPodID return pod-id associated with container. only used by CRI-based drivers

func (*RuncContainer) Image

func (c *RuncContainer) Image() string

Image returns the bundle path that runc will use

func (*RuncContainer) Name

func (c *RuncContainer) Name() string

Name returns the name of the container

func (*RuncContainer) Pid

func (c *RuncContainer) Pid() string

Pid returns the process ID in cases where this container instance is wrapping a potentially running container

func (*RuncContainer) State

func (c *RuncContainer) State() string

State returns the queried state of the container (if available)

func (*RuncContainer) Trace

func (c *RuncContainer) Trace() bool

Trace returns whether the container should be started with tracing enabled

type RuncDriver

type RuncDriver struct {
	// contains filtered or unexported fields
}

RuncDriver is an implementation of the driver interface for Runc. IMPORTANT: This implementation does not protect instance metadata for thread safely. At this time there is no understood use case for multi-threaded use of this implementation.

func (*RuncDriver) Clean

func (r *RuncDriver) Clean() error

Clean will clean the environment; removing any remaining containers in the runc metadata

func (*RuncDriver) Close

func (r *RuncDriver) Close() error

Close allows the driver to handle any resource free/connection closing as necessary. Runc has no need to perform any actions on close.

func (*RuncDriver) Create

func (r *RuncDriver) Create(name, image, cmdOverride string, detached bool, trace bool) (Container, error)

Create will create a container instance matching the specific needs of a driver

func (*RuncDriver) Info

func (r *RuncDriver) Info() (string, error)

Info returns

func (*RuncDriver) Path

func (r *RuncDriver) Path() string

Path returns the binary path of the runc binary in use

func (*RuncDriver) Pause

func (r *RuncDriver) Pause(ctr Container) (string, int, error)

Pause will pause a container

func (*RuncDriver) Remove

func (r *RuncDriver) Remove(ctr Container) (string, int, error)

Remove will remove a container

func (*RuncDriver) Run

func (r *RuncDriver) Run(ctr Container) (string, int, error)

Run will execute a container using the driver. Note that if the container is specified to run detached, but the config.json for the bundle specifies a "tty" allocation, this runc invocation will fail due to the fact we cannot detach without providing a "--console" device to runc. Detached daemon/server bundles should not need a tty; stdin/out/err of the container will be ignored given this is for benchmarking not validating container operation.

func (*RuncDriver) Stop

func (r *RuncDriver) Stop(ctr Container) (string, int, error)

Stop will stop/kill a container

func (*RuncDriver) Type

func (r *RuncDriver) Type() Type

Type returns a driver.Type to indentify the driver implementation

func (*RuncDriver) Unpause

func (r *RuncDriver) Unpause(ctr Container) (string, int, error)

Unpause will unpause/resume a container

type Type

type Type int

Type represents the know implementations of the driver interface

const (
	// Docker represents the Docker driver implementation
	Docker Type = iota
	// Runc represents the runc-based driver implementation
	Runc
	// Containerd represents the containerd-based driver implementation
	// using the GRPC API via the containerd client library
	Containerd
	// Ctr represents the containerd legacy driver using the `ctr`
	// binary to drive containerd operations
	Ctr
	//CRI driver represents k8s Container Runtime Interface
	CRI
	// Null driver represents an empty driver for use by benchmarks that
	// require no driver
	Null
)

func StringToType

func StringToType(dtype string) Type

StringToType converts a driver stringified typename into its Type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL