driver

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2017 License: MPL-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NoSuchContainerError is returned by the docker daemon if the container
	// does not exist.
	NoSuchContainerError = "No such container"
)

Variables

View Source
var (

	// The statistics the Docker driver exposes
	DockerMeasuredMemStats = []string{"RSS", "Cache", "Swap", "Max Usage"}
	DockerMeasuredCpuStats = []string{"Throttled Periods", "Throttled Time", "Percent"}
)
View Source
var (
	// BuiltinDrivers contains the built in registered drivers
	// which are available for allocation handling
	BuiltinDrivers = map[string]Factory{
		"docker":   NewDockerDriver,
		"exec":     NewExecDriver,
		"raw_exec": NewRawExecDriver,
		"java":     NewJavaDriver,
		"qemu":     NewQemuDriver,
		"rkt":      NewRktDriver,
	}

	// DriverStatsNotImplemented is the error to be returned if a driver doesn't
	// implement stats.
	DriverStatsNotImplemented = errors.New("stats not implemented for driver")
)
View Source
var HandshakeConfig = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "NOMAD_PLUGIN_MAGIC_COOKIE",
	MagicCookieValue: "e4327c2e01eabfd75a8a67adb114fb34a757d57eee7728d857a8cec6e91a7255",
}

Functions

func GetAbsolutePath

func GetAbsolutePath(bin string) (string, error)

GetAbsolutePath returns the absolute path of the passed binary by resolving it in the path and following symlinks.

func GetDockerCoordinator

func GetDockerCoordinator(config *dockerCoordinatorConfig) *dockerCoordinator

GetDockerCoordinator returns the shared dockerCoordinator instance

func GetKillTimeout

func GetKillTimeout(desired, max time.Duration) time.Duration

GetKillTimeout returns the kill timeout to use given the tasks desired kill timeout and the operator configured max kill timeout.

func GetPluginMap

func GetPluginMap(w io.Writer, logLevel string) map[string]plugin.Plugin

func NewDockerCoordinator

func NewDockerCoordinator(config *dockerCoordinatorConfig) *dockerCoordinator

NewDockerCoordinator returns a new Docker coordinator

func SetEnvvars

func SetEnvvars(envBuilder *env.Builder, fsi cstructs.FSIsolation, taskDir *allocdir.TaskDir, conf *config.Config)

SetEnvvars sets path and host env vars depending on the FS isolation used.

Types

type CreatedResources

type CreatedResources struct {
	Resources map[string][]string
}

CreatedResources is a map of resources (eg downloaded images) created by a driver that must be cleaned up.

func NewCreatedResources

func NewCreatedResources() *CreatedResources

func (*CreatedResources) Add

func (r *CreatedResources) Add(k, v string)

Add a new resource if it doesn't already exist.

func (*CreatedResources) Copy

Copy returns a new deep copy of CreatedResrouces.

func (*CreatedResources) Hash

func (r *CreatedResources) Hash() []byte

func (*CreatedResources) Merge

func (r *CreatedResources) Merge(o *CreatedResources)

Merge another CreatedResources into this one. If the other CreatedResources is nil this method is a noop.

func (*CreatedResources) Remove

func (r *CreatedResources) Remove(k, needle string) bool

Remove a resource. Return true if removed, otherwise false.

Removes the entire key if the needle is the last value in the list.

type DockerDevice

type DockerDevice struct {
	HostPath          string `mapstructure:"host_path"`
	ContainerPath     string `mapstructure:"container_path"`
	CgroupPermissions string `mapstructure:"cgroup_permissions"`
}

type DockerDriver

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

func (*DockerDriver) Abilities

func (d *DockerDriver) Abilities() DriverAbilities

func (*DockerDriver) Cleanup

func (d *DockerDriver) Cleanup(_ *ExecContext, res *CreatedResources) error

func (*DockerDriver) FSIsolation

func (d *DockerDriver) FSIsolation() cstructs.FSIsolation

func (*DockerDriver) Fingerprint

func (d *DockerDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error)

func (*DockerDriver) Open

func (d *DockerDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, error)

func (*DockerDriver) Periodic

func (d *DockerDriver) Periodic() (bool, time.Duration)

func (*DockerDriver) Prestart

func (d *DockerDriver) Prestart(ctx *ExecContext, task *structs.Task) (*PrestartResponse, error)

func (*DockerDriver) Start

func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (*StartResponse, error)

func (*DockerDriver) Validate

func (d *DockerDriver) Validate(config map[string]interface{}) error

Validate is used to validate the driver configuration

type DockerDriverAuth

type DockerDriverAuth struct {
	Username      string `mapstructure:"username"`       // username for the registry
	Password      string `mapstructure:"password"`       // password to access the registry
	Email         string `mapstructure:"email"`          // email address of the user who is allowed to access the registry
	ServerAddress string `mapstructure:"server_address"` // server address of the registry
}

type DockerDriverConfig

type DockerDriverConfig struct {
	ImageName        string              `mapstructure:"image"`              // Container's Image Name
	LoadImage        string              `mapstructure:"load"`               // LoadImage is a path to an image archive file
	Command          string              `mapstructure:"command"`            // The Command to run when the container starts up
	Args             []string            `mapstructure:"args"`               // The arguments to the Command
	IpcMode          string              `mapstructure:"ipc_mode"`           // The IPC mode of the container - host and none
	NetworkMode      string              `mapstructure:"network_mode"`       // The network mode of the container - host, nat and none
	NetworkAliases   []string            `mapstructure:"network_aliases"`    // The network-scoped alias for the container
	IPv4Address      string              `mapstructure:"ipv4_address"`       // The container ipv4 address
	IPv6Address      string              `mapstructure:"ipv6_address"`       // the container ipv6 address
	PidMode          string              `mapstructure:"pid_mode"`           // The PID mode of the container - host and none
	UTSMode          string              `mapstructure:"uts_mode"`           // The UTS mode of the container - host and none
	UsernsMode       string              `mapstructure:"userns_mode"`        // The User namespace mode of the container - host and none
	PortMapRaw       []map[string]string `mapstructure:"port_map"`           //
	PortMap          map[string]int      `mapstructure:"-"`                  // A map of host port labels and the ports exposed on the container
	Privileged       bool                `mapstructure:"privileged"`         // Flag to run the container in privileged mode
	SysctlRaw        []map[string]string `mapstructure:"sysctl"`             //
	Sysctl           map[string]string   `mapstructure:"-"`                  // The sysctl custom configurations
	UlimitRaw        []map[string]string `mapstructure:"ulimit"`             //
	Ulimit           []docker.ULimit     `mapstructure:"-"`                  // The ulimit custom configurations
	DNSServers       []string            `mapstructure:"dns_servers"`        // DNS Server for containers
	DNSSearchDomains []string            `mapstructure:"dns_search_domains"` // DNS Search domains for containers
	DNSOptions       []string            `mapstructure:"dns_options"`        // DNS Options
	ExtraHosts       []string            `mapstructure:"extra_hosts"`        // Add host to /etc/hosts (host:IP)
	Hostname         string              `mapstructure:"hostname"`           // Hostname for containers
	LabelsRaw        []map[string]string `mapstructure:"labels"`             //
	Labels           map[string]string   `mapstructure:"-"`                  // Labels to set when the container starts up
	Auth             []DockerDriverAuth  `mapstructure:"auth"`               // Authentication credentials for a private Docker registry
	AuthSoftFail     bool                `mapstructure:"auth_soft_fail"`     // Soft-fail if auth creds are provided but fail
	TTY              bool                `mapstructure:"tty"`                // Allocate a Pseudo-TTY
	Interactive      bool                `mapstructure:"interactive"`        // Keep STDIN open even if not attached
	ShmSize          int64               `mapstructure:"shm_size"`           // Size of /dev/shm of the container in bytes
	WorkDir          string              `mapstructure:"work_dir"`           // Working directory inside the container
	Logging          []DockerLoggingOpts `mapstructure:"logging"`            // Logging options for syslog server
	Volumes          []string            `mapstructure:"volumes"`            // Host-Volumes to mount in, syntax: /path/to/host/directory:/destination/path/in/container
	Mounts           []DockerMount       `mapstructure:"mounts"`             // Docker volumes to mount
	VolumeDriver     string              `mapstructure:"volume_driver"`      // Docker volume driver used for the container's volumes
	ForcePull        bool                `mapstructure:"force_pull"`         // Always force pull before running image, useful if your tags are mutable
	MacAddress       string              `mapstructure:"mac_address"`        // Pin mac address to container
	SecurityOpt      []string            `mapstructure:"security_opt"`       // Flags to pass directly to security-opt
	Devices          []DockerDevice      `mapstructure:"devices"`            // To allow mounting USB or other serial control devices
}

DockerDriverConfig defines the user specified config block in a jobspec

func NewDockerDriverConfig

func NewDockerDriverConfig(task *structs.Task, env *env.TaskEnv) (*DockerDriverConfig, error)

NewDockerDriverConfig returns a docker driver config by parsing the HCL config

func (*DockerDriverConfig) Validate

func (c *DockerDriverConfig) Validate() error

Validate validates a docker driver config

type DockerHandle

type DockerHandle struct {
	Image   string
	ImageID string
	// contains filtered or unexported fields
}

func (*DockerHandle) ContainerID

func (h *DockerHandle) ContainerID() string

func (*DockerHandle) Exec

func (h *DockerHandle) Exec(ctx context.Context, cmd string, args []string) ([]byte, int, error)

func (*DockerHandle) ID

func (h *DockerHandle) ID() string

func (*DockerHandle) Kill

func (h *DockerHandle) Kill() error

Kill is used to terminate the task. This uses `docker stop -t killTimeout`

func (*DockerHandle) Signal

func (h *DockerHandle) Signal(s os.Signal) error

func (*DockerHandle) Stats

func (*DockerHandle) Update

func (h *DockerHandle) Update(task *structs.Task) error

func (*DockerHandle) WaitCh

func (h *DockerHandle) WaitCh() chan *dstructs.WaitResult

type DockerImageClient

type DockerImageClient interface {
	PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration) error
	InspectImage(id string) (*docker.Image, error)
	RemoveImage(id string) error
}

DockerImageClient provides the methods required to do CRUD operations on the Docker images

type DockerLoggingOpts

type DockerLoggingOpts struct {
	Type      string              `mapstructure:"type"`
	ConfigRaw []map[string]string `mapstructure:"config"`
	Config    map[string]string   `mapstructure:"-"`
}

type DockerMount

type DockerMount struct {
	Target        string                 `mapstructure:"target"`
	Source        string                 `mapstructure:"source"`
	ReadOnly      bool                   `mapstructure:"readonly"`
	VolumeOptions []*DockerVolumeOptions `mapstructure:"volume_options"`
}

type DockerVolumeDriverConfig

type DockerVolumeDriverConfig struct {
	Name    string              `mapstructure:"name"`
	Options []map[string]string `mapstructure:"options"`
}

VolumeDriverConfig holds a map of volume driver specific options

type DockerVolumeOptions

type DockerVolumeOptions struct {
	NoCopy       bool                       `mapstructure:"no_copy"`
	Labels       []map[string]string        `mapstructure:"labels"`
	DriverConfig []DockerVolumeDriverConfig `mapstructure:"driver_config"`
}

type Driver

type Driver interface {
	// Drivers must support the fingerprint interface for detection
	fingerprint.Fingerprint

	// Prestart prepares the task environment and performs expensive
	// intialization steps like downloading images.
	//
	// CreatedResources may be non-nil even when an error occurs.
	Prestart(*ExecContext, *structs.Task) (*PrestartResponse, error)

	// Start is used to begin task execution. If error is nil,
	// StartResponse.Handle will be the handle to the task's executor.
	// StartResponse.Network may be nil if the task doesn't configure a
	// network.
	Start(ctx *ExecContext, task *structs.Task) (*StartResponse, error)

	// Open is used to re-open a handle to a task
	Open(ctx *ExecContext, handleID string) (DriverHandle, error)

	// Cleanup is called to remove resources which were created for a task
	// and no longer needed. Cleanup is not called if CreatedResources is
	// nil.
	//
	// If Cleanup returns a recoverable error it may be retried. On retry
	// it will be passed the same CreatedResources, so all successfully
	// cleaned up resources should be removed or handled idempotently.
	Cleanup(*ExecContext, *CreatedResources) error

	// Drivers must validate their configuration
	Validate(map[string]interface{}) error

	// Abilities returns the abilities of the driver
	Abilities() DriverAbilities

	// FSIsolation returns the method of filesystem isolation used
	FSIsolation() cstructs.FSIsolation
}

Driver is used for execution of tasks. This allows Nomad to support many pluggable implementations of task drivers. Examples could include LXC, Docker, Qemu, etc.

func NewDockerDriver

func NewDockerDriver(ctx *DriverContext) Driver

func NewDriver

func NewDriver(name string, ctx *DriverContext) (Driver, error)

NewDriver is used to instantiate and return a new driver given the name and a logger

func NewExecDriver

func NewExecDriver(ctx *DriverContext) Driver

NewExecDriver is used to create a new exec driver

func NewJavaDriver

func NewJavaDriver(ctx *DriverContext) Driver

NewJavaDriver is used to create a new exec driver

func NewQemuDriver

func NewQemuDriver(ctx *DriverContext) Driver

NewQemuDriver is used to create a new exec driver

func NewRawExecDriver

func NewRawExecDriver(ctx *DriverContext) Driver

NewRawExecDriver is used to create a new raw exec driver

func NewRktDriver

func NewRktDriver(ctx *DriverContext) Driver

NewRktDriver is used to create a new rkt driver

type DriverAbilities

type DriverAbilities struct {
	// SendSignals marks the driver as being able to send signals
	SendSignals bool

	// Exec marks the driver as being able to execute arbitrary commands
	// such as health checks. Used by the ScriptExecutor interface.
	Exec bool
}

DriverAbilities marks the abilities the driver has.

type DriverContext

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

DriverContext is a means to inject dependencies such as loggers, configs, and node attributes into a Driver without having to change the Driver interface each time we do it. Used in conjection with Factory, above.

func NewDriverContext

func NewDriverContext(taskName, allocID string, config *config.Config, node *structs.Node,
	logger *log.Logger, eventEmitter LogEventFn) *DriverContext

NewDriverContext initializes a new DriverContext with the specified fields. This enables other packages to create DriverContexts but keeps the fields private to the driver. If we want to change this later we can gorename all of the fields in DriverContext.

func NewEmptyDriverContext

func NewEmptyDriverContext() *DriverContext

NewEmptyDriverContext returns a DriverContext with all fields set to their zero value.

type DriverHandle

type DriverHandle interface {
	// Returns an opaque handle that can be used to re-open the handle
	ID() string

	// WaitCh is used to return a channel used wait for task completion
	WaitCh() chan *dstructs.WaitResult

	// Update is used to update the task if possible and update task related
	// configurations.
	Update(task *structs.Task) error

	// Kill is used to stop the task
	Kill() error

	// Stats returns aggregated stats of the driver
	Stats() (*cstructs.TaskResourceUsage, error)

	// Signal is used to send a signal to the task
	Signal(s os.Signal) error

	// ScriptExecutor is an interface used to execute commands such as
	// health check scripts in the a DriverHandle's context.
	ScriptExecutor
}

DriverHandle is an opaque handle into a driver used for task manipulation

type ExecCmdArgs

type ExecCmdArgs struct {
	Deadline time.Time
	Name     string
	Args     []string
}

type ExecCmdReturn

type ExecCmdReturn struct {
	Output []byte
	Code   int
}

type ExecContext

type ExecContext struct {
	// TaskDir contains information about the task directory structure.
	TaskDir *allocdir.TaskDir

	// TaskEnv contains the task's environment variables.
	TaskEnv *env.TaskEnv
}

ExecContext is a task's execution context

func NewExecContext

func NewExecContext(td *allocdir.TaskDir, te *env.TaskEnv) *ExecContext

NewExecContext is used to create a new execution context

type ExecDriver

type ExecDriver struct {
	DriverContext
	// contains filtered or unexported fields
}

ExecDriver fork/execs tasks using as many of the underlying OS's isolation features.

func (*ExecDriver) Abilities

func (d *ExecDriver) Abilities() DriverAbilities

func (*ExecDriver) Cleanup

func (*ExecDriver) FSIsolation

func (d *ExecDriver) FSIsolation() cstructs.FSIsolation

func (*ExecDriver) Fingerprint

func (d *ExecDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error)

func (*ExecDriver) Open

func (d *ExecDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, error)

func (*ExecDriver) Periodic

func (d *ExecDriver) Periodic() (bool, time.Duration)

func (*ExecDriver) Prestart

func (*ExecDriver) Start

func (d *ExecDriver) Start(ctx *ExecContext, task *structs.Task) (*StartResponse, error)

func (*ExecDriver) Validate

func (d *ExecDriver) Validate(config map[string]interface{}) error

Validate is used to validate the driver configuration

type ExecDriverConfig

type ExecDriverConfig struct {
	Command string   `mapstructure:"command"`
	Args    []string `mapstructure:"args"`
}

type ExecutorPlugin

type ExecutorPlugin struct {
	Impl *ExecutorRPCServer
	// contains filtered or unexported fields
}

func (*ExecutorPlugin) Client

func (p *ExecutorPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*ExecutorPlugin) Server

func (p *ExecutorPlugin) Server(*plugin.MuxBroker) (interface{}, error)

type ExecutorRPC

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

func (*ExecutorRPC) DeregisterServices

func (e *ExecutorRPC) DeregisterServices() error

func (*ExecutorRPC) Exec

func (e *ExecutorRPC) Exec(deadline time.Time, name string, args []string) ([]byte, int, error)

func (*ExecutorRPC) Exit

func (e *ExecutorRPC) Exit() error

func (*ExecutorRPC) LaunchCmd

func (e *ExecutorRPC) LaunchCmd(cmd *executor.ExecCommand) (*executor.ProcessState, error)

func (*ExecutorRPC) LaunchSyslogServer

func (e *ExecutorRPC) LaunchSyslogServer() (*executor.SyslogServerState, error)

func (*ExecutorRPC) SetContext

func (e *ExecutorRPC) SetContext(ctx *executor.ExecutorContext) error

func (*ExecutorRPC) ShutDown

func (e *ExecutorRPC) ShutDown() error

func (*ExecutorRPC) Signal

func (e *ExecutorRPC) Signal(s os.Signal) error

func (*ExecutorRPC) Stats

func (*ExecutorRPC) UpdateLogConfig

func (e *ExecutorRPC) UpdateLogConfig(logConfig *structs.LogConfig) error

func (*ExecutorRPC) UpdateTask

func (e *ExecutorRPC) UpdateTask(task *structs.Task) error

func (*ExecutorRPC) Version

func (e *ExecutorRPC) Version() (*executor.ExecutorVersion, error)

func (*ExecutorRPC) Wait

func (e *ExecutorRPC) Wait() (*executor.ProcessState, error)

type ExecutorRPCServer

type ExecutorRPCServer struct {
	Impl executor.Executor
	// contains filtered or unexported fields
}

func (*ExecutorRPCServer) DeregisterServices

func (e *ExecutorRPCServer) DeregisterServices(args interface{}, resp *interface{}) error

func (*ExecutorRPCServer) Exec

func (e *ExecutorRPCServer) Exec(args ExecCmdArgs, result *ExecCmdReturn) error

func (*ExecutorRPCServer) Exit

func (e *ExecutorRPCServer) Exit(args interface{}, resp *interface{}) error

func (*ExecutorRPCServer) LaunchCmd

func (e *ExecutorRPCServer) LaunchCmd(args LaunchCmdArgs, ps *executor.ProcessState) error

func (*ExecutorRPCServer) LaunchSyslogServer

func (e *ExecutorRPCServer) LaunchSyslogServer(args interface{}, ss *executor.SyslogServerState) error

func (*ExecutorRPCServer) SetContext

func (e *ExecutorRPCServer) SetContext(args *executor.ExecutorContext, resp *interface{}) error

func (*ExecutorRPCServer) ShutDown

func (e *ExecutorRPCServer) ShutDown(args interface{}, resp *interface{}) error

func (*ExecutorRPCServer) Signal

func (e *ExecutorRPCServer) Signal(args os.Signal, resp *interface{}) error

func (*ExecutorRPCServer) Stats

func (e *ExecutorRPCServer) Stats(args interface{}, resourceUsage *cstructs.TaskResourceUsage) error

func (*ExecutorRPCServer) UpdateLogConfig

func (e *ExecutorRPCServer) UpdateLogConfig(args *structs.LogConfig, resp *interface{}) error

func (*ExecutorRPCServer) UpdateTask

func (e *ExecutorRPCServer) UpdateTask(args *structs.Task, resp *interface{}) error

func (*ExecutorRPCServer) Version

func (e *ExecutorRPCServer) Version(args interface{}, version *executor.ExecutorVersion) error

func (*ExecutorRPCServer) Wait

func (e *ExecutorRPCServer) Wait(args interface{}, ps *executor.ProcessState) error

type Factory

type Factory func(*DriverContext) Driver

Factory is used to instantiate a new Driver

type JavaDriver

type JavaDriver struct {
	DriverContext
	fingerprint.StaticFingerprinter
	// contains filtered or unexported fields
}

JavaDriver is a simple driver to execute applications packaged in Jars. It literally just fork/execs tasks with the java command.

func (*JavaDriver) Abilities

func (d *JavaDriver) Abilities() DriverAbilities

func (*JavaDriver) Cleanup

func (*JavaDriver) FSIsolation

func (d *JavaDriver) FSIsolation() cstructs.FSIsolation

func (*JavaDriver) Fingerprint

func (d *JavaDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error)

func (*JavaDriver) Open

func (d *JavaDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, error)

func (*JavaDriver) Prestart

func (*JavaDriver) Start

func (d *JavaDriver) Start(ctx *ExecContext, task *structs.Task) (*StartResponse, error)

func (*JavaDriver) Validate

func (d *JavaDriver) Validate(config map[string]interface{}) error

Validate is used to validate the driver configuration

type JavaDriverConfig

type JavaDriverConfig struct {
	Class     string   `mapstructure:"class"`
	ClassPath string   `mapstructure:"class_path"`
	JarPath   string   `mapstructure:"jar_path"`
	JvmOpts   []string `mapstructure:"jvm_options"`
	Args      []string `mapstructure:"args"`
}

func NewJavaDriverConfig

func NewJavaDriverConfig(task *structs.Task, env *env.TaskEnv) (*JavaDriverConfig, error)

type LaunchCmdArgs

type LaunchCmdArgs struct {
	Cmd *executor.ExecCommand
}

LaunchCmdArgs wraps a user command and the args for the purposes of RPC

type LogEventFn

type LogEventFn func(message string, args ...interface{})

LogEventFn is a callback which allows Drivers to emit task events.

type PluginReattachConfig

type PluginReattachConfig struct {
	Pid      int
	AddrNet  string
	AddrName string
}

ExecutorReattachConfig is the config that we seralize and de-serialize and store in disk

func NewPluginReattachConfig

func NewPluginReattachConfig(c *plugin.ReattachConfig) *PluginReattachConfig

func (*PluginReattachConfig) PluginConfig

func (c *PluginReattachConfig) PluginConfig() *plugin.ReattachConfig

PluginConfig returns a config from an ExecutorReattachConfig

type PrestartResponse

type PrestartResponse struct {
	// CreatedResources by the driver.
	CreatedResources *CreatedResources

	// Network contains driver-specific network parameters such as the port
	// map between the host and a container.
	//
	// Since the network configuration may not be fully populated by
	// Prestart, it will only be used for creating an environment for
	// Start. It will be overridden by the DriverNetwork returned by Start.
	Network *cstructs.DriverNetwork
}

PrestartResponse is driver state returned by Driver.Prestart.

func NewPrestartResponse

func NewPrestartResponse() *PrestartResponse

NewPrestartResponse creates a new PrestartResponse with CreatedResources initialized.

type QemuDriver

type QemuDriver struct {
	DriverContext
	fingerprint.StaticFingerprinter
	// contains filtered or unexported fields
}

QemuDriver is a driver for running images via Qemu We attempt to chose sane defaults for now, with more configuration available planned in the future

func (*QemuDriver) Abilities

func (d *QemuDriver) Abilities() DriverAbilities

func (*QemuDriver) Cleanup

func (*QemuDriver) FSIsolation

func (d *QemuDriver) FSIsolation() cstructs.FSIsolation

func (*QemuDriver) Fingerprint

func (d *QemuDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error)

func (*QemuDriver) Open

func (d *QemuDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, error)

func (*QemuDriver) Prestart

func (d *QemuDriver) Prestart(_ *ExecContext, task *structs.Task) (*PrestartResponse, error)

func (*QemuDriver) Start

func (d *QemuDriver) Start(ctx *ExecContext, task *structs.Task) (*StartResponse, error)

Run an existing Qemu image. Start() will pull down an existing, valid Qemu image and save it to the Drivers Allocation Dir

func (*QemuDriver) Validate

func (d *QemuDriver) Validate(config map[string]interface{}) error

Validate is used to validate the driver configuration

type QemuDriverConfig

type QemuDriverConfig struct {
	ImagePath        string           `mapstructure:"image_path"`
	Accelerator      string           `mapstructure:"accelerator"`
	GracefulShutdown bool             `mapstructure:"graceful_shutdown"`
	PortMap          []map[string]int `mapstructure:"port_map"` // A map of host port labels and to guest ports.
	Args             []string         `mapstructure:"args"`     // extra arguments to qemu executable
}

type RawExecDriver

type RawExecDriver struct {
	DriverContext
	fingerprint.StaticFingerprinter
}

The RawExecDriver is a privileged version of the exec driver. It provides no resource isolation and just fork/execs. The Exec driver should be preferred and this should only be used when explicitly needed.

func (*RawExecDriver) Abilities

func (d *RawExecDriver) Abilities() DriverAbilities

func (*RawExecDriver) Cleanup

func (*RawExecDriver) FSIsolation

func (d *RawExecDriver) FSIsolation() cstructs.FSIsolation

func (*RawExecDriver) Fingerprint

func (d *RawExecDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error)

func (*RawExecDriver) Open

func (d *RawExecDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, error)

func (*RawExecDriver) Prestart

func (*RawExecDriver) Start

func (d *RawExecDriver) Start(ctx *ExecContext, task *structs.Task) (*StartResponse, error)

func (*RawExecDriver) Validate

func (d *RawExecDriver) Validate(config map[string]interface{}) error

Validate is used to validate the driver configuration

type RktDriver

type RktDriver struct {
	DriverContext
	// contains filtered or unexported fields
}

RktDriver is a driver for running images via Rkt We attempt to chose sane defaults for now, with more configuration available planned in the future

func (*RktDriver) Abilities

func (d *RktDriver) Abilities() DriverAbilities

func (*RktDriver) Cleanup

func (*RktDriver) FSIsolation

func (d *RktDriver) FSIsolation() cstructs.FSIsolation

func (*RktDriver) Fingerprint

func (d *RktDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error)

func (*RktDriver) Open

func (d *RktDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, error)

func (*RktDriver) Periodic

func (d *RktDriver) Periodic() (bool, time.Duration)

func (*RktDriver) Prestart

func (d *RktDriver) Prestart(ctx *ExecContext, task *structs.Task) (*PrestartResponse, error)

func (*RktDriver) Start

func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (*StartResponse, error)

Run an existing Rkt image.

func (*RktDriver) Validate

func (d *RktDriver) Validate(config map[string]interface{}) error

Validate is used to validate the driver configuration

type RktDriverConfig

type RktDriverConfig struct {
	ImageName        string              `mapstructure:"image"`
	Command          string              `mapstructure:"command"`
	Args             []string            `mapstructure:"args"`
	TrustPrefix      string              `mapstructure:"trust_prefix"`
	DNSServers       []string            `mapstructure:"dns_servers"`        // DNS Server for containers
	DNSSearchDomains []string            `mapstructure:"dns_search_domains"` // DNS Search domains for containers
	Net              []string            `mapstructure:"net"`                // Networks for the containers
	PortMapRaw       []map[string]string `mapstructure:"port_map"`           //
	PortMap          map[string]string   `mapstructure:"-"`                  // A map of host port and the port name defined in the image manifest file
	Volumes          []string            `mapstructure:"volumes"`            // Host-Volumes to mount in, syntax: /path/to/host/directory:/destination/path/in/container[:readOnly]
	InsecureOptions  []string            `mapstructure:"insecure_options"`   // list of args for --insecure-options

	NoOverlay bool `mapstructure:"no_overlay"` // disable overlayfs for rkt run
	Debug     bool `mapstructure:"debug"`      // Enable debug option for rkt command
}

type ScriptExecutor

type ScriptExecutor interface {
	Exec(ctx context.Context, cmd string, args []string) ([]byte, int, error)
}

ScriptExecutor is an interface that supports Exec()ing commands in the driver's context. Split out of DriverHandle to ease testing.

type StartResponse

type StartResponse struct {
	// Handle to the driver's task executor for controlling the lifecycle
	// of the task.
	Handle DriverHandle

	// Network contains driver-specific network parameters such as the port
	// map between the host and a container.
	//
	// Network may be nil as not all drivers or configurations create
	// networks.
	Network *cstructs.DriverNetwork
}

StartResponse is returned by Driver.Start.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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