executor

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2017 License: MPL-2.0 Imports: 32 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.

func ExecScript added in v0.6.0

func ExecScript(ctx context.Context, dir string, env *env.TaskEnv, attrs *syscall.SysProcAttr,
	name string, args []string) ([]byte, int, error)

ExecScript executes cmd with args and returns the output, exit code, and error. Output is truncated to client/driver/structs.CheckBufSize

Types

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 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
	Version() (*ExecutorVersion, error)
	Stats() (*cstructs.TaskResourceUsage, error)
	Signal(s os.Signal) error
	Exec(deadline time.Time, cmd string, args []string) ([]byte, int, 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.TaskEnv

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

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

	// TaskDir is the host path to the task's root
	TaskDir string

	// LogDir is the host path where logs should be written
	LogDir 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) Exec added in v0.6.0

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

Exec a command inside a container for exec and java drivers.

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 the main process and returns its 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) 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