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

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

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

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

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

func (d *DockerScriptCheck) ID() string

ID returns the check id

func (*DockerScriptCheck) Interval

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

Interval returns the interval at which the check has to run

func (*DockerScriptCheck) Run

Run runs a script check inside a docker container

func (*DockerScriptCheck) Timeout

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

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

type ExecCommand

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

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

func (e *ExecScriptCheck) ID() string

ID returns the check id

func (*ExecScriptCheck) Interval

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

Interval returns the interval at which the check has to run

func (*ExecScriptCheck) Run

Run runs an exec script check

func (*ExecScriptCheck) Timeout

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

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

type ExecutorVersion struct {
	Version string
}

ExecutorVersion is the version of the executor

func (*ExecutorVersion) GoString

func (v *ExecutorVersion) GoString() string

type ProcessState

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

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

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

type UniversalExecutor

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

func (e *UniversalExecutor) DeregisterServices() error

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

func (*UniversalExecutor) Exit

func (e *UniversalExecutor) Exit() error

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

func (*UniversalExecutor) LaunchCmd

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

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

func (*UniversalExecutor) SetContext

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

func (e *UniversalExecutor) ShutDown() error

Shutdown sends an interrupt signal to the user process

func (*UniversalExecutor) Signal

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

Signal sends the passed signal to the task

func (*UniversalExecutor) Stats

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

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

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

func (*UniversalExecutor) UpdateLogConfig

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

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

func (*UniversalExecutor) Version

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

Version returns the api version of the executor

func (*UniversalExecutor) Wait

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