executor

package
v0.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2016 License: MPL-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// The statistics the basic executor exposes
	ExecutorBasicMeasuredMemStats = []string{"RSS", "Swap"}
	ExecutorBasicMeasuredCpuStats = []string{"System Mode", "User Mode", "Percent"}
)
View Source
var (

	// The statistics the executor exposes when using cgroups
	ExecutorCgroupMeasuredMemStats = []string{"RSS", "Cache", "Swap", "Max Usage", "Kernel Usage", "Kernel Max Usage"}
	ExecutorCgroupMeasuredCpuStats = []string{"System Mode", "User Mode", "Throttled Periods", "Throttled Time", "Percent"}
)

Functions

func ClientCleanup added in v0.4.1

func ClientCleanup(ic *dstructs.IsolationConfig, pid int) error

ClientCleanup is the cleanup routine that a Nomad Client uses to remove the reminants of a child UniversalExecutor.

func DestroyCgroup added in v0.3.0

func DestroyCgroup(groups *cgroupConfig.Cgroup, cgPaths map[string]string, executorPid int) error

destroyCgroup kills all processes in the cgroup and removes the cgroup configuration from the host. This function is idempotent.

Types

type ConsulContext added in v0.3.2

type ConsulContext struct {
	// ConsulConfig contains the configuration information for talking
	// with this Nomad Agent's Consul Agent.
	ConsulConfig *config.ConsulConfig

	// ContainerID is the ID of the container
	ContainerID string

	// TLSCert is the cert which docker client uses while interactng with the docker
	// daemon over TLS
	TLSCert string

	// TLSCa is the CA which the docker client uses while interacting with the docker
	// daeemon over TLS
	TLSCa string

	// TLSKey is the TLS key which the docker client uses while interacting with
	// the docker daemon
	TLSKey string

	// DockerEndpoint is the endpoint of the docker daemon
	DockerEndpoint string
}

ConsulContext holds context to configure the Consul client and run checks

type DockerScriptCheck added in v0.3.2

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

DockerScriptCheck runs nagios compatible scripts in a docker container and provides the check result

func (*DockerScriptCheck) ID added in v0.3.2

func (d *DockerScriptCheck) ID() string

ID returns the check id

func (*DockerScriptCheck) Interval added in v0.3.2

func (d *DockerScriptCheck) Interval() time.Duration

Interval returns the interval at which the check has to run

func (*DockerScriptCheck) Run added in v0.3.2

Run runs a script check inside a docker container

func (*DockerScriptCheck) Timeout added in v0.4.0

func (d *DockerScriptCheck) Timeout() time.Duration

Timeout returns the duration after which a check is timed out.

type ExecCommand added in v0.3.0

type ExecCommand struct {
	// Cmd is the command that the user wants to run.
	Cmd string

	// Args is the args of the command that the user wants to run.
	Args []string

	// FSIsolation determines whether the command would be run in a chroot.
	FSIsolation bool

	// User is the user which the executor uses to run the command.
	User string

	// ResourceLimits determines whether resource limits are enforced by the
	// executor.
	ResourceLimits bool
}

ExecCommand holds the user command, args, and other isolation related settings.

type ExecScriptCheck added in v0.3.2

type ExecScriptCheck struct {
	FSIsolation bool // indicates whether the check has to be run within a chroot
	// contains filtered or unexported fields
}

ExecScriptCheck runs a nagios compatible script and returns the check result

func (*ExecScriptCheck) ID added in v0.3.2

func (e *ExecScriptCheck) ID() string

ID returns the check id

func (*ExecScriptCheck) Interval added in v0.3.2

func (e *ExecScriptCheck) Interval() time.Duration

Interval returns the interval at which the check has to run

func (*ExecScriptCheck) Run added in v0.3.2

Run runs an exec script check

func (*ExecScriptCheck) Timeout added in v0.4.0

func (e *ExecScriptCheck) Timeout() time.Duration

Timeout returns the duration after which a check is timed out.

type Executor

type Executor interface {
	SetContext(ctx *ExecutorContext) error
	LaunchCmd(command *ExecCommand) (*ProcessState, error)
	LaunchSyslogServer() (*SyslogServerState, error)
	Wait() (*ProcessState, error)
	ShutDown() error
	Exit() error
	UpdateLogConfig(logConfig *structs.LogConfig) error
	UpdateTask(task *structs.Task) error
	SyncServices(ctx *ConsulContext) error
	DeregisterServices() error
	Version() (*ExecutorVersion, error)
	Stats() (*cstructs.TaskResourceUsage, error)
	Signal(s os.Signal) error
}

Executor is the interface which allows a driver to launch and supervise a process

func NewExecutor

func NewExecutor(logger *log.Logger) Executor

NewExecutor returns an Executor

type ExecutorContext added in v0.3.0

type ExecutorContext struct {
	// TaskEnv holds information about the environment of a Task
	TaskEnv *env.TaskEnvironment

	// AllocDir is the handle to do operations on the alloc dir of
	// the task
	AllocDir *allocdir.AllocDir

	// Task is the task whose executor is being launched
	Task *structs.Task

	// AllocID is the allocation id to which the task belongs
	AllocID string

	// A mapping of directories on the host OS to attempt to embed inside each
	// task's chroot.
	ChrootEnv map[string]string

	// Driver is the name of the driver that invoked the executor
	Driver string

	// PortUpperBound is the upper bound of the ports that we can use to start
	// the syslog server
	PortUpperBound uint

	// PortLowerBound is the lower bound of the ports that we can use to start
	// the syslog server
	PortLowerBound uint
}

ExecutorContext holds context to configure the command user wants to run and isolate it

type ExecutorVersion added in v0.3.2

type ExecutorVersion struct {
	Version string
}

ExecutorVersion is the version of the executor

func (*ExecutorVersion) GoString added in v0.3.2

func (v *ExecutorVersion) GoString() string

type ProcessState added in v0.3.0

type ProcessState struct {
	Pid             int
	ExitCode        int
	Signal          int
	IsolationConfig *dstructs.IsolationConfig
	Time            time.Time
}

ProcessState holds information about the state of a user process.

type SyslogServerState added in v0.3.2

type SyslogServerState struct {
	IsolationConfig *dstructs.IsolationConfig
	Addr            string
}

SyslogServerState holds the address and islation information of a launched syslog server

type UniversalExecutor added in v0.3.0

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

UniversalExecutor is an implementation of the Executor which launches and supervises processes. In addition to process supervision it provides resource and file system isolation

func (*UniversalExecutor) DeregisterServices added in v0.3.2

func (e *UniversalExecutor) DeregisterServices() error

DeregisterServices removes the services of the task that the executor is running from Consul

func (*UniversalExecutor) Exit added in v0.3.0

func (e *UniversalExecutor) Exit() error

Exit cleans up the alloc directory, destroys resource container and kills the user process

func (*UniversalExecutor) LaunchCmd added in v0.3.0

func (e *UniversalExecutor) LaunchCmd(command *ExecCommand) (*ProcessState, error)

LaunchCmd launches a process and returns it's state. It also configures an applies isolation on certain platforms.

func (*UniversalExecutor) LaunchSyslogServer added in v0.3.2

func (e *UniversalExecutor) LaunchSyslogServer() (*SyslogServerState, error)

func (*UniversalExecutor) SetContext added in v0.5.0

func (e *UniversalExecutor) SetContext(ctx *ExecutorContext) error

SetContext is used to set the executors context and should be the first call after launching the executor.

func (*UniversalExecutor) ShutDown added in v0.3.0

func (e *UniversalExecutor) ShutDown() error

Shutdown sends an interrupt signal to the user process

func (*UniversalExecutor) Signal added in v0.5.0

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

Signal sends the passed signal to the task

func (*UniversalExecutor) Stats added in v0.4.0

Stats reports the resource utilization of the cgroup. If there is no resource isolation we aggregate the resource utilization of all the pids launched by the executor.

func (*UniversalExecutor) SyncServices added in v0.3.2

func (e *UniversalExecutor) SyncServices(ctx *ConsulContext) error

SyncServices syncs the services of the task that the executor is running with Consul

func (*UniversalExecutor) UpdateLogConfig added in v0.3.0

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

COMPAT: prior to Nomad 0.3.2, UpdateTask didn't exist. UpdateLogConfig updates the log configuration

func (*UniversalExecutor) UpdateTask added in v0.3.2

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

func (*UniversalExecutor) Version added in v0.3.2

func (e *UniversalExecutor) Version() (*ExecutorVersion, error)

Version returns the api version of the executor

func (*UniversalExecutor) Wait added in v0.3.0

func (e *UniversalExecutor) Wait() (*ProcessState, error)

Wait waits until a process has exited and returns it's exitcode and errors

Jump to

Keyboard shortcuts

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