driver

package
v0.7.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2017 License: MPL-2.0 Imports: 46 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 added in v0.3.1

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 added in v0.5.5

func GetDockerCoordinator(config *dockerCoordinatorConfig) *dockerCoordinator

GetDockerCoordinator returns the shared dockerCoordinator instance

func GetKillTimeout added in v0.3.1

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 added in v0.3.0

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

func NewDockerCoordinator added in v0.5.5

func NewDockerCoordinator(config *dockerCoordinatorConfig) *dockerCoordinator

NewDockerCoordinator returns a new Docker coordinator

func SetEnvvars added in v0.6.0

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 added in v0.5.3

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 added in v0.5.3

func NewCreatedResources() *CreatedResources

func (*CreatedResources) Add added in v0.5.3

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

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

func (*CreatedResources) Copy added in v0.5.3

Copy returns a new deep copy of CreatedResrouces.

func (*CreatedResources) Hash added in v0.6.0

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

func (*CreatedResources) Merge added in v0.5.3

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 added in v0.5.3

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 DockerDriver

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

func (*DockerDriver) Abilities added in v0.5.0

func (d *DockerDriver) Abilities() DriverAbilities

func (*DockerDriver) Cleanup added in v0.5.3

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

func (*DockerDriver) FSIsolation added in v0.5.3

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 added in v0.3.1

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

func (*DockerDriver) Prestart added in v0.5.2

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 added in v0.3.2

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

Validate is used to validate the driver configuration

type DockerDriverAuth added in v0.2.0

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 added in v0.2.0

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
	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
}

func NewDockerDriverConfig added in v0.4.0

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

NewDockerDriverConfig returns a docker driver config by parsing the HCL config

func (*DockerDriverConfig) Validate added in v0.2.0

func (c *DockerDriverConfig) Validate() error

Validate validates a docker driver config

type DockerHandle added in v0.2.1

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

func (*DockerHandle) ContainerID added in v0.2.1

func (h *DockerHandle) ContainerID() string

func (*DockerHandle) Exec added in v0.6.0

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

func (*DockerHandle) ID added in v0.2.1

func (h *DockerHandle) ID() string

func (*DockerHandle) Kill added in v0.2.1

func (h *DockerHandle) Kill() error

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

func (*DockerHandle) Signal added in v0.5.0

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

func (*DockerHandle) Stats added in v0.4.0

func (*DockerHandle) Update added in v0.2.1

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

func (*DockerHandle) WaitCh added in v0.2.1

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

type DockerImageClient added in v0.5.5

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 added in v0.4.2

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

type DockerMount added in v0.6.1

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

type DockerVolumeDriverConfig added in v0.6.1

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

VolumeDriverConfig holds a map of volume driver specific options

type DockerVolumeOptions added in v0.6.1

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 added in v0.2.0

func NewRawExecDriver(ctx *DriverContext) Driver

NewRawExecDriver is used to create a new raw exec driver

func NewRktDriver added in v0.2.0

func NewRktDriver(ctx *DriverContext) Driver

NewRktDriver is used to create a new rkt driver

type DriverAbilities added in v0.5.0

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 added in v0.3.2

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 added in v0.6.0

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

type ExecCmdReturn added in v0.6.0

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 added in v0.5.0

func (d *ExecDriver) Abilities() DriverAbilities

func (*ExecDriver) Cleanup added in v0.5.3

func (*ExecDriver) FSIsolation added in v0.5.3

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 added in v0.3.0

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

func (*ExecDriver) Prestart added in v0.5.2

func (*ExecDriver) Start

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

func (*ExecDriver) Validate added in v0.3.2

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

Validate is used to validate the driver configuration

type ExecDriverConfig added in v0.2.0

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

type ExecutorPlugin added in v0.3.0

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

func (*ExecutorPlugin) Client added in v0.3.0

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

func (*ExecutorPlugin) Server added in v0.3.0

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

type ExecutorRPC added in v0.3.0

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

func (*ExecutorRPC) DeregisterServices added in v0.3.2

func (e *ExecutorRPC) DeregisterServices() error

func (*ExecutorRPC) Exec added in v0.6.0

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

func (*ExecutorRPC) Exit added in v0.3.0

func (e *ExecutorRPC) Exit() error

func (*ExecutorRPC) LaunchCmd added in v0.3.0

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

func (*ExecutorRPC) LaunchSyslogServer added in v0.3.2

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

func (*ExecutorRPC) SetContext added in v0.5.0

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

func (*ExecutorRPC) ShutDown added in v0.3.0

func (e *ExecutorRPC) ShutDown() error

func (*ExecutorRPC) Signal added in v0.5.0

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

func (*ExecutorRPC) Stats added in v0.4.0

func (*ExecutorRPC) UpdateLogConfig added in v0.3.0

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

func (*ExecutorRPC) UpdateTask added in v0.3.2

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

func (*ExecutorRPC) Version added in v0.3.2

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

func (*ExecutorRPC) Wait added in v0.3.0

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

type ExecutorRPCServer added in v0.3.0

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

func (*ExecutorRPCServer) DeregisterServices added in v0.3.2

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

func (*ExecutorRPCServer) Exec added in v0.6.0

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

func (*ExecutorRPCServer) Exit added in v0.3.0

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

func (*ExecutorRPCServer) LaunchCmd added in v0.3.0

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

func (*ExecutorRPCServer) LaunchSyslogServer added in v0.3.2

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

func (*ExecutorRPCServer) SetContext added in v0.5.0

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

func (*ExecutorRPCServer) ShutDown added in v0.3.0

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

func (*ExecutorRPCServer) Signal added in v0.5.0

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

func (*ExecutorRPCServer) Stats added in v0.4.0

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

func (*ExecutorRPCServer) UpdateLogConfig added in v0.3.0

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

func (*ExecutorRPCServer) UpdateTask added in v0.3.2

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

func (*ExecutorRPCServer) Version added in v0.3.2

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

func (*ExecutorRPCServer) Wait added in v0.3.0

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 added in v0.5.0

func (d *JavaDriver) Abilities() DriverAbilities

func (*JavaDriver) Cleanup added in v0.5.3

func (*JavaDriver) FSIsolation added in v0.5.3

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 added in v0.5.2

func (*JavaDriver) Start

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

func (*JavaDriver) Validate added in v0.3.2

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

Validate is used to validate the driver configuration

type JavaDriverConfig added in v0.2.0

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 added in v0.5.3

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

type LaunchCmdArgs added in v0.3.0

type LaunchCmdArgs struct {
	Cmd *executor.ExecCommand
}

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

type LogEventFn added in v0.5.2

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

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

type PluginReattachConfig added in v0.3.0

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 added in v0.3.0

func NewPluginReattachConfig(c *plugin.ReattachConfig) *PluginReattachConfig

func (*PluginReattachConfig) PluginConfig added in v0.3.0

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

PluginConfig returns a config from an ExecutorReattachConfig

type PrestartResponse added in v0.6.0

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 added in v0.6.0

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 added in v0.5.0

func (d *QemuDriver) Abilities() DriverAbilities

func (*QemuDriver) Cleanup added in v0.5.3

func (*QemuDriver) FSIsolation added in v0.5.3

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 added in v0.5.2

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 added in v0.3.2

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

Validate is used to validate the driver configuration

type QemuDriverConfig added in v0.2.0

type QemuDriverConfig struct {
	ImagePath   string           `mapstructure:"image_path"`
	Accelerator string           `mapstructure:"accelerator"`
	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 added in v0.2.0

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 added in v0.5.0

func (d *RawExecDriver) Abilities() DriverAbilities

func (*RawExecDriver) Cleanup added in v0.5.3

func (*RawExecDriver) FSIsolation added in v0.5.3

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

func (*RawExecDriver) Fingerprint added in v0.2.0

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

func (*RawExecDriver) Open added in v0.2.0

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

func (*RawExecDriver) Prestart added in v0.5.2

func (*RawExecDriver) Start added in v0.2.0

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

func (*RawExecDriver) Validate added in v0.3.2

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

Validate is used to validate the driver configuration

type RktDriver added in v0.2.0

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 added in v0.5.0

func (d *RktDriver) Abilities() DriverAbilities

func (*RktDriver) Cleanup added in v0.5.3

func (*RktDriver) FSIsolation added in v0.5.3

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

func (*RktDriver) Fingerprint added in v0.2.0

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

func (*RktDriver) Open added in v0.2.0

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

func (*RktDriver) Periodic added in v0.5.0

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

func (*RktDriver) Prestart added in v0.5.2

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

func (*RktDriver) Start added in v0.2.0

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

Run an existing Rkt image.

func (*RktDriver) Validate added in v0.3.2

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

Validate is used to validate the driver configuration

type RktDriverConfig added in v0.2.0

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 added in v0.6.0

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 added in v0.6.0

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