5dee1141d1
* client/executor: refactor client to remove interpolation * executor: POC libcontainer based executor * vendor: use hashicorp libcontainer fork * vendor: add libcontainer/nsenter dep * executor: updated executor interface to simplify operations * executor: implement logging pipe * logmon: new logmon plugin to manage task logs * driver/executor: use logmon for log management * executor: fix tests and windows build * executor: fix logging key names * executor: fix test failures * executor: add config field to toggle between using libcontainer and standard executors * logmon: use discover utility to discover nomad executable * executor: only call libcontainer-shim on main in linux * logmon: use seperate path configs for stdout/stderr fifos * executor: windows fixes * executor: created reusable pid stats collection utility that can be used in an executor * executor: update fifo.Open calls * executor: fix build * remove executor from docker driver * executor: Shutdown func to kill and cleanup executor and its children * executor: move linux specific universal executor funcs to seperate file * move logmon initialization to a task runner hook * client: doc fixes and renaming from code review * taskrunner: use shared config struct for logmon fifo fields * taskrunner: logmon only needs to be started once per task
72 lines
1.5 KiB
Go
72 lines
1.5 KiB
Go
package structs
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
// The default user that the executor uses to run tasks
|
|
DefaultUnprivilegedUser = "nobody"
|
|
|
|
// CheckBufSize is the size of the check output result
|
|
CheckBufSize = 4 * 1024
|
|
)
|
|
|
|
// WaitResult stores the result of a Wait operation.
|
|
type WaitResult struct {
|
|
ExitCode int
|
|
Signal int
|
|
Err error
|
|
}
|
|
|
|
func NewWaitResult(code, signal int, err error) *WaitResult {
|
|
return &WaitResult{
|
|
ExitCode: code,
|
|
Signal: signal,
|
|
Err: err,
|
|
}
|
|
}
|
|
|
|
func (r *WaitResult) Successful() bool {
|
|
return r.ExitCode == 0 && r.Signal == 0 && r.Err == nil
|
|
}
|
|
|
|
func (r *WaitResult) String() string {
|
|
return fmt.Sprintf("Wait returned exit code %v, signal %v, and error %v",
|
|
r.ExitCode, r.Signal, r.Err)
|
|
}
|
|
|
|
// CheckResult encapsulates the result of a check
|
|
type CheckResult struct {
|
|
|
|
// ExitCode is the exit code of the check
|
|
ExitCode int
|
|
|
|
// Output is the output of the check script
|
|
Output string
|
|
|
|
// Timestamp is the time at which the check was executed
|
|
Timestamp time.Time
|
|
|
|
// Duration is the time it took the check to run
|
|
Duration time.Duration
|
|
|
|
// Err is the error that a check returned
|
|
Err error
|
|
}
|
|
|
|
// ExecutorConfig is the config that Nomad passes to the executor
|
|
type ExecutorConfig struct {
|
|
|
|
// LogFile is the file to which Executor logs
|
|
LogFile string
|
|
|
|
// LogLevel is the level of the logs to putout
|
|
LogLevel string
|
|
|
|
// FSIsolation if set will use an executor implementation that support
|
|
// filesystem isolation
|
|
FSIsolation bool
|
|
}
|