executor

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: 33 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.

func ExecScript

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

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

	// TaskKillSignal is an optional field which signal to kill the process
	TaskKillSignal os.Signal

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

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

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

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) Exec

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

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