Documentation ¶
Index ¶
- Constants
- func AppendTaskEnv(envVars []string, taskInfo *mesos.TaskInfo) []string
- func BindsForTask(taskInfo *mesos.TaskInfo) []string
- func CapAddForTask(taskInfo *mesos.TaskInfo) []string
- func CapDropForTask(taskInfo *mesos.TaskInfo) []string
- func CheckImage(client DockerClient, taskInfo *mesos.TaskInfo) bool
- func ConfigForTask(taskInfo *mesos.TaskInfo, forceCpuLimit bool, forceMemoryLimit bool, ...) *docker.CreateContainerOptions
- func EnvForTask(taskInfo *mesos.TaskInfo, labels map[string]string, addEnvVars []string) []string
- func FollowLogs(client DockerClient, containerId string, since int64, stdout io.Writer, ...)
- func GetContainerName(taskId *mesos.TaskID) string
- func GetExitCode(client DockerClient, containerId string) (int, error)
- func GetLogs(client DockerClient, containerId string, since int64, stdout io.Writer, ...)
- func LabelsForTask(taskInfo *mesos.TaskInfo) map[string]string
- func NetworkForTask(taskInfo *mesos.TaskInfo) string
- func PortBindingsForTask(taskInfo *mesos.TaskInfo) map[docker.Port][]docker.PortBinding
- func PortsForTask(taskInfo *mesos.TaskInfo) map[docker.Port]struct{}
- func PullImage(client DockerClient, taskInfo *mesos.TaskInfo, ...) error
- func StopContainer(client DockerClient, containerId string, timeout uint) error
- func VolumeDriverForTask(taskInfo *mesos.TaskInfo) string
- type DockerClient
- type MockDockerClient
- func (m *MockDockerClient) CreateContainer(opts docker.CreateContainerOptions) (*docker.Container, error)
- func (m *MockDockerClient) InspectContainer(id string) (*docker.Container, error)
- func (m *MockDockerClient) ListContainers(opts docker.ListContainersOptions) ([]docker.APIContainers, error)
- func (m *MockDockerClient) ListImages(opts docker.ListImagesOptions) ([]docker.APIImages, error)
- func (m *MockDockerClient) Logs(opts docker.LogsOptions) error
- func (m *MockDockerClient) PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration) error
- func (m *MockDockerClient) StartContainer(id string, hostConfig *docker.HostConfig) error
- func (m *MockDockerClient) StopContainer(id string, timeout uint) error
Constants ¶
const DockerNamePrefix = "mesos-"
Prefix used to name Docker containers in order to distinguish those created by Mesos from those created manually.
const (
// How many times a docker image pull will be retried on error
PullImageNumRetries = 5
)
Variables ¶
This section is empty.
Functions ¶
func AppendTaskEnv ¶ added in v0.9.2
Map Task Env to Docker Env
func BindsForTask ¶
BindsForTask turns Mesos volume information to Docker volume binds at runtime (equivalent to -v)
func CapAddForTask ¶
CapAddForTask scans for cap-adds and generate string slice
func CapDropForTask ¶
CapDropForTask scans for cap-drops and generate string slice
func CheckImage ¶
func CheckImage(client DockerClient, taskInfo *mesos.TaskInfo) bool
Loop through all the images and see if we have one with a match on this repo image:tag combination.
func ConfigForTask ¶
func ConfigForTask(taskInfo *mesos.TaskInfo, forceCpuLimit bool, forceMemoryLimit bool, useCpuShares bool, envVars []string) *docker.CreateContainerOptions
Generate a complete config with both Config and HostConfig. Does not attempt to be exhaustive in support for Docker options. Supports the most commonly used options. Others are not complex to add.
func EnvForTask ¶
Map Mesos environment settings to Docker environment (-e FOO=BAR). Adds a few environment variables derived from the labels we were passed, as well. Useful for services in containers to know more about their environment.
func FollowLogs ¶ added in v0.10.0
func FollowLogs(client DockerClient, containerId string, since int64, stdout io.Writer, stderr io.Writer)
FollowLogs will fetch the Docker logs since "since", and start pumping logs into the two writers that are passed in.
func GetContainerName ¶ added in v0.6.1
GetContainerName constructs a Mesos-friendly container name. This lets Mesos properly handle agent/master resolution without us.
func GetExitCode ¶ added in v0.6.3
func GetExitCode(client DockerClient, containerId string) (int, error)
GetExitCode returns the exit code for a container so that we can try to see how it exited and map that to a Mesos status.
func GetLogs ¶
func GetLogs(client DockerClient, containerId string, since int64, stdout io.Writer, stderr io.Writer)
GetLogs will fetch the Docker logs from a task and return two Readers that let us fetch the contents.
func LabelsForTask ¶
LabelsForTask maps Mesos parameter lables to Docker labels
func NetworkForTask ¶
NetworkForTask maps Mesos enum to strings for Docker
func PortBindingsForTask ¶
PortBindingsForTask returns the actual ports bound to this container, not just EXPOSEd (equivalent to -P)
func PortsForTask ¶
Translate Mesos TaskInfo port records in Docker ports map. These show up as EXPOSE
func PullImage ¶
func PullImage(client DockerClient, taskInfo *mesos.TaskInfo, authConfig *docker.AuthConfiguration) error
PullImage will pull the Docker image refered to in the taskInfo. Uses the Docker credentials passed in.
func StopContainer ¶
func StopContainer(client DockerClient, containerId string, timeout uint) error
Tries very hard to stop a container. Has to take a containerId instead of a mesos.TaskInfo because we don't have the TaskInfo in the KillTask callback from the executor driver.
func VolumeDriverForTask ¶ added in v0.9.3
VolumeDriverForTask scans for volume-driver
Types ¶
type DockerClient ¶
type DockerClient interface { CreateContainer(opts docker.CreateContainerOptions) (*docker.Container, error) InspectContainer(id string) (*docker.Container, error) ListContainers(opts docker.ListContainersOptions) ([]docker.APIContainers, error) ListImages(docker.ListImagesOptions) ([]docker.APIImages, error) Logs(opts docker.LogsOptions) error PullImage(docker.PullImageOptions, docker.AuthConfiguration) error StartContainer(id string, hostConfig *docker.HostConfig) error StopContainer(id string, timeout uint) error }
Our own narrowly-scoped interface for Docker client
type MockDockerClient ¶
type MockDockerClient struct { ValidOptions bool PullImageShouldError bool // Set either this or PullImageSuccessAfterNumRetries PullImageSuccessAfterNumRetries int // but not both PullImageRetries int Images []docker.APIImages ListImagesShouldError bool StopContainerShouldError bool StopContainerMaxFails int InspectContainerShouldError bool Container *docker.Container LogOutputString string LogErrorString string ListContainersShouldError bool ListContainersContainers []docker.APIContainers ContainerStarted bool // contains filtered or unexported fields }
func (*MockDockerClient) CreateContainer ¶
func (m *MockDockerClient) CreateContainer(opts docker.CreateContainerOptions) (*docker.Container, error)
func (*MockDockerClient) InspectContainer ¶
func (m *MockDockerClient) InspectContainer(id string) (*docker.Container, error)
func (*MockDockerClient) ListContainers ¶
func (m *MockDockerClient) ListContainers(opts docker.ListContainersOptions) ([]docker.APIContainers, error)
func (*MockDockerClient) ListImages ¶
func (m *MockDockerClient) ListImages(opts docker.ListImagesOptions) ([]docker.APIImages, error)
func (*MockDockerClient) Logs ¶
func (m *MockDockerClient) Logs(opts docker.LogsOptions) error
func (*MockDockerClient) PullImage ¶
func (m *MockDockerClient) PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration) error
func (*MockDockerClient) StartContainer ¶
func (m *MockDockerClient) StartContainer(id string, hostConfig *docker.HostConfig) error
func (*MockDockerClient) StopContainer ¶
func (m *MockDockerClient) StopContainer(id string, timeout uint) error