From 467930f650d123322df15f877607fd00a9fce820 Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Wed, 5 Dec 2018 11:03:56 -0500 Subject: [PATCH 01/13] executor: use grpc instead of netrpc as plugin protocol * Added protobuf spec for executor * Seperated executor structs into their own package --- command/executor_plugin.go | 1 + drivers/shared/executor/executor.go | 184 +-- drivers/shared/executor/executor_basic.go | 7 +- drivers/shared/executor/executor_linux.go | 41 +- .../shared/executor/executor_linux_test.go | 17 +- drivers/shared/executor/executor_test.go | 22 +- drivers/shared/executor/structs/structs.go | 177 +++ plugins/drivers/client.go | 2 +- plugins/drivers/server.go | 2 +- plugins/drivers/utils.go | 4 +- plugins/drivers/utils/utils.go | 14 +- plugins/executor/client.go | 145 ++ plugins/executor/executor_plugin.go | 183 +-- plugins/executor/proto/executor.pb.go | 1201 +++++++++++++++++ plugins/executor/proto/executor.proto | 96 ++ plugins/executor/server.go | 132 ++ plugins/executor/utils.go | 62 + 17 files changed, 1911 insertions(+), 379 deletions(-) create mode 100644 drivers/shared/executor/structs/structs.go create mode 100644 plugins/executor/client.go create mode 100644 plugins/executor/proto/executor.pb.go create mode 100644 plugins/executor/proto/executor.proto create mode 100644 plugins/executor/server.go create mode 100644 plugins/executor/utils.go diff --git a/command/executor_plugin.go b/command/executor_plugin.go index e9741fb90..666d1fb47 100644 --- a/command/executor_plugin.go +++ b/command/executor_plugin.go @@ -49,6 +49,7 @@ func (e *ExecutorPluginCommand) Run(args []string) int { hclog.LevelFromString(executorConfig.LogLevel), executorConfig.FSIsolation, ), + GRPCServer: plugin.DefaultGRPCServer, }) return 0 } diff --git a/drivers/shared/executor/executor.go b/drivers/shared/executor/executor.go index 7239fd577..cb34ce3bd 100644 --- a/drivers/shared/executor/executor.go +++ b/drivers/shared/executor/executor.go @@ -3,8 +3,6 @@ package executor import ( "context" "fmt" - "io" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -18,8 +16,8 @@ import ( multierror "github.com/hashicorp/go-multierror" "github.com/hashicorp/nomad/client/allocdir" - "github.com/hashicorp/nomad/client/lib/fifo" "github.com/hashicorp/nomad/client/stats" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" shelpers "github.com/hashicorp/nomad/helper/stats" "github.com/hashicorp/consul-template/signals" @@ -41,164 +39,14 @@ var ( ExecutorBasicMeasuredCpuStats = []string{"System Mode", "User Mode", "Percent"} ) -// Executor is the interface which allows a driver to launch and supervise -// a process -type Executor interface { - // Launch a user process configured by the given ExecCommand - Launch(launchCmd *ExecCommand) (*ProcessState, error) - - // Wait blocks until the process exits or an error occures - Wait() (*ProcessState, error) - - // Shutdown will shutdown the executor by stopping the user process, - // cleaning up and resources created by the executor. The shutdown sequence - // will first send the given signal to the process. This defaults to "SIGINT" - // if not specified. The executor will then wait for the process to exit - // before cleaning up other resources. If the executor waits longer than the - // given grace period, the process is forcefully killed. - // - // To force kill the user process, gracePeriod can be set to 0. - Shutdown(signal string, gracePeriod time.Duration) error - - // UpdateResources updates any resource isolation enforcement with new - // constraints if supported. - UpdateResources(*Resources) error - - // Version returns the executor API version - Version() (*ExecutorVersion, error) - - // Stats fetchs process usage stats for the executor and each pid if available - Stats() (*cstructs.TaskResourceUsage, error) - - // Signal sends the given signal to the user process - Signal(os.Signal) error - - // Exec executes the given command and args inside the executor context - // and returns the output and exit code. - Exec(deadline time.Time, cmd string, args []string) ([]byte, int, error) -} - -// Resources describes the resource isolation required -type Resources struct { - CPU int - MemoryMB int - DiskMB int - IOPS int -} - -// ExecCommand holds the user command, args, and other isolation related -// settings. -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 - - // Resources defined by the task - Resources *Resources - - // StdoutPath is the path the procoess stdout should be written to - StdoutPath string - stdout io.WriteCloser - - // StderrPath is the path the procoess stderr should be written to - StderrPath string - stderr io.WriteCloser - - // Env is the list of KEY=val pairs of environment variables to be set - Env []string - - // User is the user which the executor uses to run the command. - User string - - // TaskDir is the directory path on the host where for the task - TaskDir string - - // ResourceLimits determines whether resource limits are enforced by the - // executor. - ResourceLimits bool - - // Cgroup marks whether we put the process in a cgroup. Setting this field - // doesn't enforce resource limits. To enforce limits, set ResourceLimits. - // Using the cgroup does allow more precise cleanup of processes. - BasicProcessCgroup bool -} - -type nopCloser struct { - io.Writer -} - -func (nopCloser) Close() error { return nil } - -// Stdout returns a writer for the configured file descriptor -func (c *ExecCommand) Stdout() (io.WriteCloser, error) { - if c.stdout == nil { - if c.StdoutPath != "" { - f, err := fifo.Open(c.StdoutPath) - if err != nil { - return nil, fmt.Errorf("failed to create stdout: %v", err) - } - c.stdout = f - } else { - c.stdout = nopCloser{ioutil.Discard} - } - } - return c.stdout, nil -} - -// Stderr returns a writer for the configured file descriptor -func (c *ExecCommand) Stderr() (io.WriteCloser, error) { - if c.stderr == nil { - if c.StderrPath != "" { - f, err := fifo.Open(c.StderrPath) - if err != nil { - return nil, fmt.Errorf("failed to create stderr: %v", err) - } - c.stderr = f - } else { - c.stderr = nopCloser{ioutil.Discard} - } - } - return c.stderr, nil -} - -func (c *ExecCommand) Close() { - stdout, err := c.Stdout() - if err == nil { - stdout.Close() - } - stderr, err := c.Stderr() - if err == nil { - stderr.Close() - } -} - -// ProcessState holds information about the state of a user process. -type ProcessState struct { - Pid int - ExitCode int - Signal int - Time time.Time -} - -// ExecutorVersion is the version of the executor -type ExecutorVersion struct { - Version string -} - -func (v *ExecutorVersion) GoString() string { - return v.Version -} - // UniversalExecutor is an implementation of the Executor which launches and // supervises processes. In addition to process supervision it provides resource // and file system isolation type UniversalExecutor struct { childCmd exec.Cmd - commandCfg *ExecCommand + commandCfg *structs.ExecCommand - exitState *ProcessState + exitState *structs.ProcessState processExited chan interface{} // resConCtx is used to track and cleanup additional resources created by @@ -214,7 +62,7 @@ type UniversalExecutor struct { } // NewExecutor returns an Executor -func NewExecutor(logger hclog.Logger) Executor { +func NewExecutor(logger hclog.Logger) structs.Executor { logger = logger.Named("executor") if err := shelpers.Init(); err != nil { logger.Error("unable to initialize stats", "error", err) @@ -230,13 +78,13 @@ func NewExecutor(logger hclog.Logger) Executor { } // Version returns the api version of the executor -func (e *UniversalExecutor) Version() (*ExecutorVersion, error) { - return &ExecutorVersion{Version: ExecutorVersionLatest}, nil +func (e *UniversalExecutor) Version() (*structs.ExecutorVersion, error) { + return &structs.ExecutorVersion{Version: ExecutorVersionLatest}, nil } // Launch launches the main process and returns its state. It also // configures an applies isolation on certain platforms. -func (e *UniversalExecutor) Launch(command *ExecCommand) (*ProcessState, error) { +func (e *UniversalExecutor) Launch(command *structs.ExecCommand) (*structs.ProcessState, error) { e.logger.Info("launching command", "command", command.Cmd, "args", strings.Join(command.Args, " ")) e.commandCfg = command @@ -298,7 +146,7 @@ func (e *UniversalExecutor) Launch(command *ExecCommand) (*ProcessState, error) go e.pidCollector.collectPids(e.processExited, getAllPids) go e.wait() - return &ProcessState{Pid: e.childCmd.Process.Pid, ExitCode: -1, Time: time.Now()}, nil + return &structs.ProcessState{Pid: e.childCmd.Process.Pid, ExitCode: -1, Time: time.Now()}, nil } // Exec a command inside a container for exec and java drivers. @@ -346,12 +194,16 @@ func ExecScript(ctx context.Context, dir string, env []string, attrs *syscall.Sy } // Wait waits until a process has exited and returns it's exitcode and errors -func (e *UniversalExecutor) Wait() (*ProcessState, error) { - <-e.processExited - return e.exitState, nil +func (e *UniversalExecutor) Wait(ctx context.Context) (*structs.ProcessState, error) { + select { + case <-ctx.Done(): + return nil, ctx.Err() + case <-e.processExited: + return e.exitState, nil + } } -func (e *UniversalExecutor) UpdateResources(resources *Resources) error { +func (e *UniversalExecutor) UpdateResources(resources *structs.Resources) error { return nil } @@ -360,7 +212,7 @@ func (e *UniversalExecutor) wait() { pid := e.childCmd.Process.Pid err := e.childCmd.Wait() if err == nil { - e.exitState = &ProcessState{Pid: pid, ExitCode: 0, Time: time.Now()} + e.exitState = &structs.ProcessState{Pid: pid, ExitCode: 0, Time: time.Now()} return } @@ -388,7 +240,7 @@ func (e *UniversalExecutor) wait() { e.logger.Warn("unexpected Cmd.Wait() error type", "error", err) } - e.exitState = &ProcessState{Pid: pid, ExitCode: exitCode, Signal: signal, Time: time.Now()} + e.exitState = &structs.ProcessState{Pid: pid, ExitCode: exitCode, Signal: signal, Time: time.Now()} } var ( diff --git a/drivers/shared/executor/executor_basic.go b/drivers/shared/executor/executor_basic.go index 1951ae584..ccd5172ff 100644 --- a/drivers/shared/executor/executor_basic.go +++ b/drivers/shared/executor/executor_basic.go @@ -2,9 +2,12 @@ package executor -import hclog "github.com/hashicorp/go-hclog" +import ( + hclog "github.com/hashicorp/go-hclog" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" +) -func NewExecutorWithIsolation(logger hclog.Logger) Executor { +func NewExecutorWithIsolation(logger hclog.Logger) structs.Executor { logger = logger.Named("executor") logger.Error("isolation executor is not supported on this platform, using default") return NewExecutor(logger) diff --git a/drivers/shared/executor/executor_linux.go b/drivers/shared/executor/executor_linux.go index 989cea353..f5182d0c9 100644 --- a/drivers/shared/executor/executor_linux.go +++ b/drivers/shared/executor/executor_linux.go @@ -19,6 +19,7 @@ import ( multierror "github.com/hashicorp/go-multierror" "github.com/hashicorp/nomad/client/stats" cstructs "github.com/hashicorp/nomad/client/structs" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" "github.com/hashicorp/nomad/helper/discover" shelpers "github.com/hashicorp/nomad/helper/stats" "github.com/hashicorp/nomad/helper/uuid" @@ -61,7 +62,7 @@ func init() { // LibcontainerExecutor implements an Executor with the runc/libcontainer api type LibcontainerExecutor struct { id string - command *ExecCommand + command *structs.ExecCommand logger hclog.Logger @@ -73,10 +74,10 @@ type LibcontainerExecutor struct { container libcontainer.Container userProc *libcontainer.Process userProcExited chan interface{} - exitState *ProcessState + exitState *structs.ProcessState } -func NewExecutorWithIsolation(logger hclog.Logger) Executor { +func NewExecutorWithIsolation(logger hclog.Logger) structs.Executor { logger = logger.Named("isolated_executor") if err := shelpers.Init(); err != nil { logger.Error("unable to initialize stats", "error", err) @@ -92,7 +93,7 @@ func NewExecutorWithIsolation(logger hclog.Logger) Executor { } // Launch creates a new container in libcontainer and starts a new process with it -func (l *LibcontainerExecutor) Launch(command *ExecCommand) (*ProcessState, error) { +func (l *LibcontainerExecutor) Launch(command *structs.ExecCommand) (*structs.ProcessState, error) { l.logger.Info("launching command", "command", command.Cmd, "args", strings.Join(command.Args, " ")) // Find the nomad executable to launch the executor process with bin, err := discover.NomadExecutable() @@ -101,7 +102,7 @@ func (l *LibcontainerExecutor) Launch(command *ExecCommand) (*ProcessState, erro } if command.Resources == nil { - command.Resources = &Resources{} + command.Resources = &structs.Resources{} } l.command = command @@ -206,7 +207,7 @@ func (l *LibcontainerExecutor) Launch(command *ExecCommand) (*ProcessState, erro go l.pidCollector.collectPids(l.userProcExited, l.getAllPids) go l.wait() - return &ProcessState{ + return &structs.ProcessState{ Pid: pid, ExitCode: -1, Time: time.Now(), @@ -231,9 +232,13 @@ func (l *LibcontainerExecutor) getAllPids() (map[int]*nomadPid, error) { } // Wait waits until a process has exited and returns it's exitcode and errors -func (l *LibcontainerExecutor) Wait() (*ProcessState, error) { - <-l.userProcExited - return l.exitState, nil +func (l *LibcontainerExecutor) Wait(ctx context.Context) (*structs.ProcessState, error) { + select { + case <-ctx.Done(): + return nil, ctx.Err() + case <-l.userProcExited: + return l.exitState, nil + } } func (l *LibcontainerExecutor) wait() { @@ -247,7 +252,7 @@ func (l *LibcontainerExecutor) wait() { ps = exitErr.ProcessState } else { l.logger.Error("failed to call wait on user process", "error", err) - l.exitState = &ProcessState{Pid: 0, ExitCode: 0, Time: time.Now()} + l.exitState = &structs.ProcessState{Pid: 0, ExitCode: 0, Time: time.Now()} return } } @@ -265,7 +270,7 @@ func (l *LibcontainerExecutor) wait() { } } - l.exitState = &ProcessState{ + l.exitState = &structs.ProcessState{ Pid: ps.Pid(), ExitCode: exitCode, Signal: signal, @@ -327,13 +332,13 @@ func (l *LibcontainerExecutor) Shutdown(signal string, grace time.Duration) erro } // UpdateResources updates the resource isolation with new values to be enforced -func (l *LibcontainerExecutor) UpdateResources(resources *Resources) error { +func (l *LibcontainerExecutor) UpdateResources(resources *structs.Resources) error { return nil } // Version returns the api version of the executor -func (l *LibcontainerExecutor) Version() (*ExecutorVersion, error) { - return &ExecutorVersion{Version: ExecutorVersionLatest}, nil +func (l *LibcontainerExecutor) Version() (*structs.ExecutorVersion, error) { + return &structs.ExecutorVersion{Version: ExecutorVersionLatest}, nil } // Stats returns the resource statistics for processes managed by the executor @@ -453,7 +458,7 @@ func (l *LibcontainerExecutor) handleExecWait(ch chan *waitResult, process *libc ch <- &waitResult{ps, err} } -func configureCapabilities(cfg *lconfigs.Config, command *ExecCommand) { +func configureCapabilities(cfg *lconfigs.Config, command *structs.ExecCommand) { // TODO: allow better control of these cfg.Capabilities = &lconfigs.Capabilities{ Bounding: allCaps, @@ -465,7 +470,7 @@ func configureCapabilities(cfg *lconfigs.Config, command *ExecCommand) { } -func configureIsolation(cfg *lconfigs.Config, command *ExecCommand) { +func configureIsolation(cfg *lconfigs.Config, command *structs.ExecCommand) { defaultMountFlags := syscall.MS_NOEXEC | syscall.MS_NOSUID | syscall.MS_NODEV // set the new root directory for the container @@ -531,7 +536,7 @@ func configureIsolation(cfg *lconfigs.Config, command *ExecCommand) { } } -func configureCgroups(cfg *lconfigs.Config, command *ExecCommand) error { +func configureCgroups(cfg *lconfigs.Config, command *structs.ExecCommand) error { // If resources are not limited then manually create cgroups needed if !command.ResourceLimits { @@ -597,7 +602,7 @@ func configureBasicCgroups(cfg *lconfigs.Config) error { return nil } -func newLibcontainerConfig(command *ExecCommand) *lconfigs.Config { +func newLibcontainerConfig(command *structs.ExecCommand) *lconfigs.Config { cfg := &lconfigs.Config{ Cgroups: &lconfigs.Cgroup{ Resources: &lconfigs.Resources{ diff --git a/drivers/shared/executor/executor_linux_test.go b/drivers/shared/executor/executor_linux_test.go index de7bf54f4..3b8219396 100644 --- a/drivers/shared/executor/executor_linux_test.go +++ b/drivers/shared/executor/executor_linux_test.go @@ -15,6 +15,7 @@ import ( cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/client/taskenv" "github.com/hashicorp/nomad/client/testutil" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" "github.com/hashicorp/nomad/helper/testlog" "github.com/hashicorp/nomad/nomad/mock" tu "github.com/hashicorp/nomad/testutil" @@ -25,7 +26,7 @@ func init() { executorFactories["LibcontainerExecutor"] = libcontainerFactory } -func libcontainerFactory(l hclog.Logger) Executor { +func libcontainerFactory(l hclog.Logger) structs.Executor { return NewExecutorWithIsolation(l) } @@ -33,7 +34,7 @@ func libcontainerFactory(l hclog.Logger) Executor { // chroot. Use testExecutorContext if you don't need a chroot. // // The caller is responsible for calling AllocDir.Destroy() to cleanup. -func testExecutorCommandWithChroot(t *testing.T) (*ExecCommand, *allocdir.AllocDir) { +func testExecutorCommandWithChroot(t *testing.T) (*structs.ExecCommand, *allocdir.AllocDir) { chrootEnv := map[string]string{ "/etc/ld.so.cache": "/etc/ld.so.cache", "/etc/ld.so.conf": "/etc/ld.so.conf", @@ -61,10 +62,10 @@ func testExecutorCommandWithChroot(t *testing.T) (*ExecCommand, *allocdir.AllocD t.Fatalf("allocDir.NewTaskDir(%q) failed: %v", task.Name, err) } td := allocDir.TaskDirs[task.Name] - cmd := &ExecCommand{ + cmd := &structs.ExecCommand{ Env: taskEnv.List(), TaskDir: td.Dir, - Resources: &Resources{ + Resources: &structs.Resources{ CPU: task.Resources.CPU, MemoryMB: task.Resources.MemoryMB, IOPS: task.Resources.IOPS, @@ -143,7 +144,8 @@ ld.so.cache ld.so.conf ld.so.conf.d/` tu.WaitForResult(func() (bool, error) { - output := execCmd.stdout.(*bufferCloser).String() + outWriter, _ := execCmd.GetWriters() + output := outWriter.(*bufferCloser).String() act := strings.TrimSpace(string(output)) if act != expected { return false, fmt.Errorf("Command output incorrectly: want %v; got %v", expected, act) @@ -176,9 +178,10 @@ func TestExecutor_ClientCleanup(t *testing.T) { require.NoError(executor.Shutdown("SIGINT", 100*time.Millisecond)) executor.Wait() - output := execCmd.stdout.(*bufferCloser).String() + outWriter, _ := execCmd.GetWriters() + output := outWriter.(*bufferCloser).String() require.NotZero(len(output)) time.Sleep(2 * time.Second) - output1 := execCmd.stdout.(*bufferCloser).String() + output1 := outWriter.(*bufferCloser).String() require.Equal(len(output), len(output1)) } diff --git a/drivers/shared/executor/executor_test.go b/drivers/shared/executor/executor_test.go index 1c274a382..109ae6641 100644 --- a/drivers/shared/executor/executor_test.go +++ b/drivers/shared/executor/executor_test.go @@ -11,6 +11,7 @@ import ( "testing" "time" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" tu "github.com/hashicorp/nomad/testutil" hclog "github.com/hashicorp/go-hclog" @@ -22,8 +23,8 @@ import ( "github.com/stretchr/testify/require" ) -var executorFactories = map[string]func(hclog.Logger) Executor{} -var universalFactory = func(l hclog.Logger) Executor { +var executorFactories = map[string]func(hclog.Logger) structs.Executor{} +var universalFactory = func(l hclog.Logger) structs.Executor { return NewExecutor(l) } @@ -34,7 +35,7 @@ func init() { // testExecutorContext returns an ExecutorContext and AllocDir. // // The caller is responsible for calling AllocDir.Destroy() to cleanup. -func testExecutorCommand(t *testing.T) (*ExecCommand, *allocdir.AllocDir) { +func testExecutorCommand(t *testing.T) (*structs.ExecCommand, *allocdir.AllocDir) { alloc := mock.Alloc() task := alloc.Job.TaskGroups[0].Tasks[0] taskEnv := taskenv.NewBuilder(mock.Node(), alloc, task, "global").Build() @@ -48,10 +49,10 @@ func testExecutorCommand(t *testing.T) (*ExecCommand, *allocdir.AllocDir) { t.Fatalf("allocDir.NewTaskDir(%q) failed: %v", task.Name, err) } td := allocDir.TaskDirs[task.Name] - cmd := &ExecCommand{ + cmd := &structs.ExecCommand{ Env: taskEnv.List(), TaskDir: td.Dir, - Resources: &Resources{ + Resources: &structs.Resources{ CPU: task.Resources.CPU, MemoryMB: task.Resources.MemoryMB, IOPS: task.Resources.IOPS, @@ -68,9 +69,8 @@ type bufferCloser struct { func (_ *bufferCloser) Close() error { return nil } -func configureTLogging(cmd *ExecCommand) (stdout bufferCloser, stderr bufferCloser) { - cmd.stdout = &stdout - cmd.stderr = &stderr +func configureTLogging(cmd *structs.ExecCommand) (stdout bufferCloser, stderr bufferCloser) { + cmd.SetWriters(&stdout, &stderr) return } @@ -140,7 +140,8 @@ func TestExecutor_Start_Wait(pt *testing.T) { expected := "hello world" tu.WaitForResult(func() (bool, error) { - output := execCmd.stdout.(*bufferCloser).String() + outWriter, _ := execCmd.GetWriters() + output := outWriter.(*bufferCloser).String() act := strings.TrimSpace(string(output)) if expected != act { return false, fmt.Errorf("expected: '%s' actual: '%s'", expected, act) @@ -207,7 +208,8 @@ func TestExecutor_Start_Kill(pt *testing.T) { require.NoError(executor.Shutdown("SIGINT", 100*time.Millisecond)) time.Sleep(time.Duration(tu.TestMultiplier()*2) * time.Second) - output := execCmd.stdout.(*bufferCloser).String() + outWriter, _ := execCmd.GetWriters() + output := outWriter.(*bufferCloser).String() expected := "" act := strings.TrimSpace(string(output)) if act != expected { diff --git a/drivers/shared/executor/structs/structs.go b/drivers/shared/executor/structs/structs.go new file mode 100644 index 000000000..56495f7ab --- /dev/null +++ b/drivers/shared/executor/structs/structs.go @@ -0,0 +1,177 @@ +package structs + +import ( + "context" + "fmt" + "io" + "io/ioutil" + "os" + "time" + + "github.com/hashicorp/nomad/client/lib/fifo" + cstructs "github.com/hashicorp/nomad/client/structs" +) + +// Executor is the interface which allows a driver to launch and supervise +// a process +type Executor interface { + // Launch a user process configured by the given ExecCommand + Launch(launchCmd *ExecCommand) (*ProcessState, error) + + // Wait blocks until the process exits or an error occures + Wait(ctx context.Context) (*ProcessState, error) + + // Shutdown will shutdown the executor by stopping the user process, + // cleaning up and resources created by the executor. The shutdown sequence + // will first send the given signal to the process. This defaults to "SIGINT" + // if not specified. The executor will then wait for the process to exit + // before cleaning up other resources. If the executor waits longer than the + // given grace period, the process is forcefully killed. + // + // To force kill the user process, gracePeriod can be set to 0. + Shutdown(signal string, gracePeriod time.Duration) error + + // UpdateResources updates any resource isolation enforcement with new + // constraints if supported. + UpdateResources(*Resources) error + + // Version returns the executor API version + Version() (*ExecutorVersion, error) + + // Stats fetchs process usage stats for the executor and each pid if available + Stats() (*cstructs.TaskResourceUsage, error) + + // Signal sends the given signal to the user process + Signal(os.Signal) error + + // Exec executes the given command and args inside the executor context + // and returns the output and exit code. + Exec(deadline time.Time, cmd string, args []string) ([]byte, int, error) +} + +// Resources describes the resource isolation required +type Resources struct { + CPU int + MemoryMB int + DiskMB int + IOPS int +} + +// ExecCommand holds the user command, args, and other isolation related +// settings. +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 + + // Resources defined by the task + Resources *Resources + + // StdoutPath is the path the process stdout should be written to + StdoutPath string + stdout io.WriteCloser + + // StderrPath is the path the process stderr should be written to + StderrPath string + stderr io.WriteCloser + + // Env is the list of KEY=val pairs of environment variables to be set + Env []string + + // User is the user which the executor uses to run the command. + User string + + // TaskDir is the directory path on the host where for the task + TaskDir string + + // ResourceLimits determines whether resource limits are enforced by the + // executor. + ResourceLimits bool + + // Cgroup marks whether we put the process in a cgroup. Setting this field + // doesn't enforce resource limits. To enforce limits, set ResourceLimits. + // Using the cgroup does allow more precise cleanup of processes. + BasicProcessCgroup bool +} + +// SetWriters sets the writer for the process stdout and stderr. This should +// not be used if writing to a file path such as a fifo file. SetStdoutWriter +// is mainly used for unit testing purposes. +func (c *ExecCommand) SetWriters(out io.WriteCloser, err io.WriteCloser) { + c.stdout = out + c.stderr = err +} + +// GetWriters returns the unexported io.WriteCloser for the stdout and stderr +// handles. This is mainly used for unit testing purposes. +func (c *ExecCommand) GetWriters() (stdout io.WriteCloser, stderr io.WriteCloser) { + return c.stdout, c.stderr +} + +type nopCloser struct { + io.Writer +} + +func (nopCloser) Close() error { return nil } + +// Stdout returns a writer for the configured file descriptor +func (c *ExecCommand) Stdout() (io.WriteCloser, error) { + if c.stdout == nil { + if c.StdoutPath != "" { + f, err := fifo.Open(c.StdoutPath) + if err != nil { + return nil, fmt.Errorf("failed to create stdout: %v", err) + } + c.stdout = f + } else { + c.stdout = nopCloser{ioutil.Discard} + } + } + return c.stdout, nil +} + +// Stderr returns a writer for the configured file descriptor +func (c *ExecCommand) Stderr() (io.WriteCloser, error) { + if c.stderr == nil { + if c.StderrPath != "" { + f, err := fifo.Open(c.StderrPath) + if err != nil { + return nil, fmt.Errorf("failed to create stderr: %v", err) + } + c.stderr = f + } else { + c.stderr = nopCloser{ioutil.Discard} + } + } + return c.stderr, nil +} + +func (c *ExecCommand) Close() { + stdout, err := c.Stdout() + if err == nil { + stdout.Close() + } + stderr, err := c.Stderr() + if err == nil { + stderr.Close() + } +} + +// ProcessState holds information about the state of a user process. +type ProcessState struct { + Pid int + ExitCode int + Signal int + Time time.Time +} + +// ExecutorVersion is the version of the executor +type ExecutorVersion struct { + Version string +} + +func (v *ExecutorVersion) GoString() string { + return v.Version +} diff --git a/plugins/drivers/client.go b/plugins/drivers/client.go index 83200c160..d8a1415fb 100644 --- a/plugins/drivers/client.go +++ b/plugins/drivers/client.go @@ -265,7 +265,7 @@ func (d *driverPluginClient) TaskStats(taskID string) (*cstructs.TaskResourceUsa return nil, err } - stats, err := taskStatsFromProto(resp.Stats) + stats, err := TaskStatsFromProto(resp.Stats) if err != nil { return nil, err } diff --git a/plugins/drivers/server.go b/plugins/drivers/server.go index deff26e12..f24072a3c 100644 --- a/plugins/drivers/server.go +++ b/plugins/drivers/server.go @@ -230,7 +230,7 @@ func (b *driverPluginServer) TaskStats(ctx context.Context, req *proto.TaskStats return nil, err } - pb, err := taskStatsToProto(stats) + pb, err := TaskStatsToProto(stats) if err != nil { return nil, fmt.Errorf("failed to encode task stats: %v", err) } diff --git a/plugins/drivers/utils.go b/plugins/drivers/utils.go index 090ff014a..d8ea6f605 100644 --- a/plugins/drivers/utils.go +++ b/plugins/drivers/utils.go @@ -373,7 +373,7 @@ func taskStatusFromProto(pb *proto.TaskStatus) (*TaskStatus, error) { }, nil } -func taskStatsToProto(stats *cstructs.TaskResourceUsage) (*proto.TaskStats, error) { +func TaskStatsToProto(stats *cstructs.TaskResourceUsage) (*proto.TaskStats, error) { timestamp, err := ptypes.TimestampProto(time.Unix(0, stats.Timestamp)) if err != nil { return nil, err @@ -391,7 +391,7 @@ func taskStatsToProto(stats *cstructs.TaskResourceUsage) (*proto.TaskStats, erro }, nil } -func taskStatsFromProto(pb *proto.TaskStats) (*cstructs.TaskResourceUsage, error) { +func TaskStatsFromProto(pb *proto.TaskStats) (*cstructs.TaskResourceUsage, error) { timestamp, err := ptypes.Timestamp(pb.Timestamp) if err != nil { return nil, err diff --git a/plugins/drivers/utils/utils.go b/plugins/drivers/utils/utils.go index c11fd2a8b..1060dfce2 100644 --- a/plugins/drivers/utils/utils.go +++ b/plugins/drivers/utils/utils.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/nomad/client/config" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/client/taskenv" - "github.com/hashicorp/nomad/drivers/shared/executor" + estructs "github.com/hashicorp/nomad/drivers/shared/executor/structs" "github.com/hashicorp/nomad/helper/discover" "github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/nomad/plugins/base" @@ -64,7 +64,7 @@ func CgroupsMounted(node *structs.Node) bool { // CreateExecutor launches an executor plugin and returns an instance of the // Executor interface func CreateExecutor(w io.Writer, level hclog.Level, driverConfig *base.ClientDriverConfig, - executorConfig *pexecutor.ExecutorConfig) (executor.Executor, *plugin.Client, error) { + executorConfig *pexecutor.ExecutorConfig) (estructs.Executor, *plugin.Client, error) { c, err := json.Marshal(executorConfig) if err != nil { @@ -80,6 +80,7 @@ func CreateExecutor(w io.Writer, level hclog.Level, driverConfig *base.ClientDri } config.HandshakeConfig = base.Handshake config.Plugins = pexecutor.GetPluginMap(w, level, executorConfig.FSIsolation) + config.AllowedProtocols = []plugin.Protocol{plugin.ProtocolGRPC} if driverConfig != nil { config.MaxPort = driverConfig.ClientMaxPort @@ -105,17 +106,20 @@ func CreateExecutor(w io.Writer, level hclog.Level, driverConfig *base.ClientDri if err != nil { return nil, nil, fmt.Errorf("unable to dispense the executor plugin: %v", err) } - executorPlugin := raw.(executor.Executor) + executorPlugin := raw.(estructs.Executor) return executorPlugin, executorClient, nil } // CreateExecutorWithConfig launches a plugin with a given plugin config -func CreateExecutorWithConfig(config *plugin.ClientConfig, w io.Writer) (executor.Executor, *plugin.Client, error) { +func CreateExecutorWithConfig(config *plugin.ClientConfig, w io.Writer) (estructs.Executor, *plugin.Client, error) { config.HandshakeConfig = base.Handshake // Setting this to DEBUG since the log level at the executor server process // is already set, and this effects only the executor client. + // TODO: Use versioned plugin map to support backwards compatability with + // existing pre-0.9 executors config.Plugins = pexecutor.GetPluginMap(w, hclog.Debug, false) + config.AllowedProtocols = []plugin.Protocol{plugin.ProtocolGRPC} executorClient := plugin.NewClient(config) rpcClient, err := executorClient.Client() @@ -127,7 +131,7 @@ func CreateExecutorWithConfig(config *plugin.ClientConfig, w io.Writer) (executo if err != nil { return nil, nil, fmt.Errorf("unable to dispense the executor plugin: %v", err) } - executorPlugin, ok := raw.(*pexecutor.ExecutorRPC) + executorPlugin, ok := raw.(estructs.Executor) if !ok { return nil, nil, fmt.Errorf("unexpected executor rpc type: %T", raw) } diff --git a/plugins/executor/client.go b/plugins/executor/client.go new file mode 100644 index 000000000..08b429d95 --- /dev/null +++ b/plugins/executor/client.go @@ -0,0 +1,145 @@ +package executor + +import ( + "context" + "os" + "time" + + "github.com/LK4D4/joincontext" + "github.com/golang/protobuf/ptypes" + cstructs "github.com/hashicorp/nomad/client/structs" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/plugins/drivers" + "github.com/hashicorp/nomad/plugins/executor/proto" +) + +var _ structs.Executor = (*grpcExecutorClient)(nil) + +type grpcExecutorClient struct { + client proto.ExecutorClient + + // doneCtx is close when the plugin exits + doneCtx context.Context +} + +func (c *grpcExecutorClient) Launch(cmd *structs.ExecCommand) (*structs.ProcessState, error) { + ctx := context.Background() + req := &proto.LaunchRequest{ + Cmd: cmd.Cmd, + Args: cmd.Args, + Resources: resourcesToProto(cmd.Resources), + StdoutPath: cmd.StdoutPath, + StderrPath: cmd.StderrPath, + Env: cmd.Env, + User: cmd.User, + TaskDir: cmd.TaskDir, + ResourceLimits: cmd.ResourceLimits, + BasicProcessCgroup: cmd.BasicProcessCgroup, + } + resp, err := c.client.Launch(ctx, req) + if err != nil { + return nil, err + } + + ps, err := processStateFromProto(resp.Process) + if err != nil { + return nil, err + } + return ps, nil +} + +func (c *grpcExecutorClient) Wait(ctx context.Context) (*structs.ProcessState, error) { + // Join the passed context and the shutdown context + ctx, _ = joincontext.Join(ctx, c.doneCtx) + + resp, err := c.client.Wait(ctx, &proto.WaitRequest{}) + if err != nil { + return nil, err + } + + ps, err := processStateFromProto(resp.Process) + if err != nil { + return nil, err + } + + return ps, nil +} + +func (c *grpcExecutorClient) Shutdown(signal string, gracePeriod time.Duration) error { + ctx := context.Background() + req := &proto.ShutdownRequest{ + Signal: signal, + GracePeriod: gracePeriod.Nanoseconds(), + } + if _, err := c.client.Shutdown(ctx, req); err != nil { + return err + } + + return nil +} + +func (c *grpcExecutorClient) UpdateResources(r *structs.Resources) error { + ctx := context.Background() + req := &proto.UpdateResourcesRequest{Resources: resourcesToProto(r)} + if _, err := c.client.UpdateResources(ctx, req); err != nil { + return err + } + + return nil +} + +func (c *grpcExecutorClient) Version() (*structs.ExecutorVersion, error) { + ctx := context.Background() + resp, err := c.client.Version(ctx, &proto.VersionRequest{}) + if err != nil { + return nil, err + } + return &structs.ExecutorVersion{Version: resp.Version}, nil +} + +func (c *grpcExecutorClient) Stats() (*cstructs.TaskResourceUsage, error) { + ctx := context.Background() + resp, err := c.client.Stats(ctx, &proto.StatsRequest{}) + if err != nil { + return nil, err + } + + stats, err := drivers.TaskStatsFromProto(resp.Stats) + if err != nil { + return nil, err + } + return stats, nil + +} + +func (c *grpcExecutorClient) Signal(s os.Signal) error { + ctx := context.Background() + req := &proto.SignalRequest{ + Signal: s.String(), + } + if _, err := c.client.Signal(ctx, req); err != nil { + return err + } + + return nil +} + +func (c *grpcExecutorClient) Exec(deadline time.Time, cmd string, args []string) ([]byte, int, error) { + ctx := context.Background() + pbDeadline, err := ptypes.TimestampProto(deadline) + if err != nil { + return nil, 0, err + } + req := &proto.ExecRequest{ + Deadline: pbDeadline, + Cmd: cmd, + Args: args, + } + + resp, err := c.client.Exec(ctx, req) + if err != nil { + return nil, 0, err + } + + return resp.Output, int(resp.ExitCode), nil +} diff --git a/plugins/executor/executor_plugin.go b/plugins/executor/executor_plugin.go index a31d9eb80..905dc6a30 100644 --- a/plugins/executor/executor_plugin.go +++ b/plugins/executor/executor_plugin.go @@ -1,185 +1,34 @@ package executor import ( - "encoding/gob" - "net/rpc" - "os" - "syscall" - "time" + "context" hclog "github.com/hashicorp/go-hclog" "github.com/hashicorp/go-plugin" - cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/executor" + "github.com/hashicorp/nomad/plugins/executor/proto" + "google.golang.org/grpc" ) -// Registering these types since we have to serialize and de-serialize the Task -// structs over the wire between drivers and the executor. -func init() { - gob.Register([]interface{}{}) - gob.Register(map[string]interface{}{}) - gob.Register([]map[string]string{}) - gob.Register([]map[string]int{}) - gob.Register(syscall.Signal(0x1)) -} - -type ExecutorRPC struct { - client *rpc.Client - logger hclog.Logger -} - -// LaunchCmdArgs wraps a user command and the args for the purposes of RPC -type LaunchArgs struct { - Cmd *executor.ExecCommand -} - -// ShutdownArgs wraps shutdown signal and grace period -type ShutdownArgs struct { - Signal string - GracePeriod time.Duration -} - -type ExecArgs struct { - Deadline time.Time - Name string - Args []string -} - -type ExecReturn struct { - Output []byte - Code int -} - -func (e *ExecutorRPC) Launch(cmd *executor.ExecCommand) (*executor.ProcessState, error) { - var ps *executor.ProcessState - err := e.client.Call("Plugin.Launch", LaunchArgs{Cmd: cmd}, &ps) - return ps, err -} - -func (e *ExecutorRPC) Wait() (*executor.ProcessState, error) { - var ps executor.ProcessState - err := e.client.Call("Plugin.Wait", new(interface{}), &ps) - return &ps, err -} - -func (e *ExecutorRPC) Kill() error { - return e.client.Call("Plugin.Kill", new(interface{}), new(interface{})) -} - -func (e *ExecutorRPC) Shutdown(signal string, grace time.Duration) error { - return e.client.Call("Plugin.Shutdown", &ShutdownArgs{signal, grace}, new(interface{})) -} - -func (e *ExecutorRPC) UpdateResources(resources *executor.Resources) error { - return e.client.Call("Plugin.UpdateResources", resources, new(interface{})) -} - -func (e *ExecutorRPC) Version() (*executor.ExecutorVersion, error) { - var version executor.ExecutorVersion - err := e.client.Call("Plugin.Version", new(interface{}), &version) - return &version, err -} - -func (e *ExecutorRPC) Stats() (*cstructs.TaskResourceUsage, error) { - var resourceUsage cstructs.TaskResourceUsage - err := e.client.Call("Plugin.Stats", new(interface{}), &resourceUsage) - return &resourceUsage, err -} - -func (e *ExecutorRPC) Signal(s os.Signal) error { - return e.client.Call("Plugin.Signal", &s, new(interface{})) -} - -func (e *ExecutorRPC) Exec(deadline time.Time, name string, args []string) ([]byte, int, error) { - req := ExecArgs{ - Deadline: deadline, - Name: name, - Args: args, - } - var resp *ExecReturn - err := e.client.Call("Plugin.Exec", req, &resp) - if resp == nil { - return nil, 0, err - } - return resp.Output, resp.Code, err -} - -type ExecutorRPCServer struct { - Impl executor.Executor - logger hclog.Logger -} - -func (e *ExecutorRPCServer) Launch(args LaunchArgs, ps *executor.ProcessState) error { - state, err := e.Impl.Launch(args.Cmd) - if state != nil { - *ps = *state - } - return err -} - -func (e *ExecutorRPCServer) Wait(args interface{}, ps *executor.ProcessState) error { - state, err := e.Impl.Wait() - if state != nil { - *ps = *state - } - return err -} - -func (e *ExecutorRPCServer) Shutdown(args ShutdownArgs, resp *interface{}) error { - return e.Impl.Shutdown(args.Signal, args.GracePeriod) -} - -func (e *ExecutorRPCServer) UpdateResources(args *executor.Resources, resp *interface{}) error { - return e.Impl.UpdateResources(args) -} - -func (e *ExecutorRPCServer) Version(args interface{}, version *executor.ExecutorVersion) error { - ver, err := e.Impl.Version() - if ver != nil { - *version = *ver - } - return err -} - -func (e *ExecutorRPCServer) Stats(args interface{}, resourceUsage *cstructs.TaskResourceUsage) error { - ru, err := e.Impl.Stats() - if ru != nil { - *resourceUsage = *ru - } - return err -} - -func (e *ExecutorRPCServer) Signal(args os.Signal, resp *interface{}) error { - return e.Impl.Signal(args) -} - -func (e *ExecutorRPCServer) Exec(args ExecArgs, result *ExecReturn) error { - out, code, err := e.Impl.Exec(args.Deadline, args.Name, args.Args) - ret := &ExecReturn{ - Output: out, - Code: code, - } - *result = *ret - return err -} - type ExecutorPlugin struct { + // TODO: support backwards compatability with pre 0.9 NetRPC plugin + plugin.NetRPCUnsupportedPlugin logger hclog.Logger fsIsolation bool - Impl *ExecutorRPCServer } -func (p *ExecutorPlugin) Server(*plugin.MuxBroker) (interface{}, error) { - if p.Impl == nil { - if p.fsIsolation { - p.Impl = &ExecutorRPCServer{Impl: executor.NewExecutorWithIsolation(p.logger), logger: p.logger} - } else { - p.Impl = &ExecutorRPCServer{Impl: executor.NewExecutor(p.logger), logger: p.logger} - } +func (p *ExecutorPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error { + if p.fsIsolation { + proto.RegisterExecutorServer(s, &grpcExecutorServer{impl: executor.NewExecutorWithIsolation(p.logger)}) + } else { + proto.RegisterExecutorServer(s, &grpcExecutorServer{impl: executor.NewExecutor(p.logger)}) } - return p.Impl, nil + return nil } -func (p *ExecutorPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error) { - return &ExecutorRPC{client: c, logger: p.logger}, nil +func (p *ExecutorPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) { + return &grpcExecutorClient{ + client: proto.NewExecutorClient(c), + doneCtx: ctx, + }, nil } diff --git a/plugins/executor/proto/executor.pb.go b/plugins/executor/proto/executor.pb.go new file mode 100644 index 000000000..5c345fa66 --- /dev/null +++ b/plugins/executor/proto/executor.pb.go @@ -0,0 +1,1201 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: plugins/executor/proto/executor.proto + +package proto + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" +import timestamp "github.com/golang/protobuf/ptypes/timestamp" +import proto1 "github.com/hashicorp/nomad/plugins/drivers/proto" + +import ( + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +type LaunchRequest struct { + Cmd string `protobuf:"bytes,1,opt,name=cmd,proto3" json:"cmd,omitempty"` + Args []string `protobuf:"bytes,2,rep,name=args,proto3" json:"args,omitempty"` + Resources *Resources `protobuf:"bytes,3,opt,name=resources,proto3" json:"resources,omitempty"` + StdoutPath string `protobuf:"bytes,4,opt,name=stdout_path,json=stdoutPath,proto3" json:"stdout_path,omitempty"` + StderrPath string `protobuf:"bytes,5,opt,name=stderr_path,json=stderrPath,proto3" json:"stderr_path,omitempty"` + Env []string `protobuf:"bytes,6,rep,name=env,proto3" json:"env,omitempty"` + User string `protobuf:"bytes,7,opt,name=user,proto3" json:"user,omitempty"` + TaskDir string `protobuf:"bytes,8,opt,name=task_dir,json=taskDir,proto3" json:"task_dir,omitempty"` + ResourceLimits bool `protobuf:"varint,9,opt,name=resource_limits,json=resourceLimits,proto3" json:"resource_limits,omitempty"` + BasicProcessCgroup bool `protobuf:"varint,10,opt,name=basic_process_cgroup,json=basicProcessCgroup,proto3" json:"basic_process_cgroup,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *LaunchRequest) Reset() { *m = LaunchRequest{} } +func (m *LaunchRequest) String() string { return proto.CompactTextString(m) } +func (*LaunchRequest) ProtoMessage() {} +func (*LaunchRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{0} +} +func (m *LaunchRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_LaunchRequest.Unmarshal(m, b) +} +func (m *LaunchRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_LaunchRequest.Marshal(b, m, deterministic) +} +func (dst *LaunchRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_LaunchRequest.Merge(dst, src) +} +func (m *LaunchRequest) XXX_Size() int { + return xxx_messageInfo_LaunchRequest.Size(m) +} +func (m *LaunchRequest) XXX_DiscardUnknown() { + xxx_messageInfo_LaunchRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_LaunchRequest proto.InternalMessageInfo + +func (m *LaunchRequest) GetCmd() string { + if m != nil { + return m.Cmd + } + return "" +} + +func (m *LaunchRequest) GetArgs() []string { + if m != nil { + return m.Args + } + return nil +} + +func (m *LaunchRequest) GetResources() *Resources { + if m != nil { + return m.Resources + } + return nil +} + +func (m *LaunchRequest) GetStdoutPath() string { + if m != nil { + return m.StdoutPath + } + return "" +} + +func (m *LaunchRequest) GetStderrPath() string { + if m != nil { + return m.StderrPath + } + return "" +} + +func (m *LaunchRequest) GetEnv() []string { + if m != nil { + return m.Env + } + return nil +} + +func (m *LaunchRequest) GetUser() string { + if m != nil { + return m.User + } + return "" +} + +func (m *LaunchRequest) GetTaskDir() string { + if m != nil { + return m.TaskDir + } + return "" +} + +func (m *LaunchRequest) GetResourceLimits() bool { + if m != nil { + return m.ResourceLimits + } + return false +} + +func (m *LaunchRequest) GetBasicProcessCgroup() bool { + if m != nil { + return m.BasicProcessCgroup + } + return false +} + +type LaunchResponse struct { + Process *ProcessState `protobuf:"bytes,1,opt,name=process,proto3" json:"process,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *LaunchResponse) Reset() { *m = LaunchResponse{} } +func (m *LaunchResponse) String() string { return proto.CompactTextString(m) } +func (*LaunchResponse) ProtoMessage() {} +func (*LaunchResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{1} +} +func (m *LaunchResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_LaunchResponse.Unmarshal(m, b) +} +func (m *LaunchResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_LaunchResponse.Marshal(b, m, deterministic) +} +func (dst *LaunchResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_LaunchResponse.Merge(dst, src) +} +func (m *LaunchResponse) XXX_Size() int { + return xxx_messageInfo_LaunchResponse.Size(m) +} +func (m *LaunchResponse) XXX_DiscardUnknown() { + xxx_messageInfo_LaunchResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_LaunchResponse proto.InternalMessageInfo + +func (m *LaunchResponse) GetProcess() *ProcessState { + if m != nil { + return m.Process + } + return nil +} + +type WaitRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *WaitRequest) Reset() { *m = WaitRequest{} } +func (m *WaitRequest) String() string { return proto.CompactTextString(m) } +func (*WaitRequest) ProtoMessage() {} +func (*WaitRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{2} +} +func (m *WaitRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_WaitRequest.Unmarshal(m, b) +} +func (m *WaitRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_WaitRequest.Marshal(b, m, deterministic) +} +func (dst *WaitRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_WaitRequest.Merge(dst, src) +} +func (m *WaitRequest) XXX_Size() int { + return xxx_messageInfo_WaitRequest.Size(m) +} +func (m *WaitRequest) XXX_DiscardUnknown() { + xxx_messageInfo_WaitRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_WaitRequest proto.InternalMessageInfo + +type WaitResponse struct { + Process *ProcessState `protobuf:"bytes,1,opt,name=process,proto3" json:"process,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *WaitResponse) Reset() { *m = WaitResponse{} } +func (m *WaitResponse) String() string { return proto.CompactTextString(m) } +func (*WaitResponse) ProtoMessage() {} +func (*WaitResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{3} +} +func (m *WaitResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_WaitResponse.Unmarshal(m, b) +} +func (m *WaitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_WaitResponse.Marshal(b, m, deterministic) +} +func (dst *WaitResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_WaitResponse.Merge(dst, src) +} +func (m *WaitResponse) XXX_Size() int { + return xxx_messageInfo_WaitResponse.Size(m) +} +func (m *WaitResponse) XXX_DiscardUnknown() { + xxx_messageInfo_WaitResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_WaitResponse proto.InternalMessageInfo + +func (m *WaitResponse) GetProcess() *ProcessState { + if m != nil { + return m.Process + } + return nil +} + +type ShutdownRequest struct { + Signal string `protobuf:"bytes,1,opt,name=signal,proto3" json:"signal,omitempty"` + GracePeriod int64 `protobuf:"varint,2,opt,name=grace_period,json=gracePeriod,proto3" json:"grace_period,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ShutdownRequest) Reset() { *m = ShutdownRequest{} } +func (m *ShutdownRequest) String() string { return proto.CompactTextString(m) } +func (*ShutdownRequest) ProtoMessage() {} +func (*ShutdownRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{4} +} +func (m *ShutdownRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ShutdownRequest.Unmarshal(m, b) +} +func (m *ShutdownRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ShutdownRequest.Marshal(b, m, deterministic) +} +func (dst *ShutdownRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ShutdownRequest.Merge(dst, src) +} +func (m *ShutdownRequest) XXX_Size() int { + return xxx_messageInfo_ShutdownRequest.Size(m) +} +func (m *ShutdownRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ShutdownRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ShutdownRequest proto.InternalMessageInfo + +func (m *ShutdownRequest) GetSignal() string { + if m != nil { + return m.Signal + } + return "" +} + +func (m *ShutdownRequest) GetGracePeriod() int64 { + if m != nil { + return m.GracePeriod + } + return 0 +} + +type ShutdownResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ShutdownResponse) Reset() { *m = ShutdownResponse{} } +func (m *ShutdownResponse) String() string { return proto.CompactTextString(m) } +func (*ShutdownResponse) ProtoMessage() {} +func (*ShutdownResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{5} +} +func (m *ShutdownResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ShutdownResponse.Unmarshal(m, b) +} +func (m *ShutdownResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ShutdownResponse.Marshal(b, m, deterministic) +} +func (dst *ShutdownResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ShutdownResponse.Merge(dst, src) +} +func (m *ShutdownResponse) XXX_Size() int { + return xxx_messageInfo_ShutdownResponse.Size(m) +} +func (m *ShutdownResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ShutdownResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ShutdownResponse proto.InternalMessageInfo + +type UpdateResourcesRequest struct { + Resources *Resources `protobuf:"bytes,1,opt,name=resources,proto3" json:"resources,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UpdateResourcesRequest) Reset() { *m = UpdateResourcesRequest{} } +func (m *UpdateResourcesRequest) String() string { return proto.CompactTextString(m) } +func (*UpdateResourcesRequest) ProtoMessage() {} +func (*UpdateResourcesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{6} +} +func (m *UpdateResourcesRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_UpdateResourcesRequest.Unmarshal(m, b) +} +func (m *UpdateResourcesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_UpdateResourcesRequest.Marshal(b, m, deterministic) +} +func (dst *UpdateResourcesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpdateResourcesRequest.Merge(dst, src) +} +func (m *UpdateResourcesRequest) XXX_Size() int { + return xxx_messageInfo_UpdateResourcesRequest.Size(m) +} +func (m *UpdateResourcesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_UpdateResourcesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_UpdateResourcesRequest proto.InternalMessageInfo + +func (m *UpdateResourcesRequest) GetResources() *Resources { + if m != nil { + return m.Resources + } + return nil +} + +type UpdateResourcesResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *UpdateResourcesResponse) Reset() { *m = UpdateResourcesResponse{} } +func (m *UpdateResourcesResponse) String() string { return proto.CompactTextString(m) } +func (*UpdateResourcesResponse) ProtoMessage() {} +func (*UpdateResourcesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{7} +} +func (m *UpdateResourcesResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_UpdateResourcesResponse.Unmarshal(m, b) +} +func (m *UpdateResourcesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_UpdateResourcesResponse.Marshal(b, m, deterministic) +} +func (dst *UpdateResourcesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpdateResourcesResponse.Merge(dst, src) +} +func (m *UpdateResourcesResponse) XXX_Size() int { + return xxx_messageInfo_UpdateResourcesResponse.Size(m) +} +func (m *UpdateResourcesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_UpdateResourcesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_UpdateResourcesResponse proto.InternalMessageInfo + +type VersionRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *VersionRequest) Reset() { *m = VersionRequest{} } +func (m *VersionRequest) String() string { return proto.CompactTextString(m) } +func (*VersionRequest) ProtoMessage() {} +func (*VersionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{8} +} +func (m *VersionRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_VersionRequest.Unmarshal(m, b) +} +func (m *VersionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_VersionRequest.Marshal(b, m, deterministic) +} +func (dst *VersionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_VersionRequest.Merge(dst, src) +} +func (m *VersionRequest) XXX_Size() int { + return xxx_messageInfo_VersionRequest.Size(m) +} +func (m *VersionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_VersionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_VersionRequest proto.InternalMessageInfo + +type VersionResponse struct { + Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *VersionResponse) Reset() { *m = VersionResponse{} } +func (m *VersionResponse) String() string { return proto.CompactTextString(m) } +func (*VersionResponse) ProtoMessage() {} +func (*VersionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{9} +} +func (m *VersionResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_VersionResponse.Unmarshal(m, b) +} +func (m *VersionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_VersionResponse.Marshal(b, m, deterministic) +} +func (dst *VersionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_VersionResponse.Merge(dst, src) +} +func (m *VersionResponse) XXX_Size() int { + return xxx_messageInfo_VersionResponse.Size(m) +} +func (m *VersionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_VersionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_VersionResponse proto.InternalMessageInfo + +func (m *VersionResponse) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +type StatsRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StatsRequest) Reset() { *m = StatsRequest{} } +func (m *StatsRequest) String() string { return proto.CompactTextString(m) } +func (*StatsRequest) ProtoMessage() {} +func (*StatsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{10} +} +func (m *StatsRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StatsRequest.Unmarshal(m, b) +} +func (m *StatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StatsRequest.Marshal(b, m, deterministic) +} +func (dst *StatsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_StatsRequest.Merge(dst, src) +} +func (m *StatsRequest) XXX_Size() int { + return xxx_messageInfo_StatsRequest.Size(m) +} +func (m *StatsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_StatsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_StatsRequest proto.InternalMessageInfo + +type StatsResponse struct { + Stats *proto1.TaskStats `protobuf:"bytes,1,opt,name=stats,proto3" json:"stats,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StatsResponse) Reset() { *m = StatsResponse{} } +func (m *StatsResponse) String() string { return proto.CompactTextString(m) } +func (*StatsResponse) ProtoMessage() {} +func (*StatsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{11} +} +func (m *StatsResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StatsResponse.Unmarshal(m, b) +} +func (m *StatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StatsResponse.Marshal(b, m, deterministic) +} +func (dst *StatsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_StatsResponse.Merge(dst, src) +} +func (m *StatsResponse) XXX_Size() int { + return xxx_messageInfo_StatsResponse.Size(m) +} +func (m *StatsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_StatsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_StatsResponse proto.InternalMessageInfo + +func (m *StatsResponse) GetStats() *proto1.TaskStats { + if m != nil { + return m.Stats + } + return nil +} + +type SignalRequest struct { + Signal string `protobuf:"bytes,1,opt,name=signal,proto3" json:"signal,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SignalRequest) Reset() { *m = SignalRequest{} } +func (m *SignalRequest) String() string { return proto.CompactTextString(m) } +func (*SignalRequest) ProtoMessage() {} +func (*SignalRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{12} +} +func (m *SignalRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SignalRequest.Unmarshal(m, b) +} +func (m *SignalRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SignalRequest.Marshal(b, m, deterministic) +} +func (dst *SignalRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SignalRequest.Merge(dst, src) +} +func (m *SignalRequest) XXX_Size() int { + return xxx_messageInfo_SignalRequest.Size(m) +} +func (m *SignalRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SignalRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SignalRequest proto.InternalMessageInfo + +func (m *SignalRequest) GetSignal() string { + if m != nil { + return m.Signal + } + return "" +} + +type SignalResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SignalResponse) Reset() { *m = SignalResponse{} } +func (m *SignalResponse) String() string { return proto.CompactTextString(m) } +func (*SignalResponse) ProtoMessage() {} +func (*SignalResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{13} +} +func (m *SignalResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SignalResponse.Unmarshal(m, b) +} +func (m *SignalResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SignalResponse.Marshal(b, m, deterministic) +} +func (dst *SignalResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SignalResponse.Merge(dst, src) +} +func (m *SignalResponse) XXX_Size() int { + return xxx_messageInfo_SignalResponse.Size(m) +} +func (m *SignalResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SignalResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_SignalResponse proto.InternalMessageInfo + +type ExecRequest struct { + Deadline *timestamp.Timestamp `protobuf:"bytes,1,opt,name=deadline,proto3" json:"deadline,omitempty"` + Cmd string `protobuf:"bytes,2,opt,name=cmd,proto3" json:"cmd,omitempty"` + Args []string `protobuf:"bytes,3,rep,name=args,proto3" json:"args,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ExecRequest) Reset() { *m = ExecRequest{} } +func (m *ExecRequest) String() string { return proto.CompactTextString(m) } +func (*ExecRequest) ProtoMessage() {} +func (*ExecRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{14} +} +func (m *ExecRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ExecRequest.Unmarshal(m, b) +} +func (m *ExecRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ExecRequest.Marshal(b, m, deterministic) +} +func (dst *ExecRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExecRequest.Merge(dst, src) +} +func (m *ExecRequest) XXX_Size() int { + return xxx_messageInfo_ExecRequest.Size(m) +} +func (m *ExecRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ExecRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ExecRequest proto.InternalMessageInfo + +func (m *ExecRequest) GetDeadline() *timestamp.Timestamp { + if m != nil { + return m.Deadline + } + return nil +} + +func (m *ExecRequest) GetCmd() string { + if m != nil { + return m.Cmd + } + return "" +} + +func (m *ExecRequest) GetArgs() []string { + if m != nil { + return m.Args + } + return nil +} + +type ExecResponse struct { + Output []byte `protobuf:"bytes,1,opt,name=output,proto3" json:"output,omitempty"` + ExitCode int32 `protobuf:"varint,2,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ExecResponse) Reset() { *m = ExecResponse{} } +func (m *ExecResponse) String() string { return proto.CompactTextString(m) } +func (*ExecResponse) ProtoMessage() {} +func (*ExecResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{15} +} +func (m *ExecResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ExecResponse.Unmarshal(m, b) +} +func (m *ExecResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ExecResponse.Marshal(b, m, deterministic) +} +func (dst *ExecResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExecResponse.Merge(dst, src) +} +func (m *ExecResponse) XXX_Size() int { + return xxx_messageInfo_ExecResponse.Size(m) +} +func (m *ExecResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ExecResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ExecResponse proto.InternalMessageInfo + +func (m *ExecResponse) GetOutput() []byte { + if m != nil { + return m.Output + } + return nil +} + +func (m *ExecResponse) GetExitCode() int32 { + if m != nil { + return m.ExitCode + } + return 0 +} + +type Resources struct { + Cpu int32 `protobuf:"varint,1,opt,name=cpu,proto3" json:"cpu,omitempty"` + MemoryMB int32 `protobuf:"varint,2,opt,name=memoryMB,proto3" json:"memoryMB,omitempty"` + DiskMB int32 `protobuf:"varint,3,opt,name=diskMB,proto3" json:"diskMB,omitempty"` + Iops int32 `protobuf:"varint,4,opt,name=iops,proto3" json:"iops,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Resources) Reset() { *m = Resources{} } +func (m *Resources) String() string { return proto.CompactTextString(m) } +func (*Resources) ProtoMessage() {} +func (*Resources) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{16} +} +func (m *Resources) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Resources.Unmarshal(m, b) +} +func (m *Resources) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Resources.Marshal(b, m, deterministic) +} +func (dst *Resources) XXX_Merge(src proto.Message) { + xxx_messageInfo_Resources.Merge(dst, src) +} +func (m *Resources) XXX_Size() int { + return xxx_messageInfo_Resources.Size(m) +} +func (m *Resources) XXX_DiscardUnknown() { + xxx_messageInfo_Resources.DiscardUnknown(m) +} + +var xxx_messageInfo_Resources proto.InternalMessageInfo + +func (m *Resources) GetCpu() int32 { + if m != nil { + return m.Cpu + } + return 0 +} + +func (m *Resources) GetMemoryMB() int32 { + if m != nil { + return m.MemoryMB + } + return 0 +} + +func (m *Resources) GetDiskMB() int32 { + if m != nil { + return m.DiskMB + } + return 0 +} + +func (m *Resources) GetIops() int32 { + if m != nil { + return m.Iops + } + return 0 +} + +type ProcessState struct { + Pid int32 `protobuf:"varint,1,opt,name=pid,proto3" json:"pid,omitempty"` + ExitCode int32 `protobuf:"varint,2,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"` + Signal int32 `protobuf:"varint,3,opt,name=signal,proto3" json:"signal,omitempty"` + Time *timestamp.Timestamp `protobuf:"bytes,4,opt,name=time,proto3" json:"time,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ProcessState) Reset() { *m = ProcessState{} } +func (m *ProcessState) String() string { return proto.CompactTextString(m) } +func (*ProcessState) ProtoMessage() {} +func (*ProcessState) Descriptor() ([]byte, []int) { + return fileDescriptor_executor_e0a843141d496249, []int{17} +} +func (m *ProcessState) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ProcessState.Unmarshal(m, b) +} +func (m *ProcessState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ProcessState.Marshal(b, m, deterministic) +} +func (dst *ProcessState) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProcessState.Merge(dst, src) +} +func (m *ProcessState) XXX_Size() int { + return xxx_messageInfo_ProcessState.Size(m) +} +func (m *ProcessState) XXX_DiscardUnknown() { + xxx_messageInfo_ProcessState.DiscardUnknown(m) +} + +var xxx_messageInfo_ProcessState proto.InternalMessageInfo + +func (m *ProcessState) GetPid() int32 { + if m != nil { + return m.Pid + } + return 0 +} + +func (m *ProcessState) GetExitCode() int32 { + if m != nil { + return m.ExitCode + } + return 0 +} + +func (m *ProcessState) GetSignal() int32 { + if m != nil { + return m.Signal + } + return 0 +} + +func (m *ProcessState) GetTime() *timestamp.Timestamp { + if m != nil { + return m.Time + } + return nil +} + +func init() { + proto.RegisterType((*LaunchRequest)(nil), "hashicorp.nomad.plugins.executor.proto.LaunchRequest") + proto.RegisterType((*LaunchResponse)(nil), "hashicorp.nomad.plugins.executor.proto.LaunchResponse") + proto.RegisterType((*WaitRequest)(nil), "hashicorp.nomad.plugins.executor.proto.WaitRequest") + proto.RegisterType((*WaitResponse)(nil), "hashicorp.nomad.plugins.executor.proto.WaitResponse") + proto.RegisterType((*ShutdownRequest)(nil), "hashicorp.nomad.plugins.executor.proto.ShutdownRequest") + proto.RegisterType((*ShutdownResponse)(nil), "hashicorp.nomad.plugins.executor.proto.ShutdownResponse") + proto.RegisterType((*UpdateResourcesRequest)(nil), "hashicorp.nomad.plugins.executor.proto.UpdateResourcesRequest") + proto.RegisterType((*UpdateResourcesResponse)(nil), "hashicorp.nomad.plugins.executor.proto.UpdateResourcesResponse") + proto.RegisterType((*VersionRequest)(nil), "hashicorp.nomad.plugins.executor.proto.VersionRequest") + proto.RegisterType((*VersionResponse)(nil), "hashicorp.nomad.plugins.executor.proto.VersionResponse") + proto.RegisterType((*StatsRequest)(nil), "hashicorp.nomad.plugins.executor.proto.StatsRequest") + proto.RegisterType((*StatsResponse)(nil), "hashicorp.nomad.plugins.executor.proto.StatsResponse") + proto.RegisterType((*SignalRequest)(nil), "hashicorp.nomad.plugins.executor.proto.SignalRequest") + proto.RegisterType((*SignalResponse)(nil), "hashicorp.nomad.plugins.executor.proto.SignalResponse") + proto.RegisterType((*ExecRequest)(nil), "hashicorp.nomad.plugins.executor.proto.ExecRequest") + proto.RegisterType((*ExecResponse)(nil), "hashicorp.nomad.plugins.executor.proto.ExecResponse") + proto.RegisterType((*Resources)(nil), "hashicorp.nomad.plugins.executor.proto.Resources") + proto.RegisterType((*ProcessState)(nil), "hashicorp.nomad.plugins.executor.proto.ProcessState") +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// ExecutorClient is the client API for Executor service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ExecutorClient interface { + Launch(ctx context.Context, in *LaunchRequest, opts ...grpc.CallOption) (*LaunchResponse, error) + Wait(ctx context.Context, in *WaitRequest, opts ...grpc.CallOption) (*WaitResponse, error) + Shutdown(ctx context.Context, in *ShutdownRequest, opts ...grpc.CallOption) (*ShutdownResponse, error) + UpdateResources(ctx context.Context, in *UpdateResourcesRequest, opts ...grpc.CallOption) (*UpdateResourcesResponse, error) + Version(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*VersionResponse, error) + Stats(ctx context.Context, in *StatsRequest, opts ...grpc.CallOption) (*StatsResponse, error) + Signal(ctx context.Context, in *SignalRequest, opts ...grpc.CallOption) (*SignalResponse, error) + Exec(ctx context.Context, in *ExecRequest, opts ...grpc.CallOption) (*ExecResponse, error) +} + +type executorClient struct { + cc *grpc.ClientConn +} + +func NewExecutorClient(cc *grpc.ClientConn) ExecutorClient { + return &executorClient{cc} +} + +func (c *executorClient) Launch(ctx context.Context, in *LaunchRequest, opts ...grpc.CallOption) (*LaunchResponse, error) { + out := new(LaunchResponse) + err := c.cc.Invoke(ctx, "/hashicorp.nomad.plugins.executor.proto.Executor/Launch", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *executorClient) Wait(ctx context.Context, in *WaitRequest, opts ...grpc.CallOption) (*WaitResponse, error) { + out := new(WaitResponse) + err := c.cc.Invoke(ctx, "/hashicorp.nomad.plugins.executor.proto.Executor/Wait", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *executorClient) Shutdown(ctx context.Context, in *ShutdownRequest, opts ...grpc.CallOption) (*ShutdownResponse, error) { + out := new(ShutdownResponse) + err := c.cc.Invoke(ctx, "/hashicorp.nomad.plugins.executor.proto.Executor/Shutdown", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *executorClient) UpdateResources(ctx context.Context, in *UpdateResourcesRequest, opts ...grpc.CallOption) (*UpdateResourcesResponse, error) { + out := new(UpdateResourcesResponse) + err := c.cc.Invoke(ctx, "/hashicorp.nomad.plugins.executor.proto.Executor/UpdateResources", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *executorClient) Version(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*VersionResponse, error) { + out := new(VersionResponse) + err := c.cc.Invoke(ctx, "/hashicorp.nomad.plugins.executor.proto.Executor/Version", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *executorClient) Stats(ctx context.Context, in *StatsRequest, opts ...grpc.CallOption) (*StatsResponse, error) { + out := new(StatsResponse) + err := c.cc.Invoke(ctx, "/hashicorp.nomad.plugins.executor.proto.Executor/Stats", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *executorClient) Signal(ctx context.Context, in *SignalRequest, opts ...grpc.CallOption) (*SignalResponse, error) { + out := new(SignalResponse) + err := c.cc.Invoke(ctx, "/hashicorp.nomad.plugins.executor.proto.Executor/Signal", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *executorClient) Exec(ctx context.Context, in *ExecRequest, opts ...grpc.CallOption) (*ExecResponse, error) { + out := new(ExecResponse) + err := c.cc.Invoke(ctx, "/hashicorp.nomad.plugins.executor.proto.Executor/Exec", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ExecutorServer is the server API for Executor service. +type ExecutorServer interface { + Launch(context.Context, *LaunchRequest) (*LaunchResponse, error) + Wait(context.Context, *WaitRequest) (*WaitResponse, error) + Shutdown(context.Context, *ShutdownRequest) (*ShutdownResponse, error) + UpdateResources(context.Context, *UpdateResourcesRequest) (*UpdateResourcesResponse, error) + Version(context.Context, *VersionRequest) (*VersionResponse, error) + Stats(context.Context, *StatsRequest) (*StatsResponse, error) + Signal(context.Context, *SignalRequest) (*SignalResponse, error) + Exec(context.Context, *ExecRequest) (*ExecResponse, error) +} + +func RegisterExecutorServer(s *grpc.Server, srv ExecutorServer) { + s.RegisterService(&_Executor_serviceDesc, srv) +} + +func _Executor_Launch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LaunchRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ExecutorServer).Launch(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/hashicorp.nomad.plugins.executor.proto.Executor/Launch", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ExecutorServer).Launch(ctx, req.(*LaunchRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Executor_Wait_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WaitRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ExecutorServer).Wait(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/hashicorp.nomad.plugins.executor.proto.Executor/Wait", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ExecutorServer).Wait(ctx, req.(*WaitRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Executor_Shutdown_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ShutdownRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ExecutorServer).Shutdown(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/hashicorp.nomad.plugins.executor.proto.Executor/Shutdown", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ExecutorServer).Shutdown(ctx, req.(*ShutdownRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Executor_UpdateResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateResourcesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ExecutorServer).UpdateResources(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/hashicorp.nomad.plugins.executor.proto.Executor/UpdateResources", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ExecutorServer).UpdateResources(ctx, req.(*UpdateResourcesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Executor_Version_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(VersionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ExecutorServer).Version(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/hashicorp.nomad.plugins.executor.proto.Executor/Version", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ExecutorServer).Version(ctx, req.(*VersionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Executor_Stats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StatsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ExecutorServer).Stats(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/hashicorp.nomad.plugins.executor.proto.Executor/Stats", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ExecutorServer).Stats(ctx, req.(*StatsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Executor_Signal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SignalRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ExecutorServer).Signal(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/hashicorp.nomad.plugins.executor.proto.Executor/Signal", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ExecutorServer).Signal(ctx, req.(*SignalRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Executor_Exec_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ExecRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ExecutorServer).Exec(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/hashicorp.nomad.plugins.executor.proto.Executor/Exec", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ExecutorServer).Exec(ctx, req.(*ExecRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Executor_serviceDesc = grpc.ServiceDesc{ + ServiceName: "hashicorp.nomad.plugins.executor.proto.Executor", + HandlerType: (*ExecutorServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Launch", + Handler: _Executor_Launch_Handler, + }, + { + MethodName: "Wait", + Handler: _Executor_Wait_Handler, + }, + { + MethodName: "Shutdown", + Handler: _Executor_Shutdown_Handler, + }, + { + MethodName: "UpdateResources", + Handler: _Executor_UpdateResources_Handler, + }, + { + MethodName: "Version", + Handler: _Executor_Version_Handler, + }, + { + MethodName: "Stats", + Handler: _Executor_Stats_Handler, + }, + { + MethodName: "Signal", + Handler: _Executor_Signal_Handler, + }, + { + MethodName: "Exec", + Handler: _Executor_Exec_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "plugins/executor/proto/executor.proto", +} + +func init() { + proto.RegisterFile("plugins/executor/proto/executor.proto", fileDescriptor_executor_e0a843141d496249) +} + +var fileDescriptor_executor_e0a843141d496249 = []byte{ + // 869 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x5d, 0x6f, 0xe3, 0x44, + 0x14, 0x5d, 0x37, 0x75, 0xe2, 0xdc, 0xa4, 0x4d, 0x34, 0x42, 0xc5, 0x6b, 0x1e, 0x36, 0x58, 0x82, + 0x8d, 0x84, 0xe4, 0x2c, 0xdd, 0x2f, 0x5e, 0x00, 0xa9, 0x65, 0x79, 0xea, 0x42, 0xe5, 0x2e, 0xac, + 0xc4, 0x03, 0xc1, 0xb5, 0x07, 0x67, 0x94, 0xd8, 0x63, 0x66, 0xc6, 0xa1, 0x95, 0x90, 0x78, 0xe2, + 0x1f, 0xf0, 0x13, 0xf9, 0x11, 0x3c, 0xa2, 0xf9, 0x72, 0x93, 0x2e, 0x14, 0x07, 0xb4, 0x4f, 0x99, + 0x7b, 0x73, 0xcf, 0x3d, 0xf7, 0xce, 0x1c, 0x1f, 0xf8, 0xa0, 0x5a, 0xd5, 0x39, 0x29, 0xf9, 0x0c, + 0x5f, 0xe1, 0xb4, 0x16, 0x94, 0xcd, 0x2a, 0x46, 0x05, 0x6d, 0xc2, 0x48, 0x85, 0xe8, 0xc3, 0x45, + 0xc2, 0x17, 0x24, 0xa5, 0xac, 0x8a, 0x4a, 0x5a, 0x24, 0x59, 0x64, 0x60, 0xd1, 0x76, 0x5d, 0xf0, + 0x20, 0xa7, 0x34, 0x5f, 0x61, 0xdd, 0xe4, 0xb2, 0xfe, 0x71, 0x26, 0x48, 0x81, 0xb9, 0x48, 0x8a, + 0xca, 0x14, 0x7c, 0x9a, 0x13, 0xb1, 0xa8, 0x2f, 0xa3, 0x94, 0x16, 0xb3, 0xa6, 0xe7, 0x4c, 0xf5, + 0x9c, 0xd9, 0x51, 0x32, 0x46, 0xd6, 0x98, 0x71, 0x33, 0x89, 0x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 0xda, 0x56, 0xf3, 0x5b, + 0xfe, 0x1e, 0x3c, 0xdb, 0x15, 0x66, 0x64, 0x72, 0x0f, 0x71, 0xd8, 0x97, 0x9e, 0x82, 0x1e, 0xb7, + 0xed, 0xb0, 0x61, 0x48, 0xc1, 0x93, 0xdd, 0x40, 0x0d, 0xe9, 0xaf, 0xe0, 0x59, 0x6b, 0x40, 0xcf, + 0xdb, 0xf6, 0xb8, 0x65, 0x4d, 0xc1, 0x27, 0xbb, 0x03, 0x9b, 0x01, 0x7e, 0x77, 0x60, 0x74, 0xcb, + 0x1d, 0xd0, 0x67, 0x6d, 0xfb, 0xfd, 0xbd, 0x83, 0x05, 0x9f, 0xff, 0x67, 0x7c, 0x33, 0xd6, 0x2f, + 0xd0, 0x33, 0x36, 0x84, 0x5a, 0xbf, 0xe8, 0xb6, 0x93, 0x05, 0xcf, 0x77, 0xc6, 0x35, 0xec, 0x6b, + 0x70, 0x95, 0xfd, 0xa0, 0xd6, 0xcf, 0xba, 0x69, 0x83, 0xc1, 0xd3, 0x1d, 0x51, 0x0d, 0xef, 0x35, + 0x74, 0xb5, 0x7b, 0xb5, 0x57, 0xff, 0x96, 0x2d, 0xb6, 0x57, 0xff, 0x2d, 0x93, 0x54, 0xea, 0x97, + 0x1f, 0x61, 0x7b, 0xf5, 0x6f, 0x98, 0x6a, 0x7b, 0xf5, 0x6f, 0x9a, 0x63, 0x78, 0xef, 0xa4, 0xf7, + 0x9d, 0xab, 0x6d, 0xa1, 0xab, 0x7e, 0x1e, 0xff, 0x15, 0x00, 0x00, 0xff, 0xff, 0xa6, 0x03, 0x32, + 0x69, 0x5f, 0x0a, 0x00, 0x00, +} diff --git a/plugins/executor/proto/executor.proto b/plugins/executor/proto/executor.proto new file mode 100644 index 000000000..1ec576caa --- /dev/null +++ b/plugins/executor/proto/executor.proto @@ -0,0 +1,96 @@ +syntax = "proto3"; +package hashicorp.nomad.plugins.executor.proto; +option go_package = "proto"; + +import "google/protobuf/timestamp.proto"; +import "github.com/hashicorp/nomad/plugins/drivers/proto/driver.proto"; + +service Executor { + rpc Launch(LaunchRequest) returns (LaunchResponse) {} + rpc Wait(WaitRequest) returns (WaitResponse) {} + rpc Shutdown(ShutdownRequest) returns (ShutdownResponse) {} + rpc UpdateResources(UpdateResourcesRequest) returns (UpdateResourcesResponse) {} + rpc Version(VersionRequest) returns (VersionResponse) {} + rpc Stats(StatsRequest) returns (StatsResponse) {} + rpc Signal(SignalRequest) returns (SignalResponse) {} + rpc Exec(ExecRequest) returns (ExecResponse) {} +} + +message LaunchRequest { + string cmd = 1; + repeated string args = 2; + Resources resources = 3; + string stdout_path = 4; + string stderr_path = 5; + repeated string env = 6; + string user = 7; + string task_dir = 8; + bool resource_limits = 9; + bool basic_process_cgroup = 10; +} + +message LaunchResponse { + ProcessState process = 1; +} + +message WaitRequest {} + +message WaitResponse{ + ProcessState process = 1; +} + +message ShutdownRequest { + string signal = 1; + int64 grace_period = 2; +} + +message ShutdownResponse {} + +message UpdateResourcesRequest{ + Resources resources = 1; +} + +message UpdateResourcesResponse {} + +message VersionRequest {} + +message VersionResponse{ + string version = 1; +} + +message StatsRequest {} + +message StatsResponse { + hashicorp.nomad.plugins.drivers.proto.TaskStats stats = 1; +} + +message SignalRequest { + string signal = 1; +} + +message SignalResponse {} + +message ExecRequest { + google.protobuf.Timestamp deadline = 1; + string cmd = 2; + repeated string args = 3; +} + +message ExecResponse { + bytes output = 1; + int32 exit_code = 2; +} + +message Resources { + int32 cpu = 1; + int32 memoryMB = 2; + int32 diskMB = 3; + int32 iops = 4; +} + +message ProcessState { + int32 pid = 1; + int32 exit_code = 2; + int32 signal = 3; + google.protobuf.Timestamp time = 4; +} diff --git a/plugins/executor/server.go b/plugins/executor/server.go new file mode 100644 index 000000000..d3146dd70 --- /dev/null +++ b/plugins/executor/server.go @@ -0,0 +1,132 @@ +package executor + +import ( + "fmt" + "time" + + "github.com/golang/protobuf/ptypes" + "github.com/hashicorp/consul-template/signals" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/plugins/drivers" + "github.com/hashicorp/nomad/plugins/executor/proto" + "golang.org/x/net/context" +) + +type grpcExecutorServer struct { + impl structs.Executor + doneCtx context.Context +} + +func (s *grpcExecutorServer) Launch(ctx context.Context, req *proto.LaunchRequest) (*proto.LaunchResponse, error) { + ps, err := s.impl.Launch(&structs.ExecCommand{ + Cmd: req.Cmd, + Args: req.Args, + Resources: resourcesFromProto(req.Resources), + StdoutPath: req.StdoutPath, + StderrPath: req.StderrPath, + Env: req.Env, + User: req.User, + TaskDir: req.TaskDir, + ResourceLimits: req.ResourceLimits, + BasicProcessCgroup: req.BasicProcessCgroup, + }) + + if err != nil { + return nil, err + } + + process, err := processStateToProto(ps) + if err != nil { + return nil, err + } + + return &proto.LaunchResponse{ + Process: process, + }, nil +} + +func (s *grpcExecutorServer) Wait(ctx context.Context, req *proto.WaitRequest) (*proto.WaitResponse, error) { + ps, err := s.impl.Wait(ctx) + if err != nil { + return nil, err + } + + process, err := processStateToProto(ps) + if err != nil { + return nil, err + } + + return &proto.WaitResponse{ + Process: process, + }, nil +} + +func (s *grpcExecutorServer) Shutdown(ctx context.Context, req *proto.ShutdownRequest) (*proto.ShutdownResponse, error) { + if err := s.impl.Shutdown(req.Signal, time.Duration(req.GracePeriod)); err != nil { + return nil, err + } + + return &proto.ShutdownResponse{}, nil +} + +func (s *grpcExecutorServer) UpdateResources(ctx context.Context, req *proto.UpdateResourcesRequest) (*proto.UpdateResourcesResponse, error) { + if err := s.impl.UpdateResources(resourcesFromProto(req.Resources)); err != nil { + return nil, err + } + + return &proto.UpdateResourcesResponse{}, nil +} + +func (s *grpcExecutorServer) Version(context.Context, *proto.VersionRequest) (*proto.VersionResponse, error) { + v, err := s.impl.Version() + if err != nil { + return nil, err + } + + return &proto.VersionResponse{ + Version: v.Version, + }, nil +} + +func (s *grpcExecutorServer) Stats(context.Context, *proto.StatsRequest) (*proto.StatsResponse, error) { + stats, err := s.impl.Stats() + if err != nil { + return nil, err + } + + pbStats, err := drivers.TaskStatsToProto(stats) + if err != nil { + return nil, err + } + + return &proto.StatsResponse{ + Stats: pbStats, + }, nil +} + +func (s *grpcExecutorServer) Signal(ctx context.Context, req *proto.SignalRequest) (*proto.SignalResponse, error) { + if sig, ok := signals.SignalLookup[req.Signal]; ok { + if err := s.impl.Signal(sig); err != nil { + return nil, err + } + return &proto.SignalResponse{}, nil + } + return nil, fmt.Errorf("invalid signal sent by client") +} + +func (s *grpcExecutorServer) Exec(ctx context.Context, req *proto.ExecRequest) (*proto.ExecResponse, error) { + deadline, err := ptypes.Timestamp(req.Deadline) + if err != nil { + return nil, err + } + + out, exit, err := s.impl.Exec(deadline, req.Cmd, req.Args) + if err != nil { + return nil, err + } + + return &proto.ExecResponse{ + Output: out, + ExitCode: int32(exit), + }, nil +} diff --git a/plugins/executor/utils.go b/plugins/executor/utils.go new file mode 100644 index 000000000..e511c42a1 --- /dev/null +++ b/plugins/executor/utils.go @@ -0,0 +1,62 @@ +package executor + +import ( + "github.com/golang/protobuf/ptypes" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/plugins/executor/proto" +) + +func processStateToProto(ps *structs.ProcessState) (*proto.ProcessState, error) { + timestamp, err := ptypes.TimestampProto(ps.Time) + if err != nil { + return nil, err + } + pb := &proto.ProcessState{ + Pid: int32(ps.Pid), + ExitCode: int32(ps.ExitCode), + Signal: int32(ps.Signal), + Time: timestamp, + } + + return pb, nil +} + +func processStateFromProto(pb *proto.ProcessState) (*structs.ProcessState, error) { + timestamp, err := ptypes.Timestamp(pb.Time) + if err != nil { + return nil, err + } + + return &structs.ProcessState{ + Pid: int(pb.Pid), + ExitCode: int(pb.ExitCode), + Signal: int(pb.Signal), + Time: timestamp, + }, nil +} + +func resourcesToProto(r *structs.Resources) *proto.Resources { + if r == nil { + return &proto.Resources{} + } + + return &proto.Resources{ + Cpu: int32(r.CPU), + MemoryMB: int32(r.MemoryMB), + DiskMB: int32(r.DiskMB), + Iops: int32(r.IOPS), + } +} + +func resourcesFromProto(pb *proto.Resources) *structs.Resources { + if pb == nil { + return &structs.Resources{} + } + + return &structs.Resources{ + CPU: int(pb.Cpu), + MemoryMB: int(pb.MemoryMB), + DiskMB: int(pb.DiskMB), + IOPS: int(pb.Iops), + } +} From 2d33d48980ad53787e5185de72ec20e2be2bbd92 Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Wed, 5 Dec 2018 11:04:18 -0500 Subject: [PATCH 02/13] executor: update driver references --- drivers/exec/driver.go | 10 +++++----- drivers/exec/handle.go | 7 ++++--- drivers/java/driver.go | 8 ++++---- drivers/java/handle.go | 7 ++++--- drivers/qemu/driver.go | 6 +++--- drivers/qemu/handle.go | 7 ++++--- drivers/rawexec/driver.go | 6 +++--- drivers/rawexec/handle.go | 7 ++++--- drivers/rkt/driver.go | 8 ++++---- drivers/rkt/handle.go | 7 ++++--- 10 files changed, 39 insertions(+), 34 deletions(-) diff --git a/drivers/exec/driver.go b/drivers/exec/driver.go index 14eca02c3..7398ee022 100644 --- a/drivers/exec/driver.go +++ b/drivers/exec/driver.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/nomad/client/fingerprint" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/eventer" - "github.com/hashicorp/nomad/drivers/shared/executor" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/drivers/utils" @@ -298,7 +298,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru return nil, nil, fmt.Errorf("failed to create executor: %v", err) } - execCmd := &executor.ExecCommand{ + execCmd := &structs.ExecCommand{ Cmd: driverConfig.Command, Args: driverConfig.Args, Env: cfg.EnvList(), @@ -345,12 +345,12 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru return handle, nil, nil } -func toExecResources(resources *drivers.Resources) *executor.Resources { +func toExecResources(resources *drivers.Resources) *structs.Resources { if resources == nil || resources.NomadResources == nil { return nil } - return &executor.Resources{ + return &structs.Resources{ CPU: resources.NomadResources.CPU, MemoryMB: resources.NomadResources.MemoryMB, DiskMB: resources.NomadResources.DiskMB, @@ -373,7 +373,7 @@ func (d *Driver) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.E func (d *Driver) handleWait(ctx context.Context, handle *taskHandle, ch chan *drivers.ExitResult) { defer close(ch) var result *drivers.ExitResult - ps, err := handle.exec.Wait() + ps, err := handle.exec.Wait(ctx) if err != nil { result = &drivers.ExitResult{ Err: fmt.Errorf("executor: error waiting on process: %v", err), diff --git a/drivers/exec/handle.go b/drivers/exec/handle.go index 3feb158dc..1c73573ac 100644 --- a/drivers/exec/handle.go +++ b/drivers/exec/handle.go @@ -1,18 +1,19 @@ package exec import ( + "context" "strconv" "sync" "time" hclog "github.com/hashicorp/go-hclog" plugin "github.com/hashicorp/go-plugin" - "github.com/hashicorp/nomad/drivers/shared/executor" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" "github.com/hashicorp/nomad/plugins/drivers" ) type taskHandle struct { - exec executor.Executor + exec structs.Executor pid int pluginClient *plugin.Client logger hclog.Logger @@ -58,7 +59,7 @@ func (h *taskHandle) run() { h.stateLock.Unlock() // Block until process exits - ps, err := h.exec.Wait() + ps, err := h.exec.Wait(context.Background()) h.stateLock.Lock() defer h.stateLock.Unlock() diff --git a/drivers/java/driver.go b/drivers/java/driver.go index a9ac5a0fb..840f99245 100644 --- a/drivers/java/driver.go +++ b/drivers/java/driver.go @@ -16,7 +16,7 @@ import ( "github.com/hashicorp/nomad/client/fingerprint" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/eventer" - "github.com/hashicorp/nomad/drivers/shared/executor" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/drivers/utils" @@ -330,13 +330,13 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru return nil, nil, fmt.Errorf("failed to create executor: %v", err) } - execCmd := &executor.ExecCommand{ + execCmd := &structs.ExecCommand{ Cmd: absPath, Args: args, Env: cfg.EnvList(), User: cfg.User, ResourceLimits: true, - Resources: &executor.Resources{ + Resources: &structs.Resources{ CPU: cfg.Resources.NomadResources.CPU, MemoryMB: cfg.Resources.NomadResources.MemoryMB, DiskMB: cfg.Resources.NomadResources.DiskMB, @@ -426,7 +426,7 @@ func (d *Driver) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.E func (d *Driver) handleWait(ctx context.Context, handle *taskHandle, ch chan *drivers.ExitResult) { defer close(ch) var result *drivers.ExitResult - ps, err := handle.exec.Wait() + ps, err := handle.exec.Wait(ctx) if err != nil { result = &drivers.ExitResult{ Err: fmt.Errorf("executor: error waiting on process: %v", err), diff --git a/drivers/java/handle.go b/drivers/java/handle.go index 7d493a4a4..339036612 100644 --- a/drivers/java/handle.go +++ b/drivers/java/handle.go @@ -1,18 +1,19 @@ package java import ( + "context" "strconv" "sync" "time" "github.com/hashicorp/go-hclog" "github.com/hashicorp/go-plugin" - "github.com/hashicorp/nomad/drivers/shared/executor" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" "github.com/hashicorp/nomad/plugins/drivers" ) type taskHandle struct { - exec executor.Executor + exec structs.Executor pid int pluginClient *plugin.Client logger hclog.Logger @@ -57,7 +58,7 @@ func (h *taskHandle) run() { } h.stateLock.Unlock() - ps, err := h.exec.Wait() + ps, err := h.exec.Wait(context.Background()) h.stateLock.Lock() defer h.stateLock.Unlock() diff --git a/drivers/qemu/driver.go b/drivers/qemu/driver.go index 2a37aa6b5..1f632e22c 100644 --- a/drivers/qemu/driver.go +++ b/drivers/qemu/driver.go @@ -18,7 +18,7 @@ import ( "github.com/hashicorp/go-plugin" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/eventer" - "github.com/hashicorp/nomad/drivers/shared/executor" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/drivers/utils" @@ -424,7 +424,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru return nil, nil, err } - execCmd := &executor.ExecCommand{ + execCmd := &structs.ExecCommand{ Cmd: args[0], Args: args[1:], Env: cfg.EnvList(), @@ -584,7 +584,7 @@ func GetAbsolutePath(bin string) (string, error) { func (d *Driver) handleWait(ctx context.Context, handle *taskHandle, ch chan *drivers.ExitResult) { defer close(ch) var result *drivers.ExitResult - ps, err := handle.exec.Wait() + ps, err := handle.exec.Wait(ctx) if err != nil { result = &drivers.ExitResult{ Err: fmt.Errorf("executor: error waiting on process: %v", err), diff --git a/drivers/qemu/handle.go b/drivers/qemu/handle.go index b7aca3614..4f54c22ad 100644 --- a/drivers/qemu/handle.go +++ b/drivers/qemu/handle.go @@ -1,18 +1,19 @@ package qemu import ( + "context" "strconv" "sync" "time" "github.com/hashicorp/go-hclog" "github.com/hashicorp/go-plugin" - "github.com/hashicorp/nomad/drivers/shared/executor" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" "github.com/hashicorp/nomad/plugins/drivers" ) type taskHandle struct { - exec executor.Executor + exec structs.Executor pid int pluginClient *plugin.Client logger hclog.Logger @@ -58,7 +59,7 @@ func (h *taskHandle) run() { } h.stateLock.Unlock() - ps, err := h.exec.Wait() + ps, err := h.exec.Wait(context.Background()) h.stateLock.Lock() defer h.stateLock.Unlock() diff --git a/drivers/rawexec/driver.go b/drivers/rawexec/driver.go index e182764ef..78cdad364 100644 --- a/drivers/rawexec/driver.go +++ b/drivers/rawexec/driver.go @@ -15,7 +15,7 @@ import ( plugin "github.com/hashicorp/go-plugin" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/eventer" - "github.com/hashicorp/nomad/drivers/shared/executor" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/drivers/utils" @@ -327,7 +327,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru // will cause an error. useCgroups := !d.config.NoCgroups && runtime.GOOS == "linux" && syscall.Geteuid() == 0 - execCmd := &executor.ExecCommand{ + execCmd := &structs.ExecCommand{ Cmd: driverConfig.Command, Args: driverConfig.Args, Env: cfg.EnvList(), @@ -388,7 +388,7 @@ func (d *Driver) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.E func (d *Driver) handleWait(ctx context.Context, handle *taskHandle, ch chan *drivers.ExitResult) { defer close(ch) var result *drivers.ExitResult - ps, err := handle.exec.Wait() + ps, err := handle.exec.Wait(ctx) if err != nil { result = &drivers.ExitResult{ Err: fmt.Errorf("executor: error waiting on process: %v", err), diff --git a/drivers/rawexec/handle.go b/drivers/rawexec/handle.go index 28d9129db..72401556a 100644 --- a/drivers/rawexec/handle.go +++ b/drivers/rawexec/handle.go @@ -1,18 +1,19 @@ package rawexec import ( + "context" "strconv" "sync" "time" hclog "github.com/hashicorp/go-hclog" plugin "github.com/hashicorp/go-plugin" - "github.com/hashicorp/nomad/drivers/shared/executor" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" "github.com/hashicorp/nomad/plugins/drivers" ) type taskHandle struct { - exec executor.Executor + exec structs.Executor pid int pluginClient *plugin.Client logger hclog.Logger @@ -58,7 +59,7 @@ func (h *taskHandle) run() { h.stateLock.Unlock() // Block until process exits - ps, err := h.exec.Wait() + ps, err := h.exec.Wait(context.Background()) h.stateLock.Lock() defer h.stateLock.Unlock() diff --git a/drivers/rkt/driver.go b/drivers/rkt/driver.go index b14c2da87..7cab0c8b0 100644 --- a/drivers/rkt/driver.go +++ b/drivers/rkt/driver.go @@ -28,7 +28,7 @@ import ( cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/client/taskenv" "github.com/hashicorp/nomad/drivers/shared/eventer" - "github.com/hashicorp/nomad/drivers/shared/executor" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/drivers/utils" @@ -643,11 +643,11 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru // Enable ResourceLimits to place the executor in a parent cgroup of // the rkt container. This allows stats collection via the executor to // work just like it does for exec. - execCmd := &executor.ExecCommand{ + execCmd := &structs.ExecCommand{ Cmd: absPath, Args: runArgs, ResourceLimits: true, - Resources: &executor.Resources{ + Resources: &structs.Resources{ CPU: int(cfg.Resources.LinuxResources.CPUShares), MemoryMB: int(drivers.BytesToMB(cfg.Resources.LinuxResources.MemoryLimitBytes)), DiskMB: cfg.Resources.NomadResources.DiskMB, @@ -995,7 +995,7 @@ func elide(inBuf bytes.Buffer) string { func (d *Driver) handleWait(ctx context.Context, handle *taskHandle, ch chan *drivers.ExitResult) { defer close(ch) var result *drivers.ExitResult - ps, err := handle.exec.Wait() + ps, err := handle.exec.Wait(ctx) if err != nil { result = &drivers.ExitResult{ Err: fmt.Errorf("executor: error waiting on process: %v", err), diff --git a/drivers/rkt/handle.go b/drivers/rkt/handle.go index a66e57b26..d77ae2173 100644 --- a/drivers/rkt/handle.go +++ b/drivers/rkt/handle.go @@ -3,6 +3,7 @@ package rkt import ( + "context" "strconv" "sync" "time" @@ -10,12 +11,12 @@ import ( hclog "github.com/hashicorp/go-hclog" plugin "github.com/hashicorp/go-plugin" "github.com/hashicorp/nomad/client/taskenv" - "github.com/hashicorp/nomad/drivers/shared/executor" + "github.com/hashicorp/nomad/drivers/shared/executor/structs" "github.com/hashicorp/nomad/plugins/drivers" ) type taskHandle struct { - exec executor.Executor + exec structs.Executor env *taskenv.TaskEnv uuid string pid int @@ -62,7 +63,7 @@ func (h *taskHandle) run() { } h.stateLock.Unlock() - ps, err := h.exec.Wait() + ps, err := h.exec.Wait(context.Background()) h.stateLock.Lock() defer h.stateLock.Unlock() From 8690d0ae75ec67f20c683a63accb307c4653484c Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Wed, 5 Dec 2018 11:07:48 -0500 Subject: [PATCH 03/13] executor: update test references --- drivers/shared/executor/executor_linux_test.go | 7 ++++--- drivers/shared/executor/executor_test.go | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/shared/executor/executor_linux_test.go b/drivers/shared/executor/executor_linux_test.go index 3b8219396..3298fdca3 100644 --- a/drivers/shared/executor/executor_linux_test.go +++ b/drivers/shared/executor/executor_linux_test.go @@ -1,6 +1,7 @@ package executor import ( + "context" "fmt" "io/ioutil" "os" @@ -96,7 +97,7 @@ func TestExecutor_IsolationAndConstraints(t *testing.T) { require.NoError(err) require.NotZero(ps.Pid) - state, err := executor.Wait() + state, err := executor.Wait(context.Background()) require.NoError(err) require.Zero(state.ExitCode) @@ -113,7 +114,7 @@ func TestExecutor_IsolationAndConstraints(t *testing.T) { actualMemLim := strings.TrimSpace(string(data)) require.Equal(actualMemLim, expectedMemLim) require.NoError(executor.Shutdown("", 0)) - executor.Wait() + executor.Wait(context.Background()) // Check if Nomad has actually removed the cgroups tu.WaitForResult(func() (bool, error) { @@ -176,7 +177,7 @@ func TestExecutor_ClientCleanup(t *testing.T) { require.NotZero(ps.Pid) time.Sleep(500 * time.Millisecond) require.NoError(executor.Shutdown("SIGINT", 100*time.Millisecond)) - executor.Wait() + executor.Wait(context.Background()) outWriter, _ := execCmd.GetWriters() output := outWriter.(*bufferCloser).String() diff --git a/drivers/shared/executor/executor_test.go b/drivers/shared/executor/executor_test.go index 109ae6641..aa4711ac9 100644 --- a/drivers/shared/executor/executor_test.go +++ b/drivers/shared/executor/executor_test.go @@ -2,6 +2,7 @@ package executor import ( "bytes" + "context" "fmt" "io/ioutil" "os" @@ -110,7 +111,7 @@ func TestExecutor_Start_Wait_Failure_Code(pt *testing.T) { ps, err := executor.Launch(execCmd) require.NoError(err) require.NotZero(ps.Pid) - ps, _ = executor.Wait() + ps, _ = executor.Wait(context.Background()) require.NotZero(ps.ExitCode, "expected exit code to be non zero") require.NoError(executor.Shutdown("SIGINT", 100*time.Millisecond)) }) @@ -134,7 +135,7 @@ func TestExecutor_Start_Wait(pt *testing.T) { require.NoError(err) require.NotZero(ps.Pid) - ps, err = executor.Wait() + ps, err = executor.Wait(context.Background()) require.NoError(err) require.NoError(executor.Shutdown("SIGINT", 100*time.Millisecond)) @@ -181,7 +182,7 @@ func TestExecutor_WaitExitSignal(pt *testing.T) { require.NoError(err) }() - ps, err = executor.Wait() + ps, err = executor.Wait(context.Background()) require.NoError(err) require.Equal(ps.Signal, int(syscall.SIGKILL)) }) From 0087a51a7ade86caa22b67e1007878864e68a81c Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Thu, 6 Dec 2018 20:54:14 -0500 Subject: [PATCH 04/13] executor: remove structs package --- drivers/exec/driver.go | 8 +- drivers/exec/handle.go | 4 +- drivers/java/driver.go | 6 +- drivers/java/handle.go | 4 +- drivers/qemu/driver.go | 4 +- drivers/qemu/handle.go | 4 +- drivers/rawexec/driver.go | 4 +- drivers/rawexec/handle.go | 4 +- drivers/rkt/driver.go | 6 +- drivers/rkt/handle.go | 4 +- drivers/shared/executor/executor.go | 190 ++++++++++++++++-- drivers/shared/executor/executor_linux.go | 33 ++- .../shared/executor/executor_linux_test.go | 9 +- drivers/shared/executor/executor_test.go | 13 +- drivers/shared/executor/structs/structs.go | 177 ---------------- plugins/drivers/utils/utils.go | 10 +- plugins/executor/client.go | 14 +- plugins/executor/server.go | 6 +- plugins/executor/utils.go | 16 +- 19 files changed, 251 insertions(+), 265 deletions(-) delete mode 100644 drivers/shared/executor/structs/structs.go diff --git a/drivers/exec/driver.go b/drivers/exec/driver.go index 7398ee022..9353bb695 100644 --- a/drivers/exec/driver.go +++ b/drivers/exec/driver.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/nomad/client/fingerprint" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/eventer" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/drivers/utils" @@ -298,7 +298,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru return nil, nil, fmt.Errorf("failed to create executor: %v", err) } - execCmd := &structs.ExecCommand{ + execCmd := &executor.ExecCommand{ Cmd: driverConfig.Command, Args: driverConfig.Args, Env: cfg.EnvList(), @@ -345,12 +345,12 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru return handle, nil, nil } -func toExecResources(resources *drivers.Resources) *structs.Resources { +func toExecResources(resources *drivers.Resources) *executor.Resources { if resources == nil || resources.NomadResources == nil { return nil } - return &structs.Resources{ + return &executor.Resources{ CPU: resources.NomadResources.CPU, MemoryMB: resources.NomadResources.MemoryMB, DiskMB: resources.NomadResources.DiskMB, diff --git a/drivers/exec/handle.go b/drivers/exec/handle.go index 1c73573ac..606406b64 100644 --- a/drivers/exec/handle.go +++ b/drivers/exec/handle.go @@ -8,12 +8,12 @@ import ( hclog "github.com/hashicorp/go-hclog" plugin "github.com/hashicorp/go-plugin" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/drivers" ) type taskHandle struct { - exec structs.Executor + exec executor.Executor pid int pluginClient *plugin.Client logger hclog.Logger diff --git a/drivers/java/driver.go b/drivers/java/driver.go index 840f99245..9fbf442c8 100644 --- a/drivers/java/driver.go +++ b/drivers/java/driver.go @@ -16,7 +16,7 @@ import ( "github.com/hashicorp/nomad/client/fingerprint" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/eventer" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/drivers/utils" @@ -330,13 +330,13 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru return nil, nil, fmt.Errorf("failed to create executor: %v", err) } - execCmd := &structs.ExecCommand{ + execCmd := &executor.ExecCommand{ Cmd: absPath, Args: args, Env: cfg.EnvList(), User: cfg.User, ResourceLimits: true, - Resources: &structs.Resources{ + Resources: &executor.Resources{ CPU: cfg.Resources.NomadResources.CPU, MemoryMB: cfg.Resources.NomadResources.MemoryMB, DiskMB: cfg.Resources.NomadResources.DiskMB, diff --git a/drivers/java/handle.go b/drivers/java/handle.go index 339036612..8ef2dc6a0 100644 --- a/drivers/java/handle.go +++ b/drivers/java/handle.go @@ -8,12 +8,12 @@ import ( "github.com/hashicorp/go-hclog" "github.com/hashicorp/go-plugin" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/drivers" ) type taskHandle struct { - exec structs.Executor + exec executor.Executor pid int pluginClient *plugin.Client logger hclog.Logger diff --git a/drivers/qemu/driver.go b/drivers/qemu/driver.go index 1f632e22c..9c498b9ce 100644 --- a/drivers/qemu/driver.go +++ b/drivers/qemu/driver.go @@ -18,7 +18,7 @@ import ( "github.com/hashicorp/go-plugin" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/eventer" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/drivers/utils" @@ -424,7 +424,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru return nil, nil, err } - execCmd := &structs.ExecCommand{ + execCmd := &executor.ExecCommand{ Cmd: args[0], Args: args[1:], Env: cfg.EnvList(), diff --git a/drivers/qemu/handle.go b/drivers/qemu/handle.go index 4f54c22ad..63223f1c2 100644 --- a/drivers/qemu/handle.go +++ b/drivers/qemu/handle.go @@ -8,12 +8,12 @@ import ( "github.com/hashicorp/go-hclog" "github.com/hashicorp/go-plugin" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/drivers" ) type taskHandle struct { - exec structs.Executor + exec executor.Executor pid int pluginClient *plugin.Client logger hclog.Logger diff --git a/drivers/rawexec/driver.go b/drivers/rawexec/driver.go index 78cdad364..c5adb62dd 100644 --- a/drivers/rawexec/driver.go +++ b/drivers/rawexec/driver.go @@ -15,7 +15,7 @@ import ( plugin "github.com/hashicorp/go-plugin" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/drivers/shared/eventer" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/drivers/utils" @@ -327,7 +327,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru // will cause an error. useCgroups := !d.config.NoCgroups && runtime.GOOS == "linux" && syscall.Geteuid() == 0 - execCmd := &structs.ExecCommand{ + execCmd := &executor.ExecCommand{ Cmd: driverConfig.Command, Args: driverConfig.Args, Env: cfg.EnvList(), diff --git a/drivers/rawexec/handle.go b/drivers/rawexec/handle.go index 72401556a..0e46277e3 100644 --- a/drivers/rawexec/handle.go +++ b/drivers/rawexec/handle.go @@ -8,12 +8,12 @@ import ( hclog "github.com/hashicorp/go-hclog" plugin "github.com/hashicorp/go-plugin" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/drivers" ) type taskHandle struct { - exec structs.Executor + exec executor.Executor pid int pluginClient *plugin.Client logger hclog.Logger diff --git a/drivers/rkt/driver.go b/drivers/rkt/driver.go index 7cab0c8b0..99ffea850 100644 --- a/drivers/rkt/driver.go +++ b/drivers/rkt/driver.go @@ -28,7 +28,7 @@ import ( cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/client/taskenv" "github.com/hashicorp/nomad/drivers/shared/eventer" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/drivers/utils" @@ -643,11 +643,11 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru // Enable ResourceLimits to place the executor in a parent cgroup of // the rkt container. This allows stats collection via the executor to // work just like it does for exec. - execCmd := &structs.ExecCommand{ + execCmd := &executor.ExecCommand{ Cmd: absPath, Args: runArgs, ResourceLimits: true, - Resources: &structs.Resources{ + Resources: &executor.Resources{ CPU: int(cfg.Resources.LinuxResources.CPUShares), MemoryMB: int(drivers.BytesToMB(cfg.Resources.LinuxResources.MemoryLimitBytes)), DiskMB: cfg.Resources.NomadResources.DiskMB, diff --git a/drivers/rkt/handle.go b/drivers/rkt/handle.go index d77ae2173..e9965a22f 100644 --- a/drivers/rkt/handle.go +++ b/drivers/rkt/handle.go @@ -11,12 +11,12 @@ import ( hclog "github.com/hashicorp/go-hclog" plugin "github.com/hashicorp/go-plugin" "github.com/hashicorp/nomad/client/taskenv" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/drivers" ) type taskHandle struct { - exec structs.Executor + exec executor.Executor env *taskenv.TaskEnv uuid string pid int diff --git a/drivers/shared/executor/executor.go b/drivers/shared/executor/executor.go index cb34ce3bd..b1d898103 100644 --- a/drivers/shared/executor/executor.go +++ b/drivers/shared/executor/executor.go @@ -3,6 +3,8 @@ package executor import ( "context" "fmt" + "io" + "io/ioutil" "os" "os/exec" "path/filepath" @@ -16,8 +18,8 @@ import ( multierror "github.com/hashicorp/go-multierror" "github.com/hashicorp/nomad/client/allocdir" + "github.com/hashicorp/nomad/client/lib/fifo" "github.com/hashicorp/nomad/client/stats" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" shelpers "github.com/hashicorp/nomad/helper/stats" "github.com/hashicorp/consul-template/signals" @@ -39,14 +41,178 @@ var ( ExecutorBasicMeasuredCpuStats = []string{"System Mode", "User Mode", "Percent"} ) +// Executor is the interface which allows a driver to launch and supervise +// a process +type Executor interface { + // Launch a user process configured by the given ExecCommand + Launch(launchCmd *ExecCommand) (*ProcessState, error) + + // Wait blocks until the process exits or an error occures + Wait(ctx context.Context) (*ProcessState, error) + + // Shutdown will shutdown the executor by stopping the user process, + // cleaning up and resources created by the executor. The shutdown sequence + // will first send the given signal to the process. This defaults to "SIGINT" + // if not specified. The executor will then wait for the process to exit + // before cleaning up other resources. If the executor waits longer than the + // given grace period, the process is forcefully killed. + // + // To force kill the user process, gracePeriod can be set to 0. + Shutdown(signal string, gracePeriod time.Duration) error + + // UpdateResources updates any resource isolation enforcement with new + // constraints if supported. + UpdateResources(*Resources) error + + // Version returns the executor API version + Version() (*ExecutorVersion, error) + + // Stats fetchs process usage stats for the executor and each pid if available + Stats() (*cstructs.TaskResourceUsage, error) + + // Signal sends the given signal to the user process + Signal(os.Signal) error + + // Exec executes the given command and args inside the executor context + // and returns the output and exit code. + Exec(deadline time.Time, cmd string, args []string) ([]byte, int, error) +} + +// Resources describes the resource isolation required +type Resources struct { + CPU int + MemoryMB int + DiskMB int + IOPS int +} + +// ExecCommand holds the user command, args, and other isolation related +// settings. +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 + + // Resources defined by the task + Resources *Resources + + // StdoutPath is the path the process stdout should be written to + StdoutPath string + stdout io.WriteCloser + + // StderrPath is the path the process stderr should be written to + StderrPath string + stderr io.WriteCloser + + // Env is the list of KEY=val pairs of environment variables to be set + Env []string + + // User is the user which the executor uses to run the command. + User string + + // TaskDir is the directory path on the host where for the task + TaskDir string + + // ResourceLimits determines whether resource limits are enforced by the + // executor. + ResourceLimits bool + + // Cgroup marks whether we put the process in a cgroup. Setting this field + // doesn't enforce resource limits. To enforce limits, set ResourceLimits. + // Using the cgroup does allow more precise cleanup of processes. + BasicProcessCgroup bool +} + +// SetWriters sets the writer for the process stdout and stderr. This should +// not be used if writing to a file path such as a fifo file. SetStdoutWriter +// is mainly used for unit testing purposes. +func (c *ExecCommand) SetWriters(out io.WriteCloser, err io.WriteCloser) { + c.stdout = out + c.stderr = err +} + +// GetWriters returns the unexported io.WriteCloser for the stdout and stderr +// handles. This is mainly used for unit testing purposes. +func (c *ExecCommand) GetWriters() (stdout io.WriteCloser, stderr io.WriteCloser) { + return c.stdout, c.stderr +} + +type nopCloser struct { + io.Writer +} + +func (nopCloser) Close() error { return nil } + +// Stdout returns a writer for the configured file descriptor +func (c *ExecCommand) Stdout() (io.WriteCloser, error) { + if c.stdout == nil { + if c.StdoutPath != "" { + f, err := fifo.Open(c.StdoutPath) + if err != nil { + return nil, fmt.Errorf("failed to create stdout: %v", err) + } + c.stdout = f + } else { + c.stdout = nopCloser{ioutil.Discard} + } + } + return c.stdout, nil +} + +// Stderr returns a writer for the configured file descriptor +func (c *ExecCommand) Stderr() (io.WriteCloser, error) { + if c.stderr == nil { + if c.StderrPath != "" { + f, err := fifo.Open(c.StderrPath) + if err != nil { + return nil, fmt.Errorf("failed to create stderr: %v", err) + } + c.stderr = f + } else { + c.stderr = nopCloser{ioutil.Discard} + } + } + return c.stderr, nil +} + +func (c *ExecCommand) Close() { + stdout, err := c.Stdout() + if err == nil { + stdout.Close() + } + stderr, err := c.Stderr() + if err == nil { + stderr.Close() + } +} + +// ProcessState holds information about the state of a user process. +type ProcessState struct { + Pid int + ExitCode int + Signal int + Time time.Time +} + +// ExecutorVersion is the version of the executor +type ExecutorVersion struct { + Version string +} + +func (v *ExecutorVersion) GoString() string { + return v.Version +} + // UniversalExecutor is an implementation of the Executor which launches and // supervises processes. In addition to process supervision it provides resource // and file system isolation type UniversalExecutor struct { childCmd exec.Cmd - commandCfg *structs.ExecCommand + commandCfg *ExecCommand - exitState *structs.ProcessState + exitState *ProcessState processExited chan interface{} // resConCtx is used to track and cleanup additional resources created by @@ -62,7 +228,7 @@ type UniversalExecutor struct { } // NewExecutor returns an Executor -func NewExecutor(logger hclog.Logger) structs.Executor { +func NewExecutor(logger hclog.Logger) Executor { logger = logger.Named("executor") if err := shelpers.Init(); err != nil { logger.Error("unable to initialize stats", "error", err) @@ -78,13 +244,13 @@ func NewExecutor(logger hclog.Logger) structs.Executor { } // Version returns the api version of the executor -func (e *UniversalExecutor) Version() (*structs.ExecutorVersion, error) { - return &structs.ExecutorVersion{Version: ExecutorVersionLatest}, nil +func (e *UniversalExecutor) Version() (*ExecutorVersion, error) { + return &ExecutorVersion{Version: ExecutorVersionLatest}, nil } // Launch launches the main process and returns its state. It also // configures an applies isolation on certain platforms. -func (e *UniversalExecutor) Launch(command *structs.ExecCommand) (*structs.ProcessState, error) { +func (e *UniversalExecutor) Launch(command *ExecCommand) (*ProcessState, error) { e.logger.Info("launching command", "command", command.Cmd, "args", strings.Join(command.Args, " ")) e.commandCfg = command @@ -146,7 +312,7 @@ func (e *UniversalExecutor) Launch(command *structs.ExecCommand) (*structs.Proce go e.pidCollector.collectPids(e.processExited, getAllPids) go e.wait() - return &structs.ProcessState{Pid: e.childCmd.Process.Pid, ExitCode: -1, Time: time.Now()}, nil + return &ProcessState{Pid: e.childCmd.Process.Pid, ExitCode: -1, Time: time.Now()}, nil } // Exec a command inside a container for exec and java drivers. @@ -194,7 +360,7 @@ func ExecScript(ctx context.Context, dir string, env []string, attrs *syscall.Sy } // Wait waits until a process has exited and returns it's exitcode and errors -func (e *UniversalExecutor) Wait(ctx context.Context) (*structs.ProcessState, error) { +func (e *UniversalExecutor) Wait(ctx context.Context) (*ProcessState, error) { select { case <-ctx.Done(): return nil, ctx.Err() @@ -203,7 +369,7 @@ func (e *UniversalExecutor) Wait(ctx context.Context) (*structs.ProcessState, er } } -func (e *UniversalExecutor) UpdateResources(resources *structs.Resources) error { +func (e *UniversalExecutor) UpdateResources(resources *Resources) error { return nil } @@ -212,7 +378,7 @@ func (e *UniversalExecutor) wait() { pid := e.childCmd.Process.Pid err := e.childCmd.Wait() if err == nil { - e.exitState = &structs.ProcessState{Pid: pid, ExitCode: 0, Time: time.Now()} + e.exitState = &ProcessState{Pid: pid, ExitCode: 0, Time: time.Now()} return } @@ -240,7 +406,7 @@ func (e *UniversalExecutor) wait() { e.logger.Warn("unexpected Cmd.Wait() error type", "error", err) } - e.exitState = &structs.ProcessState{Pid: pid, ExitCode: exitCode, Signal: signal, Time: time.Now()} + e.exitState = &ProcessState{Pid: pid, ExitCode: exitCode, Signal: signal, Time: time.Now()} } var ( diff --git a/drivers/shared/executor/executor_linux.go b/drivers/shared/executor/executor_linux.go index f5182d0c9..dc361f3a3 100644 --- a/drivers/shared/executor/executor_linux.go +++ b/drivers/shared/executor/executor_linux.go @@ -19,7 +19,6 @@ import ( multierror "github.com/hashicorp/go-multierror" "github.com/hashicorp/nomad/client/stats" cstructs "github.com/hashicorp/nomad/client/structs" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" "github.com/hashicorp/nomad/helper/discover" shelpers "github.com/hashicorp/nomad/helper/stats" "github.com/hashicorp/nomad/helper/uuid" @@ -62,7 +61,7 @@ func init() { // LibcontainerExecutor implements an Executor with the runc/libcontainer api type LibcontainerExecutor struct { id string - command *structs.ExecCommand + command *ExecCommand logger hclog.Logger @@ -74,10 +73,10 @@ type LibcontainerExecutor struct { container libcontainer.Container userProc *libcontainer.Process userProcExited chan interface{} - exitState *structs.ProcessState + exitState *ProcessState } -func NewExecutorWithIsolation(logger hclog.Logger) structs.Executor { +func NewExecutorWithIsolation(logger hclog.Logger) Executor { logger = logger.Named("isolated_executor") if err := shelpers.Init(); err != nil { logger.Error("unable to initialize stats", "error", err) @@ -93,7 +92,7 @@ func NewExecutorWithIsolation(logger hclog.Logger) structs.Executor { } // Launch creates a new container in libcontainer and starts a new process with it -func (l *LibcontainerExecutor) Launch(command *structs.ExecCommand) (*structs.ProcessState, error) { +func (l *LibcontainerExecutor) Launch(command *ExecCommand) (*ProcessState, error) { l.logger.Info("launching command", "command", command.Cmd, "args", strings.Join(command.Args, " ")) // Find the nomad executable to launch the executor process with bin, err := discover.NomadExecutable() @@ -102,7 +101,7 @@ func (l *LibcontainerExecutor) Launch(command *structs.ExecCommand) (*structs.Pr } if command.Resources == nil { - command.Resources = &structs.Resources{} + command.Resources = &Resources{} } l.command = command @@ -207,7 +206,7 @@ func (l *LibcontainerExecutor) Launch(command *structs.ExecCommand) (*structs.Pr go l.pidCollector.collectPids(l.userProcExited, l.getAllPids) go l.wait() - return &structs.ProcessState{ + return &ProcessState{ Pid: pid, ExitCode: -1, Time: time.Now(), @@ -232,7 +231,7 @@ func (l *LibcontainerExecutor) getAllPids() (map[int]*nomadPid, error) { } // Wait waits until a process has exited and returns it's exitcode and errors -func (l *LibcontainerExecutor) Wait(ctx context.Context) (*structs.ProcessState, error) { +func (l *LibcontainerExecutor) Wait(ctx context.Context) (*ProcessState, error) { select { case <-ctx.Done(): return nil, ctx.Err() @@ -252,7 +251,7 @@ func (l *LibcontainerExecutor) wait() { ps = exitErr.ProcessState } else { l.logger.Error("failed to call wait on user process", "error", err) - l.exitState = &structs.ProcessState{Pid: 0, ExitCode: 0, Time: time.Now()} + l.exitState = &ProcessState{Pid: 0, ExitCode: 0, Time: time.Now()} return } } @@ -270,7 +269,7 @@ func (l *LibcontainerExecutor) wait() { } } - l.exitState = &structs.ProcessState{ + l.exitState = &ProcessState{ Pid: ps.Pid(), ExitCode: exitCode, Signal: signal, @@ -332,13 +331,13 @@ func (l *LibcontainerExecutor) Shutdown(signal string, grace time.Duration) erro } // UpdateResources updates the resource isolation with new values to be enforced -func (l *LibcontainerExecutor) UpdateResources(resources *structs.Resources) error { +func (l *LibcontainerExecutor) UpdateResources(resources *Resources) error { return nil } // Version returns the api version of the executor -func (l *LibcontainerExecutor) Version() (*structs.ExecutorVersion, error) { - return &structs.ExecutorVersion{Version: ExecutorVersionLatest}, nil +func (l *LibcontainerExecutor) Version() (*ExecutorVersion, error) { + return &ExecutorVersion{Version: ExecutorVersionLatest}, nil } // Stats returns the resource statistics for processes managed by the executor @@ -458,7 +457,7 @@ func (l *LibcontainerExecutor) handleExecWait(ch chan *waitResult, process *libc ch <- &waitResult{ps, err} } -func configureCapabilities(cfg *lconfigs.Config, command *structs.ExecCommand) { +func configureCapabilities(cfg *lconfigs.Config, command *ExecCommand) { // TODO: allow better control of these cfg.Capabilities = &lconfigs.Capabilities{ Bounding: allCaps, @@ -470,7 +469,7 @@ func configureCapabilities(cfg *lconfigs.Config, command *structs.ExecCommand) { } -func configureIsolation(cfg *lconfigs.Config, command *structs.ExecCommand) { +func configureIsolation(cfg *lconfigs.Config, command *ExecCommand) { defaultMountFlags := syscall.MS_NOEXEC | syscall.MS_NOSUID | syscall.MS_NODEV // set the new root directory for the container @@ -536,7 +535,7 @@ func configureIsolation(cfg *lconfigs.Config, command *structs.ExecCommand) { } } -func configureCgroups(cfg *lconfigs.Config, command *structs.ExecCommand) error { +func configureCgroups(cfg *lconfigs.Config, command *ExecCommand) error { // If resources are not limited then manually create cgroups needed if !command.ResourceLimits { @@ -602,7 +601,7 @@ func configureBasicCgroups(cfg *lconfigs.Config) error { return nil } -func newLibcontainerConfig(command *structs.ExecCommand) *lconfigs.Config { +func newLibcontainerConfig(command *ExecCommand) *lconfigs.Config { cfg := &lconfigs.Config{ Cgroups: &lconfigs.Cgroup{ Resources: &lconfigs.Resources{ diff --git a/drivers/shared/executor/executor_linux_test.go b/drivers/shared/executor/executor_linux_test.go index 3298fdca3..e11e9d5df 100644 --- a/drivers/shared/executor/executor_linux_test.go +++ b/drivers/shared/executor/executor_linux_test.go @@ -16,7 +16,6 @@ import ( cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/client/taskenv" "github.com/hashicorp/nomad/client/testutil" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" "github.com/hashicorp/nomad/helper/testlog" "github.com/hashicorp/nomad/nomad/mock" tu "github.com/hashicorp/nomad/testutil" @@ -27,7 +26,7 @@ func init() { executorFactories["LibcontainerExecutor"] = libcontainerFactory } -func libcontainerFactory(l hclog.Logger) structs.Executor { +func libcontainerFactory(l hclog.Logger) Executor { return NewExecutorWithIsolation(l) } @@ -35,7 +34,7 @@ func libcontainerFactory(l hclog.Logger) structs.Executor { // chroot. Use testExecutorContext if you don't need a chroot. // // The caller is responsible for calling AllocDir.Destroy() to cleanup. -func testExecutorCommandWithChroot(t *testing.T) (*structs.ExecCommand, *allocdir.AllocDir) { +func testExecutorCommandWithChroot(t *testing.T) (*ExecCommand, *allocdir.AllocDir) { chrootEnv := map[string]string{ "/etc/ld.so.cache": "/etc/ld.so.cache", "/etc/ld.so.conf": "/etc/ld.so.conf", @@ -63,10 +62,10 @@ func testExecutorCommandWithChroot(t *testing.T) (*structs.ExecCommand, *allocdi t.Fatalf("allocDir.NewTaskDir(%q) failed: %v", task.Name, err) } td := allocDir.TaskDirs[task.Name] - cmd := &structs.ExecCommand{ + cmd := &ExecCommand{ Env: taskEnv.List(), TaskDir: td.Dir, - Resources: &structs.Resources{ + Resources: &Resources{ CPU: task.Resources.CPU, MemoryMB: task.Resources.MemoryMB, IOPS: task.Resources.IOPS, diff --git a/drivers/shared/executor/executor_test.go b/drivers/shared/executor/executor_test.go index aa4711ac9..26067ebc8 100644 --- a/drivers/shared/executor/executor_test.go +++ b/drivers/shared/executor/executor_test.go @@ -12,7 +12,6 @@ import ( "testing" "time" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" tu "github.com/hashicorp/nomad/testutil" hclog "github.com/hashicorp/go-hclog" @@ -24,8 +23,8 @@ import ( "github.com/stretchr/testify/require" ) -var executorFactories = map[string]func(hclog.Logger) structs.Executor{} -var universalFactory = func(l hclog.Logger) structs.Executor { +var executorFactories = map[string]func(hclog.Logger) Executor{} +var universalFactory = func(l hclog.Logger) Executor { return NewExecutor(l) } @@ -36,7 +35,7 @@ func init() { // testExecutorContext returns an ExecutorContext and AllocDir. // // The caller is responsible for calling AllocDir.Destroy() to cleanup. -func testExecutorCommand(t *testing.T) (*structs.ExecCommand, *allocdir.AllocDir) { +func testExecutorCommand(t *testing.T) (*ExecCommand, *allocdir.AllocDir) { alloc := mock.Alloc() task := alloc.Job.TaskGroups[0].Tasks[0] taskEnv := taskenv.NewBuilder(mock.Node(), alloc, task, "global").Build() @@ -50,10 +49,10 @@ func testExecutorCommand(t *testing.T) (*structs.ExecCommand, *allocdir.AllocDir t.Fatalf("allocDir.NewTaskDir(%q) failed: %v", task.Name, err) } td := allocDir.TaskDirs[task.Name] - cmd := &structs.ExecCommand{ + cmd := &ExecCommand{ Env: taskEnv.List(), TaskDir: td.Dir, - Resources: &structs.Resources{ + Resources: &Resources{ CPU: task.Resources.CPU, MemoryMB: task.Resources.MemoryMB, IOPS: task.Resources.IOPS, @@ -70,7 +69,7 @@ type bufferCloser struct { func (_ *bufferCloser) Close() error { return nil } -func configureTLogging(cmd *structs.ExecCommand) (stdout bufferCloser, stderr bufferCloser) { +func configureTLogging(cmd *ExecCommand) (stdout bufferCloser, stderr bufferCloser) { cmd.SetWriters(&stdout, &stderr) return } diff --git a/drivers/shared/executor/structs/structs.go b/drivers/shared/executor/structs/structs.go deleted file mode 100644 index 56495f7ab..000000000 --- a/drivers/shared/executor/structs/structs.go +++ /dev/null @@ -1,177 +0,0 @@ -package structs - -import ( - "context" - "fmt" - "io" - "io/ioutil" - "os" - "time" - - "github.com/hashicorp/nomad/client/lib/fifo" - cstructs "github.com/hashicorp/nomad/client/structs" -) - -// Executor is the interface which allows a driver to launch and supervise -// a process -type Executor interface { - // Launch a user process configured by the given ExecCommand - Launch(launchCmd *ExecCommand) (*ProcessState, error) - - // Wait blocks until the process exits or an error occures - Wait(ctx context.Context) (*ProcessState, error) - - // Shutdown will shutdown the executor by stopping the user process, - // cleaning up and resources created by the executor. The shutdown sequence - // will first send the given signal to the process. This defaults to "SIGINT" - // if not specified. The executor will then wait for the process to exit - // before cleaning up other resources. If the executor waits longer than the - // given grace period, the process is forcefully killed. - // - // To force kill the user process, gracePeriod can be set to 0. - Shutdown(signal string, gracePeriod time.Duration) error - - // UpdateResources updates any resource isolation enforcement with new - // constraints if supported. - UpdateResources(*Resources) error - - // Version returns the executor API version - Version() (*ExecutorVersion, error) - - // Stats fetchs process usage stats for the executor and each pid if available - Stats() (*cstructs.TaskResourceUsage, error) - - // Signal sends the given signal to the user process - Signal(os.Signal) error - - // Exec executes the given command and args inside the executor context - // and returns the output and exit code. - Exec(deadline time.Time, cmd string, args []string) ([]byte, int, error) -} - -// Resources describes the resource isolation required -type Resources struct { - CPU int - MemoryMB int - DiskMB int - IOPS int -} - -// ExecCommand holds the user command, args, and other isolation related -// settings. -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 - - // Resources defined by the task - Resources *Resources - - // StdoutPath is the path the process stdout should be written to - StdoutPath string - stdout io.WriteCloser - - // StderrPath is the path the process stderr should be written to - StderrPath string - stderr io.WriteCloser - - // Env is the list of KEY=val pairs of environment variables to be set - Env []string - - // User is the user which the executor uses to run the command. - User string - - // TaskDir is the directory path on the host where for the task - TaskDir string - - // ResourceLimits determines whether resource limits are enforced by the - // executor. - ResourceLimits bool - - // Cgroup marks whether we put the process in a cgroup. Setting this field - // doesn't enforce resource limits. To enforce limits, set ResourceLimits. - // Using the cgroup does allow more precise cleanup of processes. - BasicProcessCgroup bool -} - -// SetWriters sets the writer for the process stdout and stderr. This should -// not be used if writing to a file path such as a fifo file. SetStdoutWriter -// is mainly used for unit testing purposes. -func (c *ExecCommand) SetWriters(out io.WriteCloser, err io.WriteCloser) { - c.stdout = out - c.stderr = err -} - -// GetWriters returns the unexported io.WriteCloser for the stdout and stderr -// handles. This is mainly used for unit testing purposes. -func (c *ExecCommand) GetWriters() (stdout io.WriteCloser, stderr io.WriteCloser) { - return c.stdout, c.stderr -} - -type nopCloser struct { - io.Writer -} - -func (nopCloser) Close() error { return nil } - -// Stdout returns a writer for the configured file descriptor -func (c *ExecCommand) Stdout() (io.WriteCloser, error) { - if c.stdout == nil { - if c.StdoutPath != "" { - f, err := fifo.Open(c.StdoutPath) - if err != nil { - return nil, fmt.Errorf("failed to create stdout: %v", err) - } - c.stdout = f - } else { - c.stdout = nopCloser{ioutil.Discard} - } - } - return c.stdout, nil -} - -// Stderr returns a writer for the configured file descriptor -func (c *ExecCommand) Stderr() (io.WriteCloser, error) { - if c.stderr == nil { - if c.StderrPath != "" { - f, err := fifo.Open(c.StderrPath) - if err != nil { - return nil, fmt.Errorf("failed to create stderr: %v", err) - } - c.stderr = f - } else { - c.stderr = nopCloser{ioutil.Discard} - } - } - return c.stderr, nil -} - -func (c *ExecCommand) Close() { - stdout, err := c.Stdout() - if err == nil { - stdout.Close() - } - stderr, err := c.Stderr() - if err == nil { - stderr.Close() - } -} - -// ProcessState holds information about the state of a user process. -type ProcessState struct { - Pid int - ExitCode int - Signal int - Time time.Time -} - -// ExecutorVersion is the version of the executor -type ExecutorVersion struct { - Version string -} - -func (v *ExecutorVersion) GoString() string { - return v.Version -} diff --git a/plugins/drivers/utils/utils.go b/plugins/drivers/utils/utils.go index 1060dfce2..f36534354 100644 --- a/plugins/drivers/utils/utils.go +++ b/plugins/drivers/utils/utils.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/nomad/client/config" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/client/taskenv" - estructs "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/helper/discover" "github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/nomad/plugins/base" @@ -64,7 +64,7 @@ func CgroupsMounted(node *structs.Node) bool { // CreateExecutor launches an executor plugin and returns an instance of the // Executor interface func CreateExecutor(w io.Writer, level hclog.Level, driverConfig *base.ClientDriverConfig, - executorConfig *pexecutor.ExecutorConfig) (estructs.Executor, *plugin.Client, error) { + executorConfig *pexecutor.ExecutorConfig) (executor.Executor, *plugin.Client, error) { c, err := json.Marshal(executorConfig) if err != nil { @@ -106,12 +106,12 @@ func CreateExecutor(w io.Writer, level hclog.Level, driverConfig *base.ClientDri if err != nil { return nil, nil, fmt.Errorf("unable to dispense the executor plugin: %v", err) } - executorPlugin := raw.(estructs.Executor) + executorPlugin := raw.(executor.Executor) return executorPlugin, executorClient, nil } // CreateExecutorWithConfig launches a plugin with a given plugin config -func CreateExecutorWithConfig(config *plugin.ClientConfig, w io.Writer) (estructs.Executor, *plugin.Client, error) { +func CreateExecutorWithConfig(config *plugin.ClientConfig, w io.Writer) (executor.Executor, *plugin.Client, error) { config.HandshakeConfig = base.Handshake // Setting this to DEBUG since the log level at the executor server process @@ -131,7 +131,7 @@ func CreateExecutorWithConfig(config *plugin.ClientConfig, w io.Writer) (estruct if err != nil { return nil, nil, fmt.Errorf("unable to dispense the executor plugin: %v", err) } - executorPlugin, ok := raw.(estructs.Executor) + executorPlugin, ok := raw.(executor.Executor) if !ok { return nil, nil, fmt.Errorf("unexpected executor rpc type: %T", raw) } diff --git a/plugins/executor/client.go b/plugins/executor/client.go index 08b429d95..089966c43 100644 --- a/plugins/executor/client.go +++ b/plugins/executor/client.go @@ -8,12 +8,12 @@ import ( "github.com/LK4D4/joincontext" "github.com/golang/protobuf/ptypes" cstructs "github.com/hashicorp/nomad/client/structs" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/executor/proto" ) -var _ structs.Executor = (*grpcExecutorClient)(nil) +var _ executor.Executor = (*grpcExecutorClient)(nil) type grpcExecutorClient struct { client proto.ExecutorClient @@ -22,7 +22,7 @@ type grpcExecutorClient struct { doneCtx context.Context } -func (c *grpcExecutorClient) Launch(cmd *structs.ExecCommand) (*structs.ProcessState, error) { +func (c *grpcExecutorClient) Launch(cmd *executor.ExecCommand) (*executor.ProcessState, error) { ctx := context.Background() req := &proto.LaunchRequest{ Cmd: cmd.Cmd, @@ -48,7 +48,7 @@ func (c *grpcExecutorClient) Launch(cmd *structs.ExecCommand) (*structs.ProcessS return ps, nil } -func (c *grpcExecutorClient) Wait(ctx context.Context) (*structs.ProcessState, error) { +func (c *grpcExecutorClient) Wait(ctx context.Context) (*executor.ProcessState, error) { // Join the passed context and the shutdown context ctx, _ = joincontext.Join(ctx, c.doneCtx) @@ -78,7 +78,7 @@ func (c *grpcExecutorClient) Shutdown(signal string, gracePeriod time.Duration) return nil } -func (c *grpcExecutorClient) UpdateResources(r *structs.Resources) error { +func (c *grpcExecutorClient) UpdateResources(r *executor.Resources) error { ctx := context.Background() req := &proto.UpdateResourcesRequest{Resources: resourcesToProto(r)} if _, err := c.client.UpdateResources(ctx, req); err != nil { @@ -88,13 +88,13 @@ func (c *grpcExecutorClient) UpdateResources(r *structs.Resources) error { return nil } -func (c *grpcExecutorClient) Version() (*structs.ExecutorVersion, error) { +func (c *grpcExecutorClient) Version() (*executor.ExecutorVersion, error) { ctx := context.Background() resp, err := c.client.Version(ctx, &proto.VersionRequest{}) if err != nil { return nil, err } - return &structs.ExecutorVersion{Version: resp.Version}, nil + return &executor.ExecutorVersion{Version: resp.Version}, nil } func (c *grpcExecutorClient) Stats() (*cstructs.TaskResourceUsage, error) { diff --git a/plugins/executor/server.go b/plugins/executor/server.go index d3146dd70..f6b3a0b24 100644 --- a/plugins/executor/server.go +++ b/plugins/executor/server.go @@ -6,19 +6,19 @@ import ( "github.com/golang/protobuf/ptypes" "github.com/hashicorp/consul-template/signals" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/executor/proto" "golang.org/x/net/context" ) type grpcExecutorServer struct { - impl structs.Executor + impl executor.Executor doneCtx context.Context } func (s *grpcExecutorServer) Launch(ctx context.Context, req *proto.LaunchRequest) (*proto.LaunchResponse, error) { - ps, err := s.impl.Launch(&structs.ExecCommand{ + ps, err := s.impl.Launch(&executor.ExecCommand{ Cmd: req.Cmd, Args: req.Args, Resources: resourcesFromProto(req.Resources), diff --git a/plugins/executor/utils.go b/plugins/executor/utils.go index e511c42a1..222e95727 100644 --- a/plugins/executor/utils.go +++ b/plugins/executor/utils.go @@ -2,11 +2,11 @@ package executor import ( "github.com/golang/protobuf/ptypes" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" + "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/executor/proto" ) -func processStateToProto(ps *structs.ProcessState) (*proto.ProcessState, error) { +func processStateToProto(ps *executor.ProcessState) (*proto.ProcessState, error) { timestamp, err := ptypes.TimestampProto(ps.Time) if err != nil { return nil, err @@ -21,13 +21,13 @@ func processStateToProto(ps *structs.ProcessState) (*proto.ProcessState, error) return pb, nil } -func processStateFromProto(pb *proto.ProcessState) (*structs.ProcessState, error) { +func processStateFromProto(pb *proto.ProcessState) (*executor.ProcessState, error) { timestamp, err := ptypes.Timestamp(pb.Time) if err != nil { return nil, err } - return &structs.ProcessState{ + return &executor.ProcessState{ Pid: int(pb.Pid), ExitCode: int(pb.ExitCode), Signal: int(pb.Signal), @@ -35,7 +35,7 @@ func processStateFromProto(pb *proto.ProcessState) (*structs.ProcessState, error }, nil } -func resourcesToProto(r *structs.Resources) *proto.Resources { +func resourcesToProto(r *executor.Resources) *proto.Resources { if r == nil { return &proto.Resources{} } @@ -48,12 +48,12 @@ func resourcesToProto(r *structs.Resources) *proto.Resources { } } -func resourcesFromProto(pb *proto.Resources) *structs.Resources { +func resourcesFromProto(pb *proto.Resources) *executor.Resources { if pb == nil { - return &structs.Resources{} + return &executor.Resources{} } - return &structs.Resources{ + return &executor.Resources{ CPU: int(pb.Cpu), MemoryMB: int(pb.MemoryMB), DiskMB: int(pb.DiskMB), From 13b582fcfb717fa201fcf592de3482fe63b4019b Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Thu, 6 Dec 2018 21:13:45 -0500 Subject: [PATCH 05/13] executor: merge plugin shim with executor package --- command/executor_plugin.go | 2 +- drivers/exec/driver.go | 7 +- drivers/java/driver.go | 8 +- drivers/qemu/driver.go | 8 +- drivers/rawexec/driver.go | 8 +- drivers/rkt/driver.go | 8 +- .../shared}/executor/client.go | 15 +- .../shared}/executor/executor_plugin.go | 7 +- .../executor/executor_plugin_pre_0_9_0.go | 0 .../shared}/executor/plugins.go | 0 .../shared}/executor/proto/executor.pb.go | 0 .../shared}/executor/proto/executor.proto | 0 .../shared}/executor/server.go | 7 +- drivers/shared/executor/utils.go | 157 ++++++++++++++++++ drivers/shared/executor/utils_unix.go | 18 ++ drivers/shared/executor/utils_windows.go | 6 + plugins/drivers/utils/utils.go | 107 ------------ plugins/drivers/utils/utils_unix.go | 13 -- plugins/drivers/utils/utils_windows.go | 7 - plugins/executor/utils.go | 62 ------- 20 files changed, 210 insertions(+), 230 deletions(-) rename {plugins => drivers/shared}/executor/client.go (83%) rename {plugins => drivers/shared}/executor/executor_plugin.go (68%) rename {plugins => drivers/shared}/executor/executor_plugin_pre_0_9_0.go (100%) rename {plugins => drivers/shared}/executor/plugins.go (100%) rename {plugins => drivers/shared}/executor/proto/executor.pb.go (100%) rename {plugins => drivers/shared}/executor/proto/executor.proto (100%) rename {plugins => drivers/shared}/executor/server.go (94%) create mode 100644 drivers/shared/executor/utils.go create mode 100644 drivers/shared/executor/utils_unix.go create mode 100644 drivers/shared/executor/utils_windows.go delete mode 100644 plugins/executor/utils.go diff --git a/command/executor_plugin.go b/command/executor_plugin.go index 666d1fb47..da75450e0 100644 --- a/command/executor_plugin.go +++ b/command/executor_plugin.go @@ -8,8 +8,8 @@ import ( hclog "github.com/hashicorp/go-hclog" "github.com/hashicorp/go-plugin" + "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/base" - "github.com/hashicorp/nomad/plugins/executor" ) type ExecutorPluginCommand struct { diff --git a/drivers/exec/driver.go b/drivers/exec/driver.go index 9353bb695..da9174829 100644 --- a/drivers/exec/driver.go +++ b/drivers/exec/driver.go @@ -18,7 +18,6 @@ import ( "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/nomad/plugins/drivers/utils" - pexecutor "github.com/hashicorp/nomad/plugins/executor" "github.com/hashicorp/nomad/plugins/shared" "github.com/hashicorp/nomad/plugins/shared/hclspec" "github.com/hashicorp/nomad/plugins/shared/loader" @@ -249,7 +248,7 @@ func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error { Reattach: plugRC, } - exec, pluginClient, err := utils.CreateExecutorWithConfig(pluginConfig, os.Stderr) + exec, pluginClient, err := executor.CreateExecutorWithConfig(pluginConfig, os.Stderr) if err != nil { d.logger.Error("failed to reattach to executor", "error", err, "task_id", handle.Config.ID) return fmt.Errorf("failed to reattach to executor: %v", err) @@ -286,14 +285,14 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru handle.Config = cfg pluginLogFile := filepath.Join(cfg.TaskDir().Dir, "executor.out") - executorConfig := &pexecutor.ExecutorConfig{ + executorConfig := &executor.ExecutorConfig{ LogFile: pluginLogFile, LogLevel: "debug", FSIsolation: true, } // TODO: best way to pass port ranges in from client config - exec, pluginClient, err := utils.CreateExecutor(os.Stderr, hclog.Debug, d.nomadConfig, executorConfig) + exec, pluginClient, err := executor.CreateExecutor(os.Stderr, hclog.Debug, d.nomadConfig, executorConfig) if err != nil { return nil, nil, fmt.Errorf("failed to create executor: %v", err) } diff --git a/drivers/java/driver.go b/drivers/java/driver.go index 9fbf442c8..18250bad5 100644 --- a/drivers/java/driver.go +++ b/drivers/java/driver.go @@ -19,8 +19,6 @@ import ( "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" - "github.com/hashicorp/nomad/plugins/drivers/utils" - pexecutor "github.com/hashicorp/nomad/plugins/executor" "github.com/hashicorp/nomad/plugins/shared" "github.com/hashicorp/nomad/plugins/shared/hclspec" "github.com/hashicorp/nomad/plugins/shared/loader" @@ -271,7 +269,7 @@ func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error { Reattach: plugRC, } - execImpl, pluginClient, err := utils.CreateExecutorWithConfig(pluginConfig, os.Stderr) + execImpl, pluginClient, err := executor.CreateExecutorWithConfig(pluginConfig, os.Stderr) if err != nil { d.logger.Error("failed to reattach to executor", "error", err, "task_id", handle.Config.ID) return fmt.Errorf("failed to reattach to executor: %v", err) @@ -320,12 +318,12 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru handle.Config = cfg pluginLogFile := filepath.Join(cfg.TaskDir().Dir, "executor.out") - executorConfig := &pexecutor.ExecutorConfig{ + executorConfig := &executor.ExecutorConfig{ LogFile: pluginLogFile, LogLevel: "debug", } - exec, pluginClient, err := utils.CreateExecutor(os.Stderr, hclog.Debug, d.nomadConfig, executorConfig) + exec, pluginClient, err := executor.CreateExecutor(os.Stderr, hclog.Debug, d.nomadConfig, executorConfig) if err != nil { return nil, nil, fmt.Errorf("failed to create executor: %v", err) } diff --git a/drivers/qemu/driver.go b/drivers/qemu/driver.go index 9c498b9ce..8b07ce298 100644 --- a/drivers/qemu/driver.go +++ b/drivers/qemu/driver.go @@ -21,8 +21,6 @@ import ( "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" - "github.com/hashicorp/nomad/plugins/drivers/utils" - pexecutor "github.com/hashicorp/nomad/plugins/executor" "github.com/hashicorp/nomad/plugins/shared" "github.com/hashicorp/nomad/plugins/shared/hclspec" "github.com/hashicorp/nomad/plugins/shared/loader" @@ -270,7 +268,7 @@ func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error { Reattach: plugRC, } - execImpl, pluginClient, err := utils.CreateExecutorWithConfig(pluginConfig, os.Stderr) + execImpl, pluginClient, err := executor.CreateExecutorWithConfig(pluginConfig, os.Stderr) if err != nil { d.logger.Error("failed to reattach to executor", "error", err, "task_id", handle.Config.ID) return fmt.Errorf("failed to reattach to executor: %v", err) @@ -414,12 +412,12 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru d.logger.Debug("starting QemuVM command ", "args", strings.Join(args, " ")) pluginLogFile := filepath.Join(cfg.TaskDir().Dir, fmt.Sprintf("%s-executor.out", cfg.Name)) - executorConfig := &pexecutor.ExecutorConfig{ + executorConfig := &executor.ExecutorConfig{ LogFile: pluginLogFile, LogLevel: "debug", } - execImpl, pluginClient, err := utils.CreateExecutor(os.Stderr, hclog.Debug, d.nomadConfig, executorConfig) + execImpl, pluginClient, err := executor.CreateExecutor(os.Stderr, hclog.Debug, d.nomadConfig, executorConfig) if err != nil { return nil, nil, err } diff --git a/drivers/rawexec/driver.go b/drivers/rawexec/driver.go index c5adb62dd..34bffe1d3 100644 --- a/drivers/rawexec/driver.go +++ b/drivers/rawexec/driver.go @@ -18,8 +18,6 @@ import ( "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" - "github.com/hashicorp/nomad/plugins/drivers/utils" - pexecutor "github.com/hashicorp/nomad/plugins/executor" "github.com/hashicorp/nomad/plugins/shared" "github.com/hashicorp/nomad/plugins/shared/hclspec" "github.com/hashicorp/nomad/plugins/shared/loader" @@ -276,7 +274,7 @@ func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error { } // Create client for reattached executor - exec, pluginClient, err := utils.CreateExecutorWithConfig(pluginConfig, os.Stderr) + exec, pluginClient, err := executor.CreateExecutorWithConfig(pluginConfig, os.Stderr) if err != nil { d.logger.Error("failed to reattach to executor", "error", err, "task_id", handle.Config.ID) return fmt.Errorf("failed to reattach to executor: %v", err) @@ -313,12 +311,12 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru handle.Config = cfg pluginLogFile := filepath.Join(cfg.TaskDir().Dir, "executor.out") - executorConfig := &pexecutor.ExecutorConfig{ + executorConfig := &executor.ExecutorConfig{ LogFile: pluginLogFile, LogLevel: "debug", } - exec, pluginClient, err := utils.CreateExecutor(os.Stderr, hclog.Debug, d.nomadConfig, executorConfig) + exec, pluginClient, err := executor.CreateExecutor(os.Stderr, hclog.Debug, d.nomadConfig, executorConfig) if err != nil { return nil, nil, fmt.Errorf("failed to create executor: %v", err) } diff --git a/drivers/rkt/driver.go b/drivers/rkt/driver.go index 99ffea850..a022db9fb 100644 --- a/drivers/rkt/driver.go +++ b/drivers/rkt/driver.go @@ -31,8 +31,6 @@ import ( "github.com/hashicorp/nomad/drivers/shared/executor" "github.com/hashicorp/nomad/plugins/base" "github.com/hashicorp/nomad/plugins/drivers" - "github.com/hashicorp/nomad/plugins/drivers/utils" - pexecutor "github.com/hashicorp/nomad/plugins/executor" "github.com/hashicorp/nomad/plugins/shared" "github.com/hashicorp/nomad/plugins/shared/hclspec" "github.com/hashicorp/nomad/plugins/shared/loader" @@ -344,7 +342,7 @@ func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error { Reattach: plugRC, } - execImpl, pluginClient, err := utils.CreateExecutorWithConfig(pluginConfig, os.Stderr) + execImpl, pluginClient, err := executor.CreateExecutorWithConfig(pluginConfig, os.Stderr) if err != nil { d.logger.Error("failed to reattach to executor", "error", err, "task_id", handle.Config.ID) return fmt.Errorf("failed to reattach to executor: %v", err) @@ -604,12 +602,12 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru } pluginLogFile := filepath.Join(cfg.TaskDir().Dir, fmt.Sprintf("%s-executor.out", cfg.Name)) - executorConfig := &pexecutor.ExecutorConfig{ + executorConfig := &executor.ExecutorConfig{ LogFile: pluginLogFile, LogLevel: "debug", } - execImpl, pluginClient, err := utils.CreateExecutor(os.Stderr, hclog.Debug, d.nomadConfig, executorConfig) + execImpl, pluginClient, err := executor.CreateExecutor(os.Stderr, hclog.Debug, d.nomadConfig, executorConfig) if err != nil { return nil, nil, err } diff --git a/plugins/executor/client.go b/drivers/shared/executor/client.go similarity index 83% rename from plugins/executor/client.go rename to drivers/shared/executor/client.go index 089966c43..2a6700b24 100644 --- a/plugins/executor/client.go +++ b/drivers/shared/executor/client.go @@ -8,12 +8,11 @@ import ( "github.com/LK4D4/joincontext" "github.com/golang/protobuf/ptypes" cstructs "github.com/hashicorp/nomad/client/structs" - "github.com/hashicorp/nomad/drivers/shared/executor" + "github.com/hashicorp/nomad/drivers/shared/executor/proto" "github.com/hashicorp/nomad/plugins/drivers" - "github.com/hashicorp/nomad/plugins/executor/proto" ) -var _ executor.Executor = (*grpcExecutorClient)(nil) +var _ Executor = (*grpcExecutorClient)(nil) type grpcExecutorClient struct { client proto.ExecutorClient @@ -22,7 +21,7 @@ type grpcExecutorClient struct { doneCtx context.Context } -func (c *grpcExecutorClient) Launch(cmd *executor.ExecCommand) (*executor.ProcessState, error) { +func (c *grpcExecutorClient) Launch(cmd *ExecCommand) (*ProcessState, error) { ctx := context.Background() req := &proto.LaunchRequest{ Cmd: cmd.Cmd, @@ -48,7 +47,7 @@ func (c *grpcExecutorClient) Launch(cmd *executor.ExecCommand) (*executor.Proces return ps, nil } -func (c *grpcExecutorClient) Wait(ctx context.Context) (*executor.ProcessState, error) { +func (c *grpcExecutorClient) Wait(ctx context.Context) (*ProcessState, error) { // Join the passed context and the shutdown context ctx, _ = joincontext.Join(ctx, c.doneCtx) @@ -78,7 +77,7 @@ func (c *grpcExecutorClient) Shutdown(signal string, gracePeriod time.Duration) return nil } -func (c *grpcExecutorClient) UpdateResources(r *executor.Resources) error { +func (c *grpcExecutorClient) UpdateResources(r *Resources) error { ctx := context.Background() req := &proto.UpdateResourcesRequest{Resources: resourcesToProto(r)} if _, err := c.client.UpdateResources(ctx, req); err != nil { @@ -88,13 +87,13 @@ func (c *grpcExecutorClient) UpdateResources(r *executor.Resources) error { return nil } -func (c *grpcExecutorClient) Version() (*executor.ExecutorVersion, error) { +func (c *grpcExecutorClient) Version() (*ExecutorVersion, error) { ctx := context.Background() resp, err := c.client.Version(ctx, &proto.VersionRequest{}) if err != nil { return nil, err } - return &executor.ExecutorVersion{Version: resp.Version}, nil + return &ExecutorVersion{Version: resp.Version}, nil } func (c *grpcExecutorClient) Stats() (*cstructs.TaskResourceUsage, error) { diff --git a/plugins/executor/executor_plugin.go b/drivers/shared/executor/executor_plugin.go similarity index 68% rename from plugins/executor/executor_plugin.go rename to drivers/shared/executor/executor_plugin.go index 905dc6a30..a7a85d5a3 100644 --- a/plugins/executor/executor_plugin.go +++ b/drivers/shared/executor/executor_plugin.go @@ -5,8 +5,7 @@ import ( hclog "github.com/hashicorp/go-hclog" "github.com/hashicorp/go-plugin" - "github.com/hashicorp/nomad/drivers/shared/executor" - "github.com/hashicorp/nomad/plugins/executor/proto" + "github.com/hashicorp/nomad/drivers/shared/executor/proto" "google.golang.org/grpc" ) @@ -19,9 +18,9 @@ type ExecutorPlugin struct { func (p *ExecutorPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error { if p.fsIsolation { - proto.RegisterExecutorServer(s, &grpcExecutorServer{impl: executor.NewExecutorWithIsolation(p.logger)}) + proto.RegisterExecutorServer(s, &grpcExecutorServer{impl: NewExecutorWithIsolation(p.logger)}) } else { - proto.RegisterExecutorServer(s, &grpcExecutorServer{impl: executor.NewExecutor(p.logger)}) + proto.RegisterExecutorServer(s, &grpcExecutorServer{impl: NewExecutor(p.logger)}) } return nil } diff --git a/plugins/executor/executor_plugin_pre_0_9_0.go b/drivers/shared/executor/executor_plugin_pre_0_9_0.go similarity index 100% rename from plugins/executor/executor_plugin_pre_0_9_0.go rename to drivers/shared/executor/executor_plugin_pre_0_9_0.go diff --git a/plugins/executor/plugins.go b/drivers/shared/executor/plugins.go similarity index 100% rename from plugins/executor/plugins.go rename to drivers/shared/executor/plugins.go diff --git a/plugins/executor/proto/executor.pb.go b/drivers/shared/executor/proto/executor.pb.go similarity index 100% rename from plugins/executor/proto/executor.pb.go rename to drivers/shared/executor/proto/executor.pb.go diff --git a/plugins/executor/proto/executor.proto b/drivers/shared/executor/proto/executor.proto similarity index 100% rename from plugins/executor/proto/executor.proto rename to drivers/shared/executor/proto/executor.proto diff --git a/plugins/executor/server.go b/drivers/shared/executor/server.go similarity index 94% rename from plugins/executor/server.go rename to drivers/shared/executor/server.go index f6b3a0b24..68c39812b 100644 --- a/plugins/executor/server.go +++ b/drivers/shared/executor/server.go @@ -6,19 +6,18 @@ import ( "github.com/golang/protobuf/ptypes" "github.com/hashicorp/consul-template/signals" - "github.com/hashicorp/nomad/drivers/shared/executor" + "github.com/hashicorp/nomad/drivers/shared/executor/proto" "github.com/hashicorp/nomad/plugins/drivers" - "github.com/hashicorp/nomad/plugins/executor/proto" "golang.org/x/net/context" ) type grpcExecutorServer struct { - impl executor.Executor + impl Executor doneCtx context.Context } func (s *grpcExecutorServer) Launch(ctx context.Context, req *proto.LaunchRequest) (*proto.LaunchResponse, error) { - ps, err := s.impl.Launch(&executor.ExecCommand{ + ps, err := s.impl.Launch(&ExecCommand{ Cmd: req.Cmd, Args: req.Args, Resources: resourcesFromProto(req.Resources), diff --git a/drivers/shared/executor/utils.go b/drivers/shared/executor/utils.go new file mode 100644 index 000000000..30f51b66d --- /dev/null +++ b/drivers/shared/executor/utils.go @@ -0,0 +1,157 @@ +package executor + +import ( + "encoding/json" + "fmt" + "io" + "os/exec" + + "github.com/golang/protobuf/ptypes" + hclog "github.com/hashicorp/go-hclog" + plugin "github.com/hashicorp/go-plugin" + "github.com/hashicorp/nomad/drivers/shared/executor/proto" + "github.com/hashicorp/nomad/helper/discover" + "github.com/hashicorp/nomad/plugins/base" +) + +const ( + // ExecutorDefaultMaxPort is the default max port used by the executor for + // searching for an available port + ExecutorDefaultMaxPort = 14512 + + // ExecutorDefaultMinPort is the default min port used by the executor for + // searching for an available port + ExecutorDefaultMinPort = 14000 +) + +// CreateExecutor launches an executor plugin and returns an instance of the +// Executor interface +func CreateExecutor(w io.Writer, level hclog.Level, driverConfig *base.ClientDriverConfig, + executorConfig *ExecutorConfig) (Executor, *plugin.Client, error) { + + c, err := json.Marshal(executorConfig) + if err != nil { + return nil, nil, fmt.Errorf("unable to create executor config: %v", err) + } + bin, err := discover.NomadExecutable() + if err != nil { + return nil, nil, fmt.Errorf("unable to find the nomad binary: %v", err) + } + + config := &plugin.ClientConfig{ + Cmd: exec.Command(bin, "executor", string(c)), + } + config.HandshakeConfig = base.Handshake + config.Plugins = GetPluginMap(w, level, executorConfig.FSIsolation) + config.AllowedProtocols = []plugin.Protocol{plugin.ProtocolGRPC} + + if driverConfig != nil { + config.MaxPort = driverConfig.ClientMaxPort + config.MinPort = driverConfig.ClientMinPort + } else { + config.MaxPort = ExecutorDefaultMaxPort + config.MinPort = ExecutorDefaultMinPort + } + + // setting the setsid of the plugin process so that it doesn't get signals sent to + // the nomad client. + if config.Cmd != nil { + isolateCommand(config.Cmd) + } + + executorClient := plugin.NewClient(config) + rpcClient, err := executorClient.Client() + if err != nil { + return nil, nil, fmt.Errorf("error creating rpc client for executor plugin: %v", err) + } + + raw, err := rpcClient.Dispense("executor") + if err != nil { + return nil, nil, fmt.Errorf("unable to dispense the executor plugin: %v", err) + } + executorPlugin := raw.(Executor) + return executorPlugin, executorClient, nil +} + +// CreateExecutorWithConfig launches a plugin with a given plugin config +func CreateExecutorWithConfig(config *plugin.ClientConfig, w io.Writer) (Executor, *plugin.Client, error) { + config.HandshakeConfig = base.Handshake + + // Setting this to DEBUG since the log level at the executor server process + // is already set, and this effects only the executor client. + // TODO: Use versioned plugin map to support backwards compatability with + // existing pre-0.9 executors + config.Plugins = GetPluginMap(w, hclog.Debug, false) + config.AllowedProtocols = []plugin.Protocol{plugin.ProtocolGRPC} + + executorClient := plugin.NewClient(config) + rpcClient, err := executorClient.Client() + if err != nil { + return nil, nil, fmt.Errorf("error creating rpc client for executor plugin: %v", err) + } + + raw, err := rpcClient.Dispense("executor") + if err != nil { + return nil, nil, fmt.Errorf("unable to dispense the executor plugin: %v", err) + } + executorPlugin, ok := raw.(Executor) + if !ok { + return nil, nil, fmt.Errorf("unexpected executor rpc type: %T", raw) + } + return executorPlugin, executorClient, nil +} + +func processStateToProto(ps *ProcessState) (*proto.ProcessState, error) { + timestamp, err := ptypes.TimestampProto(ps.Time) + if err != nil { + return nil, err + } + pb := &proto.ProcessState{ + Pid: int32(ps.Pid), + ExitCode: int32(ps.ExitCode), + Signal: int32(ps.Signal), + Time: timestamp, + } + + return pb, nil +} + +func processStateFromProto(pb *proto.ProcessState) (*ProcessState, error) { + timestamp, err := ptypes.Timestamp(pb.Time) + if err != nil { + return nil, err + } + + return &ProcessState{ + Pid: int(pb.Pid), + ExitCode: int(pb.ExitCode), + Signal: int(pb.Signal), + Time: timestamp, + }, nil +} + +func resourcesToProto(r *Resources) *proto.Resources { + if r == nil { + return &proto.Resources{} + } + + return &proto.Resources{ + Cpu: int32(r.CPU), + MemoryMB: int32(r.MemoryMB), + DiskMB: int32(r.DiskMB), + Iops: int32(r.IOPS), + } +} + +func resourcesFromProto(pb *proto.Resources) *Resources { + if pb == nil { + return &Resources{} + } + + return &Resources{ + CPU: int(pb.Cpu), + MemoryMB: int(pb.MemoryMB), + DiskMB: int(pb.DiskMB), + IOPS: int(pb.Iops), + } +} diff --git a/drivers/shared/executor/utils_unix.go b/drivers/shared/executor/utils_unix.go new file mode 100644 index 000000000..ce1a39f86 --- /dev/null +++ b/drivers/shared/executor/utils_unix.go @@ -0,0 +1,18 @@ +// +build darwin dragonfly freebsd linux netbsd openbsd solaris + +package executor + +import ( + "os/exec" + "syscall" +) + +// isolateCommand sets the setsid flag in exec.Cmd to true so that the process +// becomes the process leader in a new session and doesn't receive signals that +// are sent to the parent process. +func isolateCommand(cmd *exec.Cmd) { + if cmd.SysProcAttr == nil { + cmd.SysProcAttr = &syscall.SysProcAttr{} + } + cmd.SysProcAttr.Setsid = true +} diff --git a/drivers/shared/executor/utils_windows.go b/drivers/shared/executor/utils_windows.go new file mode 100644 index 000000000..76ae317a2 --- /dev/null +++ b/drivers/shared/executor/utils_windows.go @@ -0,0 +1,6 @@ +package executor + +import "os/exec" + +// TODO Figure out if this is needed in Windows +func isolateCommand(cmd *exec.Cmd) {} diff --git a/plugins/drivers/utils/utils.go b/plugins/drivers/utils/utils.go index f36534354..1af2c7e78 100644 --- a/plugins/drivers/utils/utils.go +++ b/plugins/drivers/utils/utils.go @@ -1,34 +1,13 @@ package utils import ( - "encoding/json" - "fmt" - "io" - "os" - "os/exec" "strings" - hclog "github.com/hashicorp/go-hclog" - plugin "github.com/hashicorp/go-plugin" "github.com/hashicorp/nomad/client/allocdir" "github.com/hashicorp/nomad/client/config" cstructs "github.com/hashicorp/nomad/client/structs" "github.com/hashicorp/nomad/client/taskenv" - "github.com/hashicorp/nomad/drivers/shared/executor" - "github.com/hashicorp/nomad/helper/discover" "github.com/hashicorp/nomad/nomad/structs" - "github.com/hashicorp/nomad/plugins/base" - pexecutor "github.com/hashicorp/nomad/plugins/executor" -) - -const ( - // ExecutorDefaultMaxPort is the default max port used by the executor for - // searching for an available port - ExecutorDefaultMaxPort = 14512 - - // ExecutorDefaultMinPort is the default min port used by the executor for - // searching for an available port - ExecutorDefaultMinPort = 14000 ) // SetEnvvars sets path and host env vars depending on the FS isolation used. @@ -60,89 +39,3 @@ func CgroupsMounted(node *structs.Node) bool { _, ok := node.Attributes["unique.cgroup.mountpoint"] return ok } - -// CreateExecutor launches an executor plugin and returns an instance of the -// Executor interface -func CreateExecutor(w io.Writer, level hclog.Level, driverConfig *base.ClientDriverConfig, - executorConfig *pexecutor.ExecutorConfig) (executor.Executor, *plugin.Client, error) { - - c, err := json.Marshal(executorConfig) - if err != nil { - return nil, nil, fmt.Errorf("unable to create executor config: %v", err) - } - bin, err := discover.NomadExecutable() - if err != nil { - return nil, nil, fmt.Errorf("unable to find the nomad binary: %v", err) - } - - config := &plugin.ClientConfig{ - Cmd: exec.Command(bin, "executor", string(c)), - } - config.HandshakeConfig = base.Handshake - config.Plugins = pexecutor.GetPluginMap(w, level, executorConfig.FSIsolation) - config.AllowedProtocols = []plugin.Protocol{plugin.ProtocolGRPC} - - if driverConfig != nil { - config.MaxPort = driverConfig.ClientMaxPort - config.MinPort = driverConfig.ClientMinPort - } else { - config.MaxPort = ExecutorDefaultMaxPort - config.MinPort = ExecutorDefaultMinPort - } - - // setting the setsid of the plugin process so that it doesn't get signals sent to - // the nomad client. - if config.Cmd != nil { - isolateCommand(config.Cmd) - } - - executorClient := plugin.NewClient(config) - rpcClient, err := executorClient.Client() - if err != nil { - return nil, nil, fmt.Errorf("error creating rpc client for executor plugin: %v", err) - } - - raw, err := rpcClient.Dispense("executor") - if err != nil { - return nil, nil, fmt.Errorf("unable to dispense the executor plugin: %v", err) - } - executorPlugin := raw.(executor.Executor) - return executorPlugin, executorClient, nil -} - -// CreateExecutorWithConfig launches a plugin with a given plugin config -func CreateExecutorWithConfig(config *plugin.ClientConfig, w io.Writer) (executor.Executor, *plugin.Client, error) { - config.HandshakeConfig = base.Handshake - - // Setting this to DEBUG since the log level at the executor server process - // is already set, and this effects only the executor client. - // TODO: Use versioned plugin map to support backwards compatability with - // existing pre-0.9 executors - config.Plugins = pexecutor.GetPluginMap(w, hclog.Debug, false) - config.AllowedProtocols = []plugin.Protocol{plugin.ProtocolGRPC} - - executorClient := plugin.NewClient(config) - rpcClient, err := executorClient.Client() - if err != nil { - return nil, nil, fmt.Errorf("error creating rpc client for executor plugin: %v", err) - } - - raw, err := rpcClient.Dispense("executor") - if err != nil { - return nil, nil, fmt.Errorf("unable to dispense the executor plugin: %v", err) - } - executorPlugin, ok := raw.(executor.Executor) - if !ok { - return nil, nil, fmt.Errorf("unexpected executor rpc type: %T", raw) - } - return executorPlugin, executorClient, nil -} - -// KillProcess kills a process with the given pid -func KillProcess(pid int) error { - proc, err := os.FindProcess(pid) - if err != nil { - return err - } - return proc.Kill() -} diff --git a/plugins/drivers/utils/utils_unix.go b/plugins/drivers/utils/utils_unix.go index 85d9fe6c0..d7592be07 100644 --- a/plugins/drivers/utils/utils_unix.go +++ b/plugins/drivers/utils/utils_unix.go @@ -3,22 +3,9 @@ package utils import ( - "os/exec" - "syscall" - "golang.org/x/sys/unix" ) -// isolateCommand sets the setsid flag in exec.Cmd to true so that the process -// becomes the process leader in a new session and doesn't receive signals that -// are sent to the parent process. -func isolateCommand(cmd *exec.Cmd) { - if cmd.SysProcAttr == nil { - cmd.SysProcAttr = &syscall.SysProcAttr{} - } - cmd.SysProcAttr.Setsid = true -} - // IsUnixRoot returns true if system is unix and user running is effectively root func IsUnixRoot() bool { return unix.Geteuid() == 0 diff --git a/plugins/drivers/utils/utils_windows.go b/plugins/drivers/utils/utils_windows.go index 8243e498a..bc322d966 100644 --- a/plugins/drivers/utils/utils_windows.go +++ b/plugins/drivers/utils/utils_windows.go @@ -1,12 +1,5 @@ package utils -import ( - "os/exec" -) - -// TODO Figure out if this is needed in Windows -func isolateCommand(cmd *exec.Cmd) {} - // IsUnixRoot returns true if system is a unix system and the effective uid of user is root func IsUnixRoot() bool { return false diff --git a/plugins/executor/utils.go b/plugins/executor/utils.go deleted file mode 100644 index 222e95727..000000000 --- a/plugins/executor/utils.go +++ /dev/null @@ -1,62 +0,0 @@ -package executor - -import ( - "github.com/golang/protobuf/ptypes" - "github.com/hashicorp/nomad/drivers/shared/executor" - "github.com/hashicorp/nomad/plugins/executor/proto" -) - -func processStateToProto(ps *executor.ProcessState) (*proto.ProcessState, error) { - timestamp, err := ptypes.TimestampProto(ps.Time) - if err != nil { - return nil, err - } - pb := &proto.ProcessState{ - Pid: int32(ps.Pid), - ExitCode: int32(ps.ExitCode), - Signal: int32(ps.Signal), - Time: timestamp, - } - - return pb, nil -} - -func processStateFromProto(pb *proto.ProcessState) (*executor.ProcessState, error) { - timestamp, err := ptypes.Timestamp(pb.Time) - if err != nil { - return nil, err - } - - return &executor.ProcessState{ - Pid: int(pb.Pid), - ExitCode: int(pb.ExitCode), - Signal: int(pb.Signal), - Time: timestamp, - }, nil -} - -func resourcesToProto(r *executor.Resources) *proto.Resources { - if r == nil { - return &proto.Resources{} - } - - return &proto.Resources{ - Cpu: int32(r.CPU), - MemoryMB: int32(r.MemoryMB), - DiskMB: int32(r.DiskMB), - Iops: int32(r.IOPS), - } -} - -func resourcesFromProto(pb *proto.Resources) *executor.Resources { - if pb == nil { - return &executor.Resources{} - } - - return &executor.Resources{ - CPU: int(pb.Cpu), - MemoryMB: int(pb.MemoryMB), - DiskMB: int(pb.DiskMB), - IOPS: int(pb.Iops), - } -} From 224c68860da73ab462029f7ace1a935509f45084 Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Thu, 6 Dec 2018 21:22:02 -0500 Subject: [PATCH 06/13] executor: use drivers.Resources as resource model --- drivers/shared/executor/client.go | 6 +- drivers/shared/executor/executor.go | 15 +- drivers/shared/executor/executor_linux.go | 25 +- drivers/shared/executor/proto/executor.pb.go | 252 +++++++------------ drivers/shared/executor/proto/executor.proto | 11 +- drivers/shared/executor/server.go | 4 +- drivers/shared/executor/utils.go | 26 -- plugins/drivers/utils.go | 8 +- 8 files changed, 117 insertions(+), 230 deletions(-) diff --git a/drivers/shared/executor/client.go b/drivers/shared/executor/client.go index 2a6700b24..d0ce617c2 100644 --- a/drivers/shared/executor/client.go +++ b/drivers/shared/executor/client.go @@ -26,7 +26,7 @@ func (c *grpcExecutorClient) Launch(cmd *ExecCommand) (*ProcessState, error) { req := &proto.LaunchRequest{ Cmd: cmd.Cmd, Args: cmd.Args, - Resources: resourcesToProto(cmd.Resources), + Resources: drivers.ResourcesToProto(cmd.Resources), StdoutPath: cmd.StdoutPath, StderrPath: cmd.StderrPath, Env: cmd.Env, @@ -77,9 +77,9 @@ func (c *grpcExecutorClient) Shutdown(signal string, gracePeriod time.Duration) return nil } -func (c *grpcExecutorClient) UpdateResources(r *Resources) error { +func (c *grpcExecutorClient) UpdateResources(r *drivers.Resources) error { ctx := context.Background() - req := &proto.UpdateResourcesRequest{Resources: resourcesToProto(r)} + req := &proto.UpdateResourcesRequest{Resources: drivers.ResourcesToProto(r)} if _, err := c.client.UpdateResources(ctx, req); err != nil { return err } diff --git a/drivers/shared/executor/executor.go b/drivers/shared/executor/executor.go index b1d898103..3f9b2cca1 100644 --- a/drivers/shared/executor/executor.go +++ b/drivers/shared/executor/executor.go @@ -21,6 +21,7 @@ import ( "github.com/hashicorp/nomad/client/lib/fifo" "github.com/hashicorp/nomad/client/stats" shelpers "github.com/hashicorp/nomad/helper/stats" + "github.com/hashicorp/nomad/plugins/drivers" "github.com/hashicorp/consul-template/signals" cstructs "github.com/hashicorp/nomad/client/structs" @@ -62,7 +63,7 @@ type Executor interface { // UpdateResources updates any resource isolation enforcement with new // constraints if supported. - UpdateResources(*Resources) error + UpdateResources(*drivers.Resources) error // Version returns the executor API version Version() (*ExecutorVersion, error) @@ -78,14 +79,6 @@ type Executor interface { Exec(deadline time.Time, cmd string, args []string) ([]byte, int, error) } -// Resources describes the resource isolation required -type Resources struct { - CPU int - MemoryMB int - DiskMB int - IOPS int -} - // ExecCommand holds the user command, args, and other isolation related // settings. type ExecCommand struct { @@ -96,7 +89,7 @@ type ExecCommand struct { Args []string // Resources defined by the task - Resources *Resources + Resources *drivers.Resources // StdoutPath is the path the process stdout should be written to StdoutPath string @@ -369,7 +362,7 @@ func (e *UniversalExecutor) Wait(ctx context.Context) (*ProcessState, error) { } } -func (e *UniversalExecutor) UpdateResources(resources *Resources) error { +func (e *UniversalExecutor) UpdateResources(resources *drivers.Resources) error { return nil } diff --git a/drivers/shared/executor/executor_linux.go b/drivers/shared/executor/executor_linux.go index dc361f3a3..9e94723f5 100644 --- a/drivers/shared/executor/executor_linux.go +++ b/drivers/shared/executor/executor_linux.go @@ -22,6 +22,7 @@ import ( "github.com/hashicorp/nomad/helper/discover" shelpers "github.com/hashicorp/nomad/helper/stats" "github.com/hashicorp/nomad/helper/uuid" + "github.com/hashicorp/nomad/plugins/drivers" "github.com/opencontainers/runc/libcontainer" "github.com/opencontainers/runc/libcontainer/cgroups" cgroupFs "github.com/opencontainers/runc/libcontainer/cgroups/fs" @@ -101,7 +102,7 @@ func (l *LibcontainerExecutor) Launch(command *ExecCommand) (*ProcessState, erro } if command.Resources == nil { - command.Resources = &Resources{} + command.Resources = &drivers.Resources{} } l.command = command @@ -331,7 +332,7 @@ func (l *LibcontainerExecutor) Shutdown(signal string, grace time.Duration) erro } // UpdateResources updates the resource isolation with new values to be enforced -func (l *LibcontainerExecutor) UpdateResources(resources *Resources) error { +func (l *LibcontainerExecutor) UpdateResources(resources *drivers.Resources) error { return nil } @@ -544,29 +545,21 @@ func configureCgroups(cfg *lconfigs.Config, command *ExecCommand) error { id := uuid.Generate() cfg.Cgroups.Path = filepath.Join(defaultCgroupParent, id) - if command.Resources.MemoryMB > 0 { + if command.Resources.NomadResources.MemoryMB > 0 { // Total amount of memory allowed to consume - cfg.Cgroups.Resources.Memory = int64(command.Resources.MemoryMB * 1024 * 1024) + cfg.Cgroups.Resources.Memory = int64(command.Resources.NomadResources.MemoryMB * 1024 * 1024) // Disable swap to avoid issues on the machine - var memSwappiness uint64 = 0 + var memSwappiness uint64 cfg.Cgroups.Resources.MemorySwappiness = &memSwappiness } - if command.Resources.CPU < 2 { - return fmt.Errorf("resources.CPU must be equal to or greater than 2: %v", command.Resources.CPU) + if command.Resources.NomadResources.CPU < 2 { + return fmt.Errorf("resources.CPU must be equal to or greater than 2: %v", command.Resources.NomadResources.CPU) } // Set the relative CPU shares for this cgroup. - cfg.Cgroups.Resources.CpuShares = uint64(command.Resources.CPU) + cfg.Cgroups.Resources.CpuShares = uint64(command.Resources.NomadResources.CPU) - if command.Resources.IOPS != 0 { - // Validate it is in an acceptable range. - if command.Resources.IOPS < 10 || command.Resources.IOPS > 1000 { - return fmt.Errorf("resources.IOPS must be between 10 and 1000: %d", command.Resources.IOPS) - } - - cfg.Cgroups.Resources.BlkioWeight = uint16(command.Resources.IOPS) - } return nil } diff --git a/drivers/shared/executor/proto/executor.pb.go b/drivers/shared/executor/proto/executor.pb.go index 5c345fa66..a6063abbd 100644 --- a/drivers/shared/executor/proto/executor.pb.go +++ b/drivers/shared/executor/proto/executor.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: plugins/executor/proto/executor.proto +// source: drivers/shared/executor/proto/executor.proto package proto @@ -26,26 +26,26 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package type LaunchRequest struct { - Cmd string `protobuf:"bytes,1,opt,name=cmd,proto3" json:"cmd,omitempty"` - Args []string `protobuf:"bytes,2,rep,name=args,proto3" json:"args,omitempty"` - Resources *Resources `protobuf:"bytes,3,opt,name=resources,proto3" json:"resources,omitempty"` - StdoutPath string `protobuf:"bytes,4,opt,name=stdout_path,json=stdoutPath,proto3" json:"stdout_path,omitempty"` - StderrPath string `protobuf:"bytes,5,opt,name=stderr_path,json=stderrPath,proto3" json:"stderr_path,omitempty"` - Env []string `protobuf:"bytes,6,rep,name=env,proto3" json:"env,omitempty"` - User string `protobuf:"bytes,7,opt,name=user,proto3" json:"user,omitempty"` - TaskDir string `protobuf:"bytes,8,opt,name=task_dir,json=taskDir,proto3" json:"task_dir,omitempty"` - ResourceLimits bool `protobuf:"varint,9,opt,name=resource_limits,json=resourceLimits,proto3" json:"resource_limits,omitempty"` - BasicProcessCgroup bool `protobuf:"varint,10,opt,name=basic_process_cgroup,json=basicProcessCgroup,proto3" json:"basic_process_cgroup,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Cmd string `protobuf:"bytes,1,opt,name=cmd,proto3" json:"cmd,omitempty"` + Args []string `protobuf:"bytes,2,rep,name=args,proto3" json:"args,omitempty"` + Resources *proto1.Resources `protobuf:"bytes,3,opt,name=resources,proto3" json:"resources,omitempty"` + StdoutPath string `protobuf:"bytes,4,opt,name=stdout_path,json=stdoutPath,proto3" json:"stdout_path,omitempty"` + StderrPath string `protobuf:"bytes,5,opt,name=stderr_path,json=stderrPath,proto3" json:"stderr_path,omitempty"` + Env []string `protobuf:"bytes,6,rep,name=env,proto3" json:"env,omitempty"` + User string `protobuf:"bytes,7,opt,name=user,proto3" json:"user,omitempty"` + TaskDir string `protobuf:"bytes,8,opt,name=task_dir,json=taskDir,proto3" json:"task_dir,omitempty"` + ResourceLimits bool `protobuf:"varint,9,opt,name=resource_limits,json=resourceLimits,proto3" json:"resource_limits,omitempty"` + BasicProcessCgroup bool `protobuf:"varint,10,opt,name=basic_process_cgroup,json=basicProcessCgroup,proto3" json:"basic_process_cgroup,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *LaunchRequest) Reset() { *m = LaunchRequest{} } func (m *LaunchRequest) String() string { return proto.CompactTextString(m) } func (*LaunchRequest) ProtoMessage() {} func (*LaunchRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{0} + return fileDescriptor_executor_ac624d46b225110f, []int{0} } func (m *LaunchRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_LaunchRequest.Unmarshal(m, b) @@ -79,7 +79,7 @@ func (m *LaunchRequest) GetArgs() []string { return nil } -func (m *LaunchRequest) GetResources() *Resources { +func (m *LaunchRequest) GetResources() *proto1.Resources { if m != nil { return m.Resources } @@ -146,7 +146,7 @@ func (m *LaunchResponse) Reset() { *m = LaunchResponse{} } func (m *LaunchResponse) String() string { return proto.CompactTextString(m) } func (*LaunchResponse) ProtoMessage() {} func (*LaunchResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{1} + return fileDescriptor_executor_ac624d46b225110f, []int{1} } func (m *LaunchResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_LaunchResponse.Unmarshal(m, b) @@ -183,7 +183,7 @@ func (m *WaitRequest) Reset() { *m = WaitRequest{} } func (m *WaitRequest) String() string { return proto.CompactTextString(m) } func (*WaitRequest) ProtoMessage() {} func (*WaitRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{2} + return fileDescriptor_executor_ac624d46b225110f, []int{2} } func (m *WaitRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_WaitRequest.Unmarshal(m, b) @@ -214,7 +214,7 @@ func (m *WaitResponse) Reset() { *m = WaitResponse{} } func (m *WaitResponse) String() string { return proto.CompactTextString(m) } func (*WaitResponse) ProtoMessage() {} func (*WaitResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{3} + return fileDescriptor_executor_ac624d46b225110f, []int{3} } func (m *WaitResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_WaitResponse.Unmarshal(m, b) @@ -253,7 +253,7 @@ func (m *ShutdownRequest) Reset() { *m = ShutdownRequest{} } func (m *ShutdownRequest) String() string { return proto.CompactTextString(m) } func (*ShutdownRequest) ProtoMessage() {} func (*ShutdownRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{4} + return fileDescriptor_executor_ac624d46b225110f, []int{4} } func (m *ShutdownRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ShutdownRequest.Unmarshal(m, b) @@ -297,7 +297,7 @@ func (m *ShutdownResponse) Reset() { *m = ShutdownResponse{} } func (m *ShutdownResponse) String() string { return proto.CompactTextString(m) } func (*ShutdownResponse) ProtoMessage() {} func (*ShutdownResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{5} + return fileDescriptor_executor_ac624d46b225110f, []int{5} } func (m *ShutdownResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ShutdownResponse.Unmarshal(m, b) @@ -318,17 +318,17 @@ func (m *ShutdownResponse) XXX_DiscardUnknown() { var xxx_messageInfo_ShutdownResponse proto.InternalMessageInfo type UpdateResourcesRequest struct { - Resources *Resources `protobuf:"bytes,1,opt,name=resources,proto3" json:"resources,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Resources *proto1.Resources `protobuf:"bytes,1,opt,name=resources,proto3" json:"resources,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *UpdateResourcesRequest) Reset() { *m = UpdateResourcesRequest{} } func (m *UpdateResourcesRequest) String() string { return proto.CompactTextString(m) } func (*UpdateResourcesRequest) ProtoMessage() {} func (*UpdateResourcesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{6} + return fileDescriptor_executor_ac624d46b225110f, []int{6} } func (m *UpdateResourcesRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UpdateResourcesRequest.Unmarshal(m, b) @@ -348,7 +348,7 @@ func (m *UpdateResourcesRequest) XXX_DiscardUnknown() { var xxx_messageInfo_UpdateResourcesRequest proto.InternalMessageInfo -func (m *UpdateResourcesRequest) GetResources() *Resources { +func (m *UpdateResourcesRequest) GetResources() *proto1.Resources { if m != nil { return m.Resources } @@ -365,7 +365,7 @@ func (m *UpdateResourcesResponse) Reset() { *m = UpdateResourcesResponse func (m *UpdateResourcesResponse) String() string { return proto.CompactTextString(m) } func (*UpdateResourcesResponse) ProtoMessage() {} func (*UpdateResourcesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{7} + return fileDescriptor_executor_ac624d46b225110f, []int{7} } func (m *UpdateResourcesResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UpdateResourcesResponse.Unmarshal(m, b) @@ -395,7 +395,7 @@ func (m *VersionRequest) Reset() { *m = VersionRequest{} } func (m *VersionRequest) String() string { return proto.CompactTextString(m) } func (*VersionRequest) ProtoMessage() {} func (*VersionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{8} + return fileDescriptor_executor_ac624d46b225110f, []int{8} } func (m *VersionRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_VersionRequest.Unmarshal(m, b) @@ -426,7 +426,7 @@ func (m *VersionResponse) Reset() { *m = VersionResponse{} } func (m *VersionResponse) String() string { return proto.CompactTextString(m) } func (*VersionResponse) ProtoMessage() {} func (*VersionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{9} + return fileDescriptor_executor_ac624d46b225110f, []int{9} } func (m *VersionResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_VersionResponse.Unmarshal(m, b) @@ -463,7 +463,7 @@ func (m *StatsRequest) Reset() { *m = StatsRequest{} } func (m *StatsRequest) String() string { return proto.CompactTextString(m) } func (*StatsRequest) ProtoMessage() {} func (*StatsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{10} + return fileDescriptor_executor_ac624d46b225110f, []int{10} } func (m *StatsRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_StatsRequest.Unmarshal(m, b) @@ -494,7 +494,7 @@ func (m *StatsResponse) Reset() { *m = StatsResponse{} } func (m *StatsResponse) String() string { return proto.CompactTextString(m) } func (*StatsResponse) ProtoMessage() {} func (*StatsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{11} + return fileDescriptor_executor_ac624d46b225110f, []int{11} } func (m *StatsResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_StatsResponse.Unmarshal(m, b) @@ -532,7 +532,7 @@ func (m *SignalRequest) Reset() { *m = SignalRequest{} } func (m *SignalRequest) String() string { return proto.CompactTextString(m) } func (*SignalRequest) ProtoMessage() {} func (*SignalRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{12} + return fileDescriptor_executor_ac624d46b225110f, []int{12} } func (m *SignalRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalRequest.Unmarshal(m, b) @@ -569,7 +569,7 @@ func (m *SignalResponse) Reset() { *m = SignalResponse{} } func (m *SignalResponse) String() string { return proto.CompactTextString(m) } func (*SignalResponse) ProtoMessage() {} func (*SignalResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{13} + return fileDescriptor_executor_ac624d46b225110f, []int{13} } func (m *SignalResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalResponse.Unmarshal(m, b) @@ -602,7 +602,7 @@ func (m *ExecRequest) Reset() { *m = ExecRequest{} } func (m *ExecRequest) String() string { return proto.CompactTextString(m) } func (*ExecRequest) ProtoMessage() {} func (*ExecRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{14} + return fileDescriptor_executor_ac624d46b225110f, []int{14} } func (m *ExecRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ExecRequest.Unmarshal(m, b) @@ -655,7 +655,7 @@ func (m *ExecResponse) Reset() { *m = ExecResponse{} } func (m *ExecResponse) String() string { return proto.CompactTextString(m) } func (*ExecResponse) ProtoMessage() {} func (*ExecResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{15} + return fileDescriptor_executor_ac624d46b225110f, []int{15} } func (m *ExecResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ExecResponse.Unmarshal(m, b) @@ -689,68 +689,6 @@ func (m *ExecResponse) GetExitCode() int32 { return 0 } -type Resources struct { - Cpu int32 `protobuf:"varint,1,opt,name=cpu,proto3" json:"cpu,omitempty"` - MemoryMB int32 `protobuf:"varint,2,opt,name=memoryMB,proto3" json:"memoryMB,omitempty"` - DiskMB int32 `protobuf:"varint,3,opt,name=diskMB,proto3" json:"diskMB,omitempty"` - Iops int32 `protobuf:"varint,4,opt,name=iops,proto3" json:"iops,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Resources) Reset() { *m = Resources{} } -func (m *Resources) String() string { return proto.CompactTextString(m) } -func (*Resources) ProtoMessage() {} -func (*Resources) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{16} -} -func (m *Resources) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Resources.Unmarshal(m, b) -} -func (m *Resources) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Resources.Marshal(b, m, deterministic) -} -func (dst *Resources) XXX_Merge(src proto.Message) { - xxx_messageInfo_Resources.Merge(dst, src) -} -func (m *Resources) XXX_Size() int { - return xxx_messageInfo_Resources.Size(m) -} -func (m *Resources) XXX_DiscardUnknown() { - xxx_messageInfo_Resources.DiscardUnknown(m) -} - -var xxx_messageInfo_Resources proto.InternalMessageInfo - -func (m *Resources) GetCpu() int32 { - if m != nil { - return m.Cpu - } - return 0 -} - -func (m *Resources) GetMemoryMB() int32 { - if m != nil { - return m.MemoryMB - } - return 0 -} - -func (m *Resources) GetDiskMB() int32 { - if m != nil { - return m.DiskMB - } - return 0 -} - -func (m *Resources) GetIops() int32 { - if m != nil { - return m.Iops - } - return 0 -} - type ProcessState struct { Pid int32 `protobuf:"varint,1,opt,name=pid,proto3" json:"pid,omitempty"` ExitCode int32 `protobuf:"varint,2,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"` @@ -765,7 +703,7 @@ func (m *ProcessState) Reset() { *m = ProcessState{} } func (m *ProcessState) String() string { return proto.CompactTextString(m) } func (*ProcessState) ProtoMessage() {} func (*ProcessState) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_e0a843141d496249, []int{17} + return fileDescriptor_executor_ac624d46b225110f, []int{16} } func (m *ProcessState) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ProcessState.Unmarshal(m, b) @@ -830,7 +768,6 @@ func init() { proto.RegisterType((*SignalResponse)(nil), "hashicorp.nomad.plugins.executor.proto.SignalResponse") proto.RegisterType((*ExecRequest)(nil), "hashicorp.nomad.plugins.executor.proto.ExecRequest") proto.RegisterType((*ExecResponse)(nil), "hashicorp.nomad.plugins.executor.proto.ExecResponse") - proto.RegisterType((*Resources)(nil), "hashicorp.nomad.plugins.executor.proto.Resources") proto.RegisterType((*ProcessState)(nil), "hashicorp.nomad.plugins.executor.proto.ProcessState") } @@ -1134,68 +1071,65 @@ var _Executor_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "plugins/executor/proto/executor.proto", + Metadata: "drivers/shared/executor/proto/executor.proto", } func init() { - proto.RegisterFile("plugins/executor/proto/executor.proto", fileDescriptor_executor_e0a843141d496249) + proto.RegisterFile("drivers/shared/executor/proto/executor.proto", fileDescriptor_executor_ac624d46b225110f) } -var fileDescriptor_executor_e0a843141d496249 = []byte{ - // 869 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x5d, 0x6f, 0xe3, 0x44, - 0x14, 0x5d, 0x37, 0x75, 0xe2, 0xdc, 0xa4, 0x4d, 0x34, 0x42, 0xc5, 0x6b, 0x1e, 0x36, 0x58, 0x82, - 0x8d, 0x84, 0xe4, 0x2c, 0xdd, 0x2f, 0x5e, 0x00, 0xa9, 0x65, 0x79, 0xea, 0x42, 0xe5, 0x2e, 0xac, - 0xc4, 0x03, 0xc1, 0xb5, 0x07, 0x67, 0x94, 0xd8, 0x63, 0x66, 0xc6, 0xa1, 0x95, 0x90, 0x78, 0xe2,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0xb6, 0x93, 0x05, 0xcf, 0x77, 0xc6, 0x35, 0xec, 0x6b, - 0x70, 0x95, 0xfd, 0xa0, 0xd6, 0xcf, 0xba, 0x69, 0x83, 0xc1, 0xd3, 0x1d, 0x51, 0x0d, 0xef, 0x35, - 0x74, 0xb5, 0x7b, 0xb5, 0x57, 0xff, 0x96, 0x2d, 0xb6, 0x57, 0xff, 0x2d, 0x93, 0x54, 0xea, 0x97, - 0x1f, 0x61, 0x7b, 0xf5, 0x6f, 0x98, 0x6a, 0x7b, 0xf5, 0x6f, 0x9a, 0x63, 0x78, 0xef, 0xa4, 0xf7, - 0x9d, 0xab, 0x6d, 0xa1, 0xab, 0x7e, 0x1e, 0xff, 0x15, 0x00, 0x00, 0xff, 0xff, 0xa6, 0x03, 0x32, - 0x69, 0x5f, 0x0a, 0x00, 0x00, +var fileDescriptor_executor_ac624d46b225110f = []byte{ + // 826 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x4b, 0x6f, 0xe4, 0x44, + 0x10, 0x5e, 0xcf, 0x7b, 0x6a, 0x9e, 0x6a, 0xa1, 0xe0, 0x35, 0x87, 0x1d, 0x7c, 0x60, 0x47, 0x02, + 0xd9, 0xab, 0xec, 0x8b, 0x0b, 0x20, 0x11, 0x96, 0x53, 0xb4, 0x8a, 0x9c, 0x85, 0x95, 0x38, 0x30, + 0x74, 0xec, 0xc6, 0x6e, 0x65, 0xc6, 0x6d, 0xba, 0xdb, 0x43, 0x22, 0x21, 0x71, 0xe2, 0x1f, 0xf0, + 0x0f, 0xf9, 0x13, 0x1c, 0x91, 0xfb, 0xe1, 0xcc, 0x24, 0x10, 0x3c, 0xa0, 0x3d, 0xb9, 0xab, 0x5c, + 0x55, 0x5f, 0x55, 0xf7, 0x57, 0x1f, 0x7c, 0x92, 0x70, 0xba, 0x25, 0x5c, 0x84, 0x22, 0xc3, 0x9c, + 0x24, 0x21, 0xb9, 0x22, 0x71, 0x29, 0x19, 0x0f, 0x0b, 0xce, 0x24, 0xab, 0xcd, 0x40, 0x99, 0xe8, + 0xa3, 0x0c, 0x8b, 0x8c, 0xc6, 0x8c, 0x17, 0x41, 0xce, 0x36, 0x38, 0x09, 0x8a, 0x75, 0x99, 0xd2, + 0x5c, 0x04, 0xfb, 0x71, 0xde, 0xa3, 0x94, 0xb1, 0x74, 0x4d, 0x74, 0x91, 0x8b, 0xf2, 0xc7, 0x50, + 0xd2, 0x0d, 0x11, 0x12, 0x6f, 0x0a, 0x13, 0xf0, 0x59, 0x4a, 0x65, 0x56, 0x5e, 0x04, 0x31, 0xdb, + 0x84, 0x75, 0xcd, 0x50, 0xd5, 0x0c, 0x4d, 0xcd, 0xd0, 0x76, 0xa6, 0x3b, 0xd1, 0x96, 0x4e, 0xf7, + 0xff, 0x68, 0xc1, 0xe4, 0x14, 0x97, 0x79, 0x9c, 0x45, 0xe4, 0xa7, 0x92, 0x08, 0x89, 0xe6, 0xd0, + 0x8e, 0x37, 0x89, 0xeb, 0x2c, 0x9c, 0xe5, 0x30, 0xaa, 0x8e, 0x08, 0x41, 0x07, 0xf3, 0x54, 0xb8, + 0xad, 0x45, 0x7b, 0x39, 0x8c, 0xd4, 0x19, 0xbd, 0x86, 0x21, 0x27, 0x82, 0x95, 0x3c, 0x26, 0xc2, + 0x6d, 0x2f, 0x9c, 0xe5, 0xe8, 0xf8, 0x49, 0xf0, 0x4f, 0x33, 0x19, 0x7c, 0x0d, 0x19, 0x44, 0x36, + 0x2f, 0xba, 0x29, 0x81, 0x1e, 0xc1, 0x48, 0xc8, 0x84, 0x95, 0x72, 0x55, 0x60, 0x99, 0xb9, 0x1d, + 0x85, 0x0e, 0xda, 0x75, 0x86, 0x65, 0x66, 0x02, 0x08, 0xe7, 0x3a, 0xa0, 0x5b, 0x07, 0x10, 0xce, + 0x55, 0xc0, 0x1c, 0xda, 0x24, 0xdf, 0xba, 0x3d, 0xd5, 0x64, 0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 0xc4, 0x55, 0x69, 0xcf, 0xfd, 0x63, 0xab, + 0xb8, 0xe3, 0x3f, 0xfb, 0x30, 0x78, 0x65, 0x96, 0x05, 0x5d, 0x43, 0x4f, 0x6f, 0x38, 0x7a, 0xde, + 0x74, 0xb3, 0xf6, 0x64, 0xd7, 0x7b, 0x71, 0x68, 0x9a, 0x79, 0xbf, 0x07, 0x48, 0x40, 0xa7, 0xda, + 0x75, 0xf4, 0xb4, 0x69, 0x85, 0x1d, 0xa1, 0xf0, 0x9e, 0x1d, 0x96, 0x54, 0x83, 0xfe, 0x0a, 0x03, + 0xbb, 0xb2, 0xe8, 0x65, 0xd3, 0x1a, 0xb7, 0x24, 0xc3, 0xfb, 0xf4, 0xf0, 0xc4, 0xba, 0x81, 0xdf, + 0x1d, 0x98, 0xdd, 0x5a, 0x5b, 0xf4, 0x79, 0xd3, 0x7a, 0x7f, 0xaf, 0x2c, 0xde, 0x17, 0xff, 0x39, + 0xbf, 0x6e, 0xeb, 0x17, 0xe8, 0x1b, 0x7d, 0x40, 0x8d, 0x5f, 0x74, 0x5f, 0x62, 0xbc, 0x97, 0x07, + 0xe7, 0xd5, 0xe8, 0x5b, 0xe8, 0x2a, 0x5d, 0x40, 0x8d, 0x9f, 0x75, 0x57, 0x9f, 0xbc, 0xe7, 0x07, + 0x66, 0xd5, 0xb8, 0xd7, 0xd0, 0xd3, 0xb2, 0xd2, 0x9c, 0xfd, 0x7b, 0x7a, 0xd5, 0x9c, 0xfd, 0xb7, + 0xd4, 0x4b, 0xb1, 0xbf, 0x5a, 0xc2, 0xe6, 0xec, 0xdf, 0x51, 0xbb, 0xe6, 0xec, 0xdf, 0x55, 0x2d, + 0xff, 0xc1, 0x97, 0xfd, 0xef, 0xba, 0x5a, 0x16, 0x7a, 0xea, 0xf3, 0xf4, 0xaf, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x89, 0x48, 0x8a, 0x16, 0xfd, 0x09, 0x00, 0x00, } diff --git a/drivers/shared/executor/proto/executor.proto b/drivers/shared/executor/proto/executor.proto index 1ec576caa..4d81ce894 100644 --- a/drivers/shared/executor/proto/executor.proto +++ b/drivers/shared/executor/proto/executor.proto @@ -19,7 +19,7 @@ service Executor { message LaunchRequest { string cmd = 1; repeated string args = 2; - Resources resources = 3; + hashicorp.nomad.plugins.drivers.proto.Resources resources = 3; string stdout_path = 4; string stderr_path = 5; repeated string env = 6; @@ -47,7 +47,7 @@ message ShutdownRequest { message ShutdownResponse {} message UpdateResourcesRequest{ - Resources resources = 1; + hashicorp.nomad.plugins.drivers.proto.Resources resources = 1; } message UpdateResourcesResponse {} @@ -81,13 +81,6 @@ message ExecResponse { int32 exit_code = 2; } -message Resources { - int32 cpu = 1; - int32 memoryMB = 2; - int32 diskMB = 3; - int32 iops = 4; -} - message ProcessState { int32 pid = 1; int32 exit_code = 2; diff --git a/drivers/shared/executor/server.go b/drivers/shared/executor/server.go index 68c39812b..4a7b3d314 100644 --- a/drivers/shared/executor/server.go +++ b/drivers/shared/executor/server.go @@ -20,7 +20,7 @@ func (s *grpcExecutorServer) Launch(ctx context.Context, req *proto.LaunchReques ps, err := s.impl.Launch(&ExecCommand{ Cmd: req.Cmd, Args: req.Args, - Resources: resourcesFromProto(req.Resources), + Resources: drivers.ResourcesFromProto(req.Resources), StdoutPath: req.StdoutPath, StderrPath: req.StderrPath, Env: req.Env, @@ -69,7 +69,7 @@ func (s *grpcExecutorServer) Shutdown(ctx context.Context, req *proto.ShutdownRe } func (s *grpcExecutorServer) UpdateResources(ctx context.Context, req *proto.UpdateResourcesRequest) (*proto.UpdateResourcesResponse, error) { - if err := s.impl.UpdateResources(resourcesFromProto(req.Resources)); err != nil { + if err := s.impl.UpdateResources(drivers.ResourcesFromProto(req.Resources)); err != nil { return nil, err } diff --git a/drivers/shared/executor/utils.go b/drivers/shared/executor/utils.go index 30f51b66d..36dc1f783 100644 --- a/drivers/shared/executor/utils.go +++ b/drivers/shared/executor/utils.go @@ -129,29 +129,3 @@ func processStateFromProto(pb *proto.ProcessState) (*ProcessState, error) { Time: timestamp, }, nil } - -func resourcesToProto(r *Resources) *proto.Resources { - if r == nil { - return &proto.Resources{} - } - - return &proto.Resources{ - Cpu: int32(r.CPU), - MemoryMB: int32(r.MemoryMB), - DiskMB: int32(r.DiskMB), - Iops: int32(r.IOPS), - } -} - -func resourcesFromProto(pb *proto.Resources) *Resources { - if pb == nil { - return &Resources{} - } - - return &Resources{ - CPU: int(pb.Cpu), - MemoryMB: int(pb.MemoryMB), - DiskMB: int(pb.DiskMB), - IOPS: int(pb.Iops), - } -} diff --git a/plugins/drivers/utils.go b/plugins/drivers/utils.go index d8ea6f605..a72b79115 100644 --- a/plugins/drivers/utils.go +++ b/plugins/drivers/utils.go @@ -56,7 +56,7 @@ func taskConfigFromProto(pb *proto.TaskConfig) *TaskConfig { Name: pb.Name, Env: pb.Env, rawDriverConfig: pb.MsgpackDriverConfig, - Resources: resourcesFromProto(pb.Resources), + Resources: ResourcesFromProto(pb.Resources), Devices: devicesFromProto(pb.Devices), Mounts: mountsFromProto(pb.Mounts), User: pb.User, @@ -77,7 +77,7 @@ func taskConfigToProto(cfg *TaskConfig) *proto.TaskConfig { TaskGroupName: cfg.TaskGroupName, Name: cfg.Name, Env: cfg.Env, - Resources: resourcesToProto(cfg.Resources), + Resources: ResourcesToProto(cfg.Resources), Devices: devicesToProto(cfg.Devices), Mounts: mountsToProto(cfg.Mounts), User: cfg.User, @@ -90,7 +90,7 @@ func taskConfigToProto(cfg *TaskConfig) *proto.TaskConfig { return pb } -func resourcesFromProto(pb *proto.Resources) *Resources { +func ResourcesFromProto(pb *proto.Resources) *Resources { var r Resources if pb == nil { return &r @@ -142,7 +142,7 @@ func resourcesFromProto(pb *proto.Resources) *Resources { return &r } -func resourcesToProto(r *Resources) *proto.Resources { +func ResourcesToProto(r *Resources) *proto.Resources { if r == nil { return nil } From ff1990064bc65ad3b1188754e3f4814bc2afaa6f Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Thu, 6 Dec 2018 21:33:20 -0500 Subject: [PATCH 07/13] executor: fix broken non-linux build --- drivers/shared/executor/executor_basic.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/shared/executor/executor_basic.go b/drivers/shared/executor/executor_basic.go index ccd5172ff..e34c3682b 100644 --- a/drivers/shared/executor/executor_basic.go +++ b/drivers/shared/executor/executor_basic.go @@ -4,10 +4,9 @@ package executor import ( hclog "github.com/hashicorp/go-hclog" - "github.com/hashicorp/nomad/drivers/shared/executor/structs" ) -func NewExecutorWithIsolation(logger hclog.Logger) structs.Executor { +func NewExecutorWithIsolation(logger hclog.Logger) Executor { logger = logger.Named("executor") logger.Error("isolation executor is not supported on this platform, using default") return NewExecutor(logger) From 9e3c2492e55e23a3de2c251d372d342272a8cea9 Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Thu, 6 Dec 2018 21:39:53 -0500 Subject: [PATCH 08/13] executor: fix tests --- drivers/exec/driver.go | 15 +-------------- drivers/java/driver.go | 12 ++++-------- drivers/rkt/driver.go | 14 +++++--------- drivers/shared/executor/executor_linux_test.go | 10 ++++------ drivers/shared/executor/executor_test.go | 8 +++----- 5 files changed, 17 insertions(+), 42 deletions(-) diff --git a/drivers/exec/driver.go b/drivers/exec/driver.go index da9174829..072d7f69f 100644 --- a/drivers/exec/driver.go +++ b/drivers/exec/driver.go @@ -303,7 +303,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru Env: cfg.EnvList(), User: cfg.User, ResourceLimits: true, - Resources: toExecResources(cfg.Resources), + Resources: cfg.Resources, TaskDir: cfg.TaskDir().Dir, StdoutPath: cfg.StdoutPath, StderrPath: cfg.StderrPath, @@ -344,19 +344,6 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru return handle, nil, nil } -func toExecResources(resources *drivers.Resources) *executor.Resources { - if resources == nil || resources.NomadResources == nil { - return nil - } - - return &executor.Resources{ - CPU: resources.NomadResources.CPU, - MemoryMB: resources.NomadResources.MemoryMB, - DiskMB: resources.NomadResources.DiskMB, - } - -} - func (d *Driver) WaitTask(ctx context.Context, taskID string) (<-chan *drivers.ExitResult, error) { handle, ok := d.tasks.Get(taskID) if !ok { diff --git a/drivers/java/driver.go b/drivers/java/driver.go index 18250bad5..793010c36 100644 --- a/drivers/java/driver.go +++ b/drivers/java/driver.go @@ -334,14 +334,10 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru Env: cfg.EnvList(), User: cfg.User, ResourceLimits: true, - Resources: &executor.Resources{ - CPU: cfg.Resources.NomadResources.CPU, - MemoryMB: cfg.Resources.NomadResources.MemoryMB, - DiskMB: cfg.Resources.NomadResources.DiskMB, - }, - TaskDir: cfg.TaskDir().Dir, - StdoutPath: cfg.StdoutPath, - StderrPath: cfg.StderrPath, + Resources: cfg.Resources, + TaskDir: cfg.TaskDir().Dir, + StdoutPath: cfg.StdoutPath, + StderrPath: cfg.StderrPath, } ps, err := exec.Launch(execCmd) diff --git a/drivers/rkt/driver.go b/drivers/rkt/driver.go index a022db9fb..9cb7cec03 100644 --- a/drivers/rkt/driver.go +++ b/drivers/rkt/driver.go @@ -645,15 +645,11 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru Cmd: absPath, Args: runArgs, ResourceLimits: true, - Resources: &executor.Resources{ - CPU: int(cfg.Resources.LinuxResources.CPUShares), - MemoryMB: int(drivers.BytesToMB(cfg.Resources.LinuxResources.MemoryLimitBytes)), - DiskMB: cfg.Resources.NomadResources.DiskMB, - }, - Env: cfg.EnvList(), - TaskDir: cfg.TaskDir().Dir, - StdoutPath: cfg.StdoutPath, - StderrPath: cfg.StderrPath, + Resources: cfg.Resources, + Env: cfg.EnvList(), + TaskDir: cfg.TaskDir().Dir, + StdoutPath: cfg.StdoutPath, + StderrPath: cfg.StderrPath, } ps, err := execImpl.Launch(execCmd) if err != nil { diff --git a/drivers/shared/executor/executor_linux_test.go b/drivers/shared/executor/executor_linux_test.go index e11e9d5df..6f29d72f8 100644 --- a/drivers/shared/executor/executor_linux_test.go +++ b/drivers/shared/executor/executor_linux_test.go @@ -18,6 +18,7 @@ import ( "github.com/hashicorp/nomad/client/testutil" "github.com/hashicorp/nomad/helper/testlog" "github.com/hashicorp/nomad/nomad/mock" + "github.com/hashicorp/nomad/plugins/drivers" tu "github.com/hashicorp/nomad/testutil" "github.com/stretchr/testify/require" ) @@ -65,11 +66,8 @@ func testExecutorCommandWithChroot(t *testing.T) (*ExecCommand, *allocdir.AllocD cmd := &ExecCommand{ Env: taskEnv.List(), TaskDir: td.Dir, - Resources: &Resources{ - CPU: task.Resources.CPU, - MemoryMB: task.Resources.MemoryMB, - IOPS: task.Resources.IOPS, - DiskMB: task.Resources.DiskMB, + Resources: &drivers.Resources{ + NomadResources: task.Resources, }, } configureTLogging(cmd) @@ -109,7 +107,7 @@ func TestExecutor_IsolationAndConstraints(t *testing.T) { data, err := ioutil.ReadFile(memLimits) require.NoError(err) - expectedMemLim := strconv.Itoa(execCmd.Resources.MemoryMB * 1024 * 1024) + expectedMemLim := strconv.Itoa(execCmd.Resources.NomadResources.MemoryMB * 1024 * 1024) actualMemLim := strings.TrimSpace(string(data)) require.Equal(actualMemLim, expectedMemLim) require.NoError(executor.Shutdown("", 0)) diff --git a/drivers/shared/executor/executor_test.go b/drivers/shared/executor/executor_test.go index 26067ebc8..a3b5d49d6 100644 --- a/drivers/shared/executor/executor_test.go +++ b/drivers/shared/executor/executor_test.go @@ -12,6 +12,7 @@ import ( "testing" "time" + "github.com/hashicorp/nomad/plugins/drivers" tu "github.com/hashicorp/nomad/testutil" hclog "github.com/hashicorp/go-hclog" @@ -52,11 +53,8 @@ func testExecutorCommand(t *testing.T) (*ExecCommand, *allocdir.AllocDir) { cmd := &ExecCommand{ Env: taskEnv.List(), TaskDir: td.Dir, - Resources: &Resources{ - CPU: task.Resources.CPU, - MemoryMB: task.Resources.MemoryMB, - IOPS: task.Resources.IOPS, - DiskMB: task.Resources.DiskMB, + Resources: &drivers.Resources{ + NomadResources: task.Resources, }, } configureTLogging(cmd) From a6cb63a96489e951ab4ed6202cde3ab19def679b Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Fri, 7 Dec 2018 14:03:13 -0500 Subject: [PATCH 09/13] executor: don't drop errors when configuring libcontainer cfg, add nil check on resources --- drivers/exec/driver_test.go | 1 - drivers/shared/executor/executor_linux.go | 40 ++++++++++++++++++----- plugins/drivers/testutils/testing.go | 2 ++ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/drivers/exec/driver_test.go b/drivers/exec/driver_test.go index ea4b58d28..3832aafdb 100644 --- a/drivers/exec/driver_test.go +++ b/drivers/exec/driver_test.go @@ -95,7 +95,6 @@ func TestExecDriver_StartWait(t *testing.T) { cleanup := harness.MkAllocDir(task, false) defer cleanup() - fmt.Println(task.AllocDir) handle, _, err := harness.StartTask(task) require.NoError(err) diff --git a/drivers/shared/executor/executor_linux.go b/drivers/shared/executor/executor_linux.go index 9e94723f5..0008c9c25 100644 --- a/drivers/shared/executor/executor_linux.go +++ b/drivers/shared/executor/executor_linux.go @@ -22,6 +22,7 @@ import ( "github.com/hashicorp/nomad/helper/discover" shelpers "github.com/hashicorp/nomad/helper/stats" "github.com/hashicorp/nomad/helper/uuid" + "github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/nomad/plugins/drivers" "github.com/opencontainers/runc/libcontainer" "github.com/opencontainers/runc/libcontainer/cgroups" @@ -102,7 +103,9 @@ func (l *LibcontainerExecutor) Launch(command *ExecCommand) (*ProcessState, erro } if command.Resources == nil { - command.Resources = &drivers.Resources{} + command.Resources = &drivers.Resources{ + NomadResources: &structs.Resources{}, + } } l.command = command @@ -127,7 +130,12 @@ func (l *LibcontainerExecutor) Launch(command *ExecCommand) (*ProcessState, erro } // A container groups processes under the same isolation enforcement - container, err := factory.Create(l.id, newLibcontainerConfig(command)) + containerCfg, err := newLibcontainerConfig(command) + if err != nil { + return nil, fmt.Errorf("failed to configure container(%s): %v", l.id, err) + } + + container, err := factory.Create(l.id, containerCfg) if err != nil { return nil, fmt.Errorf("failed to create container(%s): %v", l.id, err) } @@ -458,7 +466,7 @@ func (l *LibcontainerExecutor) handleExecWait(ch chan *waitResult, process *libc ch <- &waitResult{ps, err} } -func configureCapabilities(cfg *lconfigs.Config, command *ExecCommand) { +func configureCapabilities(cfg *lconfigs.Config, command *ExecCommand) error { // TODO: allow better control of these cfg.Capabilities = &lconfigs.Capabilities{ Bounding: allCaps, @@ -468,9 +476,10 @@ func configureCapabilities(cfg *lconfigs.Config, command *ExecCommand) { Effective: allCaps, } + return nil } -func configureIsolation(cfg *lconfigs.Config, command *ExecCommand) { +func configureIsolation(cfg *lconfigs.Config, command *ExecCommand) error { defaultMountFlags := syscall.MS_NOEXEC | syscall.MS_NOSUID | syscall.MS_NODEV // set the new root directory for the container @@ -534,6 +543,8 @@ func configureIsolation(cfg *lconfigs.Config, command *ExecCommand) { Flags: defaultMountFlags | syscall.MS_RDONLY, }, } + + return nil } func configureCgroups(cfg *lconfigs.Config, command *ExecCommand) error { @@ -545,6 +556,11 @@ func configureCgroups(cfg *lconfigs.Config, command *ExecCommand) error { id := uuid.Generate() cfg.Cgroups.Path = filepath.Join(defaultCgroupParent, id) + + if command.Resources == nil || command.Resources.NomadResources == nil { + return nil + } + if command.Resources.NomadResources.MemoryMB > 0 { // Total amount of memory allowed to consume cfg.Cgroups.Resources.Memory = int64(command.Resources.NomadResources.MemoryMB * 1024 * 1024) @@ -594,7 +610,7 @@ func configureBasicCgroups(cfg *lconfigs.Config) error { return nil } -func newLibcontainerConfig(command *ExecCommand) *lconfigs.Config { +func newLibcontainerConfig(command *ExecCommand) (*lconfigs.Config, error) { cfg := &lconfigs.Config{ Cgroups: &lconfigs.Cgroup{ Resources: &lconfigs.Resources{ @@ -606,10 +622,16 @@ func newLibcontainerConfig(command *ExecCommand) *lconfigs.Config { Version: "1.0.0", } - configureCapabilities(cfg, command) - configureIsolation(cfg, command) - configureCgroups(cfg, command) - return cfg + if err := configureCapabilities(cfg, command); err != nil { + return nil, err + } + if err := configureIsolation(cfg, command); err != nil { + return nil, err + } + if err := configureCgroups(cfg, command); err != nil { + return nil, err + } + return cfg, nil } // JoinRootCgroup moves the current process to the cgroups of the init process diff --git a/plugins/drivers/testutils/testing.go b/plugins/drivers/testutils/testing.go index 39dafa2e9..d8d0b354f 100644 --- a/plugins/drivers/testutils/testing.go +++ b/plugins/drivers/testutils/testing.go @@ -150,6 +150,7 @@ func (h *DriverHarness) MkAllocDir(t *drivers.TaskConfig, enableLogs bool) func( return func() { h.lm.Stop() + h.client.Close() allocDir.Destroy() } } @@ -158,6 +159,7 @@ func (h *DriverHarness) MkAllocDir(t *drivers.TaskConfig, enableLogs bool) func( if h.lm != nil { h.lm.Stop() } + h.client.Close() allocDir.Destroy() } } From 4243b7d5f3fed4abe33b41d07e1801e37ec2571f Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Sat, 8 Dec 2018 01:52:06 -0500 Subject: [PATCH 10/13] executor: misspell --- drivers/shared/executor/executor_plugin.go | 2 +- drivers/shared/executor/utils.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/shared/executor/executor_plugin.go b/drivers/shared/executor/executor_plugin.go index a7a85d5a3..10337c6cc 100644 --- a/drivers/shared/executor/executor_plugin.go +++ b/drivers/shared/executor/executor_plugin.go @@ -10,7 +10,7 @@ import ( ) type ExecutorPlugin struct { - // TODO: support backwards compatability with pre 0.9 NetRPC plugin + // TODO: support backwards compatibility with pre 0.9 NetRPC plugin plugin.NetRPCUnsupportedPlugin logger hclog.Logger fsIsolation bool diff --git a/drivers/shared/executor/utils.go b/drivers/shared/executor/utils.go index 36dc1f783..c23c9d3b8 100644 --- a/drivers/shared/executor/utils.go +++ b/drivers/shared/executor/utils.go @@ -79,7 +79,7 @@ func CreateExecutorWithConfig(config *plugin.ClientConfig, w io.Writer) (Executo // Setting this to DEBUG since the log level at the executor server process // is already set, and this effects only the executor client. - // TODO: Use versioned plugin map to support backwards compatability with + // TODO: Use versioned plugin map to support backwards compatibility with // existing pre-0.9 executors config.Plugins = GetPluginMap(w, hclog.Debug, false) config.AllowedProtocols = []plugin.Protocol{plugin.ProtocolGRPC} From c8a3c0e96ef9786089fdb3123b5cbf5907059a9b Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Fri, 14 Dec 2018 22:20:01 -0500 Subject: [PATCH 11/13] executor: use int when encoding signal in RPC --- drivers/shared/executor/client.go | 8 +- drivers/shared/executor/proto/executor.pb.go | 144 +++++++++---------- drivers/shared/executor/proto/executor.proto | 2 +- drivers/shared/executor/server.go | 13 +- 4 files changed, 85 insertions(+), 82 deletions(-) diff --git a/drivers/shared/executor/client.go b/drivers/shared/executor/client.go index d0ce617c2..918431bc0 100644 --- a/drivers/shared/executor/client.go +++ b/drivers/shared/executor/client.go @@ -2,7 +2,9 @@ package executor import ( "context" + "fmt" "os" + "syscall" "time" "github.com/LK4D4/joincontext" @@ -113,8 +115,12 @@ func (c *grpcExecutorClient) Stats() (*cstructs.TaskResourceUsage, error) { func (c *grpcExecutorClient) Signal(s os.Signal) error { ctx := context.Background() + sig, ok := s.(syscall.Signal) + if !ok { + return fmt.Errorf("unsupported signal type: %q", s.String()) + } req := &proto.SignalRequest{ - Signal: s.String(), + Signal: int32(sig), } if _, err := c.client.Signal(ctx, req); err != nil { return err diff --git a/drivers/shared/executor/proto/executor.pb.go b/drivers/shared/executor/proto/executor.pb.go index a6063abbd..a076d0f18 100644 --- a/drivers/shared/executor/proto/executor.pb.go +++ b/drivers/shared/executor/proto/executor.pb.go @@ -45,7 +45,7 @@ func (m *LaunchRequest) Reset() { *m = LaunchRequest{} } func (m *LaunchRequest) String() string { return proto.CompactTextString(m) } func (*LaunchRequest) ProtoMessage() {} func (*LaunchRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{0} + return fileDescriptor_executor_47d1ec212828d159, []int{0} } func (m *LaunchRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_LaunchRequest.Unmarshal(m, b) @@ -146,7 +146,7 @@ func (m *LaunchResponse) Reset() { *m = LaunchResponse{} } func (m *LaunchResponse) String() string { return proto.CompactTextString(m) } func (*LaunchResponse) ProtoMessage() {} func (*LaunchResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{1} + return fileDescriptor_executor_47d1ec212828d159, []int{1} } func (m *LaunchResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_LaunchResponse.Unmarshal(m, b) @@ -183,7 +183,7 @@ func (m *WaitRequest) Reset() { *m = WaitRequest{} } func (m *WaitRequest) String() string { return proto.CompactTextString(m) } func (*WaitRequest) ProtoMessage() {} func (*WaitRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{2} + return fileDescriptor_executor_47d1ec212828d159, []int{2} } func (m *WaitRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_WaitRequest.Unmarshal(m, b) @@ -214,7 +214,7 @@ func (m *WaitResponse) Reset() { *m = WaitResponse{} } func (m *WaitResponse) String() string { return proto.CompactTextString(m) } func (*WaitResponse) ProtoMessage() {} func (*WaitResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{3} + return fileDescriptor_executor_47d1ec212828d159, []int{3} } func (m *WaitResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_WaitResponse.Unmarshal(m, b) @@ -253,7 +253,7 @@ func (m *ShutdownRequest) Reset() { *m = ShutdownRequest{} } func (m *ShutdownRequest) String() string { return proto.CompactTextString(m) } func (*ShutdownRequest) ProtoMessage() {} func (*ShutdownRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{4} + return fileDescriptor_executor_47d1ec212828d159, []int{4} } func (m *ShutdownRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ShutdownRequest.Unmarshal(m, b) @@ -297,7 +297,7 @@ func (m *ShutdownResponse) Reset() { *m = ShutdownResponse{} } func (m *ShutdownResponse) String() string { return proto.CompactTextString(m) } func (*ShutdownResponse) ProtoMessage() {} func (*ShutdownResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{5} + return fileDescriptor_executor_47d1ec212828d159, []int{5} } func (m *ShutdownResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ShutdownResponse.Unmarshal(m, b) @@ -328,7 +328,7 @@ func (m *UpdateResourcesRequest) Reset() { *m = UpdateResourcesRequest{} func (m *UpdateResourcesRequest) String() string { return proto.CompactTextString(m) } func (*UpdateResourcesRequest) ProtoMessage() {} func (*UpdateResourcesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{6} + return fileDescriptor_executor_47d1ec212828d159, []int{6} } func (m *UpdateResourcesRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UpdateResourcesRequest.Unmarshal(m, b) @@ -365,7 +365,7 @@ func (m *UpdateResourcesResponse) Reset() { *m = UpdateResourcesResponse func (m *UpdateResourcesResponse) String() string { return proto.CompactTextString(m) } func (*UpdateResourcesResponse) ProtoMessage() {} func (*UpdateResourcesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{7} + return fileDescriptor_executor_47d1ec212828d159, []int{7} } func (m *UpdateResourcesResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UpdateResourcesResponse.Unmarshal(m, b) @@ -395,7 +395,7 @@ func (m *VersionRequest) Reset() { *m = VersionRequest{} } func (m *VersionRequest) String() string { return proto.CompactTextString(m) } func (*VersionRequest) ProtoMessage() {} func (*VersionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{8} + return fileDescriptor_executor_47d1ec212828d159, []int{8} } func (m *VersionRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_VersionRequest.Unmarshal(m, b) @@ -426,7 +426,7 @@ func (m *VersionResponse) Reset() { *m = VersionResponse{} } func (m *VersionResponse) String() string { return proto.CompactTextString(m) } func (*VersionResponse) ProtoMessage() {} func (*VersionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{9} + return fileDescriptor_executor_47d1ec212828d159, []int{9} } func (m *VersionResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_VersionResponse.Unmarshal(m, b) @@ -463,7 +463,7 @@ func (m *StatsRequest) Reset() { *m = StatsRequest{} } func (m *StatsRequest) String() string { return proto.CompactTextString(m) } func (*StatsRequest) ProtoMessage() {} func (*StatsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{10} + return fileDescriptor_executor_47d1ec212828d159, []int{10} } func (m *StatsRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_StatsRequest.Unmarshal(m, b) @@ -494,7 +494,7 @@ func (m *StatsResponse) Reset() { *m = StatsResponse{} } func (m *StatsResponse) String() string { return proto.CompactTextString(m) } func (*StatsResponse) ProtoMessage() {} func (*StatsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{11} + return fileDescriptor_executor_47d1ec212828d159, []int{11} } func (m *StatsResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_StatsResponse.Unmarshal(m, b) @@ -522,7 +522,7 @@ func (m *StatsResponse) GetStats() *proto1.TaskStats { } type SignalRequest struct { - Signal string `protobuf:"bytes,1,opt,name=signal,proto3" json:"signal,omitempty"` + Signal int32 `protobuf:"varint,1,opt,name=signal,proto3" json:"signal,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -532,7 +532,7 @@ func (m *SignalRequest) Reset() { *m = SignalRequest{} } func (m *SignalRequest) String() string { return proto.CompactTextString(m) } func (*SignalRequest) ProtoMessage() {} func (*SignalRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{12} + return fileDescriptor_executor_47d1ec212828d159, []int{12} } func (m *SignalRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalRequest.Unmarshal(m, b) @@ -552,11 +552,11 @@ func (m *SignalRequest) XXX_DiscardUnknown() { var xxx_messageInfo_SignalRequest proto.InternalMessageInfo -func (m *SignalRequest) GetSignal() string { +func (m *SignalRequest) GetSignal() int32 { if m != nil { return m.Signal } - return "" + return 0 } type SignalResponse struct { @@ -569,7 +569,7 @@ func (m *SignalResponse) Reset() { *m = SignalResponse{} } func (m *SignalResponse) String() string { return proto.CompactTextString(m) } func (*SignalResponse) ProtoMessage() {} func (*SignalResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{13} + return fileDescriptor_executor_47d1ec212828d159, []int{13} } func (m *SignalResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalResponse.Unmarshal(m, b) @@ -602,7 +602,7 @@ func (m *ExecRequest) Reset() { *m = ExecRequest{} } func (m *ExecRequest) String() string { return proto.CompactTextString(m) } func (*ExecRequest) ProtoMessage() {} func (*ExecRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{14} + return fileDescriptor_executor_47d1ec212828d159, []int{14} } func (m *ExecRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ExecRequest.Unmarshal(m, b) @@ -655,7 +655,7 @@ func (m *ExecResponse) Reset() { *m = ExecResponse{} } func (m *ExecResponse) String() string { return proto.CompactTextString(m) } func (*ExecResponse) ProtoMessage() {} func (*ExecResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{15} + return fileDescriptor_executor_47d1ec212828d159, []int{15} } func (m *ExecResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ExecResponse.Unmarshal(m, b) @@ -703,7 +703,7 @@ func (m *ProcessState) Reset() { *m = ProcessState{} } func (m *ProcessState) String() string { return proto.CompactTextString(m) } func (*ProcessState) ProtoMessage() {} func (*ProcessState) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_ac624d46b225110f, []int{16} + return fileDescriptor_executor_47d1ec212828d159, []int{16} } func (m *ProcessState) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ProcessState.Unmarshal(m, b) @@ -1075,61 +1075,61 @@ var _Executor_serviceDesc = grpc.ServiceDesc{ } func init() { - proto.RegisterFile("drivers/shared/executor/proto/executor.proto", fileDescriptor_executor_ac624d46b225110f) + proto.RegisterFile("drivers/shared/executor/proto/executor.proto", fileDescriptor_executor_47d1ec212828d159) } -var fileDescriptor_executor_ac624d46b225110f = []byte{ - // 826 bytes of a gzipped FileDescriptorProto +var fileDescriptor_executor_47d1ec212828d159 = []byte{ + // 827 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x4b, 0x6f, 0xe4, 0x44, 0x10, 0x5e, 0xcf, 0x7b, 0x6a, 0x9e, 0x6a, 0xa1, 0xe0, 0x35, 0x87, 0x1d, 0x7c, 0x60, 0x47, 0x02, 0xd9, 0xab, 0xec, 0x8b, 0x0b, 0x20, 0x11, 0x96, 0x53, 0xb4, 0x8a, 0x9c, 0x85, 0x95, 0x38, 0x30, - 0x74, 0xec, 0xc6, 0x6e, 0x65, 0xc6, 0x6d, 0xba, 0xdb, 0x43, 0x22, 0x21, 0x71, 0xe2, 0x1f, 0xf0, - 0x0f, 0xf9, 0x13, 0x1c, 0x91, 0xfb, 0xe1, 0xcc, 0x24, 0x10, 0x3c, 0xa0, 0x3d, 0xb9, 0xab, 0x5c, - 0x55, 0x5f, 0x55, 0xf7, 0x57, 0x1f, 0x7c, 0x92, 0x70, 0xba, 0x25, 0x5c, 0x84, 0x22, 0xc3, 0x9c, - 0x24, 0x21, 0xb9, 0x22, 0x71, 0x29, 0x19, 0x0f, 0x0b, 0xce, 0x24, 0xab, 0xcd, 0x40, 0x99, 0xe8, - 0xa3, 0x0c, 0x8b, 0x8c, 0xc6, 0x8c, 0x17, 0x41, 0xce, 0x36, 0x38, 0x09, 0x8a, 0x75, 0x99, 0xd2, - 0x5c, 0x04, 0xfb, 0x71, 0xde, 0xa3, 0x94, 0xb1, 0x74, 0x4d, 0x74, 0x91, 0x8b, 0xf2, 0xc7, 0x50, - 0xd2, 0x0d, 0x11, 0x12, 0x6f, 0x0a, 0x13, 0xf0, 0x59, 0x4a, 0x65, 0x56, 0x5e, 0x04, 0x31, 0xdb, - 0x84, 0x75, 0xcd, 0x50, 0xd5, 0x0c, 0x4d, 0xcd, 0xd0, 0x76, 0xa6, 0x3b, 0xd1, 0x96, 0x4e, 0xf7, - 0xff, 0x68, 0xc1, 0xe4, 0x14, 0x97, 0x79, 0x9c, 0x45, 0xe4, 0xa7, 0x92, 0x08, 0x89, 0xe6, 0xd0, - 0x8e, 0x37, 0x89, 0xeb, 0x2c, 0x9c, 0xe5, 0x30, 0xaa, 0x8e, 0x08, 0x41, 0x07, 0xf3, 0x54, 0xb8, - 0xad, 0x45, 0x7b, 0x39, 0x8c, 0xd4, 0x19, 0xbd, 0x86, 0x21, 0x27, 0x82, 0x95, 0x3c, 0x26, 0xc2, - 0x6d, 0x2f, 0x9c, 0xe5, 0xe8, 0xf8, 0x49, 0xf0, 0x4f, 0x33, 0x19, 0x7c, 0x0d, 0x19, 0x44, 0x36, - 0x2f, 0xba, 0x29, 0x81, 0x1e, 0xc1, 0x48, 0xc8, 0x84, 0x95, 0x72, 0x55, 0x60, 0x99, 0xb9, 0x1d, - 0x85, 0x0e, 0xda, 0x75, 0x86, 0x65, 0x66, 0x02, 0x08, 0xe7, 0x3a, 0xa0, 0x5b, 0x07, 0x10, 0xce, - 0x55, 0xc0, 0x1c, 0xda, 0x24, 0xdf, 0xba, 0x3d, 0xd5, 0x64, 0x75, 0xac, 0xfa, 0x2e, 0x05, 0xe1, - 0x6e, 0x5f, 0xc5, 0xaa, 0x33, 0x7a, 0x08, 0x03,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0xf2, 0x27, 0x38, 0x22, 0xf7, 0xc3, 0x99, 0x49, 0x42, 0xe4, 0x01, 0xed, 0xc9, 0x5d, 0xe5, + 0xaa, 0xef, 0xab, 0xea, 0xae, 0xfa, 0xe0, 0xb3, 0x84, 0xd3, 0x2d, 0xe1, 0x22, 0x14, 0x19, 0xe6, + 0x24, 0x09, 0xc9, 0x15, 0x89, 0x4b, 0xc9, 0x78, 0x58, 0x70, 0x26, 0x59, 0x6d, 0x06, 0xca, 0x44, + 0x9f, 0x64, 0x58, 0x64, 0x34, 0x66, 0xbc, 0x08, 0x72, 0xb6, 0xc1, 0x49, 0x50, 0xac, 0xcb, 0x94, + 0xe6, 0x22, 0xd8, 0x8f, 0xf3, 0x1e, 0xa5, 0x8c, 0xa5, 0x6b, 0xa2, 0x41, 0x2e, 0xca, 0x9f, 0x43, + 0x49, 0x37, 0x44, 0x48, 0xbc, 0x29, 0x4c, 0xc0, 0x17, 0x29, 0x95, 0x59, 0x79, 0x11, 0xc4, 0x6c, + 0x13, 0xd6, 0x98, 0xa1, 0xc2, 0x0c, 0x0d, 0x66, 0x68, 0x2b, 0xd3, 0x95, 0x68, 0x4b, 0xa7, 0xfb, + 0x7f, 0xb5, 0x60, 0x72, 0x8a, 0xcb, 0x3c, 0xce, 0x22, 0xf2, 0x4b, 0x49, 0x84, 0x44, 0x73, 0x68, + 0xc7, 0x9b, 0xc4, 0x75, 0x16, 0xce, 0x72, 0x18, 0x55, 0x47, 0x84, 0xa0, 0x83, 0x79, 0x2a, 0xdc, + 0xd6, 0xa2, 0xbd, 0x1c, 0x46, 0xea, 0x8c, 0x5e, 0xc3, 0x90, 0x13, 0xc1, 0x4a, 0x1e, 0x13, 0xe1, + 0xb6, 0x17, 0xce, 0x72, 0x74, 0xfc, 0x24, 0xf8, 0xb7, 0x9e, 0x0c, 0xbf, 0xa6, 0x0c, 0x22, 0x9b, + 0x17, 0x5d, 0x43, 0xa0, 0x47, 0x30, 0x12, 0x32, 0x61, 0xa5, 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d, 0xa7, 0x7f, 0x57, + 0xb5, 0xfc, 0x07, 0x5f, 0xf7, 0x7f, 0xe8, 0x6a, 0x59, 0xe8, 0xa9, 0xcf, 0xd3, 0x7f, 0x02, 0x00, + 0x00, 0xff, 0xff, 0x6b, 0xfb, 0xa5, 0x9a, 0xfd, 0x09, 0x00, 0x00, } diff --git a/drivers/shared/executor/proto/executor.proto b/drivers/shared/executor/proto/executor.proto index 4d81ce894..0ce382903 100644 --- a/drivers/shared/executor/proto/executor.proto +++ b/drivers/shared/executor/proto/executor.proto @@ -65,7 +65,7 @@ message StatsResponse { } message SignalRequest { - string signal = 1; + int32 signal = 1; } message SignalResponse {} diff --git a/drivers/shared/executor/server.go b/drivers/shared/executor/server.go index 9a5625808..2900334e7 100644 --- a/drivers/shared/executor/server.go +++ b/drivers/shared/executor/server.go @@ -1,11 +1,10 @@ package executor import ( - "fmt" + "syscall" "time" "github.com/golang/protobuf/ptypes" - "github.com/hashicorp/consul-template/signals" "github.com/hashicorp/nomad/drivers/shared/executor/proto" "github.com/hashicorp/nomad/plugins/drivers" "golang.org/x/net/context" @@ -103,13 +102,11 @@ func (s *grpcExecutorServer) Stats(context.Context, *proto.StatsRequest) (*proto } func (s *grpcExecutorServer) Signal(ctx context.Context, req *proto.SignalRequest) (*proto.SignalResponse, error) { - if sig, ok := signals.SignalLookup[req.Signal]; ok { - if err := s.impl.Signal(sig); err != nil { - return nil, err - } - return &proto.SignalResponse{}, nil + sig := syscall.Signal(req.Signal) + if err := s.impl.Signal(sig); err != nil { + return nil, err } - return nil, fmt.Errorf("invalid signal sent by client") + return &proto.SignalResponse{}, nil } func (s *grpcExecutorServer) Exec(ctx context.Context, req *proto.ExecRequest) (*proto.ExecResponse, error) { From d0efb72846ba6e9035ccea4b2f955bd8f6245129 Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Fri, 14 Dec 2018 23:40:37 -0500 Subject: [PATCH 12/13] rawexec: fix misleading log --- drivers/rawexec/driver.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/rawexec/driver.go b/drivers/rawexec/driver.go index 34bffe1d3..d839df7fe 100644 --- a/drivers/rawexec/driver.go +++ b/drivers/rawexec/driver.go @@ -477,8 +477,9 @@ func (d *Driver) SignalTask(taskID string, signal string) error { sig := os.Interrupt if s, ok := signals.SignalLookup[signal]; ok { - d.logger.Warn("signal to send to task unknown, using SIGINT", "signal", signal, "task_id", handle.taskConfig.ID) sig = s + } else { + d.logger.Warn("signal to send to task unknown, using SIGINT", "signal", signal, "task_id", handle.taskConfig.ID) } return handle.exec.Signal(sig) } From 81ba18d74a2e7722f879756ac960e7a849c331c6 Mon Sep 17 00:00:00 2001 From: Nick Ethier Date: Sat, 15 Dec 2018 00:08:23 -0500 Subject: [PATCH 13/13] executor: encode mounts and devices correctly when using grpc --- drivers/docker/driver_test.go | 2 +- drivers/shared/executor/client.go | 2 + drivers/shared/executor/proto/executor.pb.go | 163 +++++++++++-------- drivers/shared/executor/proto/executor.proto | 2 + drivers/shared/executor/server.go | 2 + plugins/drivers/utils.go | 32 ++-- 6 files changed, 114 insertions(+), 89 deletions(-) diff --git a/drivers/docker/driver_test.go b/drivers/docker/driver_test.go index d49514860..4aaf17817 100644 --- a/drivers/docker/driver_test.go +++ b/drivers/docker/driver_test.go @@ -1849,9 +1849,9 @@ func TestDockerDriver_Mounts(t *testing.T) { }, } - d := dockerDriverHarness(t, nil) for _, c := range cases { t.Run(c.Name, func(t *testing.T) { + d := dockerDriverHarness(t, nil) // Build the task task, cfg, _ := dockerTask(t) cfg.Command = "/bin/sleep" diff --git a/drivers/shared/executor/client.go b/drivers/shared/executor/client.go index 918431bc0..063e30dec 100644 --- a/drivers/shared/executor/client.go +++ b/drivers/shared/executor/client.go @@ -36,6 +36,8 @@ func (c *grpcExecutorClient) Launch(cmd *ExecCommand) (*ProcessState, error) { TaskDir: cmd.TaskDir, ResourceLimits: cmd.ResourceLimits, BasicProcessCgroup: cmd.BasicProcessCgroup, + Mounts: drivers.MountsToProto(cmd.Mounts), + Devices: drivers.DevicesToProto(cmd.Devices), } resp, err := c.client.Launch(ctx, req) if err != nil { diff --git a/drivers/shared/executor/proto/executor.pb.go b/drivers/shared/executor/proto/executor.pb.go index a076d0f18..6f57a0263 100644 --- a/drivers/shared/executor/proto/executor.pb.go +++ b/drivers/shared/executor/proto/executor.pb.go @@ -36,6 +36,8 @@ type LaunchRequest struct { TaskDir string `protobuf:"bytes,8,opt,name=task_dir,json=taskDir,proto3" json:"task_dir,omitempty"` ResourceLimits bool `protobuf:"varint,9,opt,name=resource_limits,json=resourceLimits,proto3" json:"resource_limits,omitempty"` BasicProcessCgroup bool `protobuf:"varint,10,opt,name=basic_process_cgroup,json=basicProcessCgroup,proto3" json:"basic_process_cgroup,omitempty"` + Mounts []*proto1.Mount `protobuf:"bytes,11,rep,name=mounts,proto3" json:"mounts,omitempty"` + Devices []*proto1.Device `protobuf:"bytes,12,rep,name=devices,proto3" json:"devices,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -45,7 +47,7 @@ func (m *LaunchRequest) Reset() { *m = LaunchRequest{} } func (m *LaunchRequest) String() string { return proto.CompactTextString(m) } func (*LaunchRequest) ProtoMessage() {} func (*LaunchRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{0} + return fileDescriptor_executor_b646d273b48eddd5, []int{0} } func (m *LaunchRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_LaunchRequest.Unmarshal(m, b) @@ -135,6 +137,20 @@ func (m *LaunchRequest) GetBasicProcessCgroup() bool { return false } +func (m *LaunchRequest) GetMounts() []*proto1.Mount { + if m != nil { + return m.Mounts + } + return nil +} + +func (m *LaunchRequest) GetDevices() []*proto1.Device { + if m != nil { + return m.Devices + } + return nil +} + type LaunchResponse struct { Process *ProcessState `protobuf:"bytes,1,opt,name=process,proto3" json:"process,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -146,7 +162,7 @@ func (m *LaunchResponse) Reset() { *m = LaunchResponse{} } func (m *LaunchResponse) String() string { return proto.CompactTextString(m) } func (*LaunchResponse) ProtoMessage() {} func (*LaunchResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{1} + return fileDescriptor_executor_b646d273b48eddd5, []int{1} } func (m *LaunchResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_LaunchResponse.Unmarshal(m, b) @@ -183,7 +199,7 @@ func (m *WaitRequest) Reset() { *m = WaitRequest{} } func (m *WaitRequest) String() string { return proto.CompactTextString(m) } func (*WaitRequest) ProtoMessage() {} func (*WaitRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{2} + return fileDescriptor_executor_b646d273b48eddd5, []int{2} } func (m *WaitRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_WaitRequest.Unmarshal(m, b) @@ -214,7 +230,7 @@ func (m *WaitResponse) Reset() { *m = WaitResponse{} } func (m *WaitResponse) String() string { return proto.CompactTextString(m) } func (*WaitResponse) ProtoMessage() {} func (*WaitResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{3} + return fileDescriptor_executor_b646d273b48eddd5, []int{3} } func (m *WaitResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_WaitResponse.Unmarshal(m, b) @@ -253,7 +269,7 @@ func (m *ShutdownRequest) Reset() { *m = ShutdownRequest{} } func (m *ShutdownRequest) String() string { return proto.CompactTextString(m) } func (*ShutdownRequest) ProtoMessage() {} func (*ShutdownRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{4} + return fileDescriptor_executor_b646d273b48eddd5, []int{4} } func (m *ShutdownRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ShutdownRequest.Unmarshal(m, b) @@ -297,7 +313,7 @@ func (m *ShutdownResponse) Reset() { *m = ShutdownResponse{} } func (m *ShutdownResponse) String() string { return proto.CompactTextString(m) } func (*ShutdownResponse) ProtoMessage() {} func (*ShutdownResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{5} + return fileDescriptor_executor_b646d273b48eddd5, []int{5} } func (m *ShutdownResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ShutdownResponse.Unmarshal(m, b) @@ -328,7 +344,7 @@ func (m *UpdateResourcesRequest) Reset() { *m = UpdateResourcesRequest{} func (m *UpdateResourcesRequest) String() string { return proto.CompactTextString(m) } func (*UpdateResourcesRequest) ProtoMessage() {} func (*UpdateResourcesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{6} + return fileDescriptor_executor_b646d273b48eddd5, []int{6} } func (m *UpdateResourcesRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UpdateResourcesRequest.Unmarshal(m, b) @@ -365,7 +381,7 @@ func (m *UpdateResourcesResponse) Reset() { *m = UpdateResourcesResponse func (m *UpdateResourcesResponse) String() string { return proto.CompactTextString(m) } func (*UpdateResourcesResponse) ProtoMessage() {} func (*UpdateResourcesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{7} + return fileDescriptor_executor_b646d273b48eddd5, []int{7} } func (m *UpdateResourcesResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UpdateResourcesResponse.Unmarshal(m, b) @@ -395,7 +411,7 @@ func (m *VersionRequest) Reset() { *m = VersionRequest{} } func (m *VersionRequest) String() string { return proto.CompactTextString(m) } func (*VersionRequest) ProtoMessage() {} func (*VersionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{8} + return fileDescriptor_executor_b646d273b48eddd5, []int{8} } func (m *VersionRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_VersionRequest.Unmarshal(m, b) @@ -426,7 +442,7 @@ func (m *VersionResponse) Reset() { *m = VersionResponse{} } func (m *VersionResponse) String() string { return proto.CompactTextString(m) } func (*VersionResponse) ProtoMessage() {} func (*VersionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{9} + return fileDescriptor_executor_b646d273b48eddd5, []int{9} } func (m *VersionResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_VersionResponse.Unmarshal(m, b) @@ -463,7 +479,7 @@ func (m *StatsRequest) Reset() { *m = StatsRequest{} } func (m *StatsRequest) String() string { return proto.CompactTextString(m) } func (*StatsRequest) ProtoMessage() {} func (*StatsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{10} + return fileDescriptor_executor_b646d273b48eddd5, []int{10} } func (m *StatsRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_StatsRequest.Unmarshal(m, b) @@ -494,7 +510,7 @@ func (m *StatsResponse) Reset() { *m = StatsResponse{} } func (m *StatsResponse) String() string { return proto.CompactTextString(m) } func (*StatsResponse) ProtoMessage() {} func (*StatsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{11} + return fileDescriptor_executor_b646d273b48eddd5, []int{11} } func (m *StatsResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_StatsResponse.Unmarshal(m, b) @@ -532,7 +548,7 @@ func (m *SignalRequest) Reset() { *m = SignalRequest{} } func (m *SignalRequest) String() string { return proto.CompactTextString(m) } func (*SignalRequest) ProtoMessage() {} func (*SignalRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{12} + return fileDescriptor_executor_b646d273b48eddd5, []int{12} } func (m *SignalRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalRequest.Unmarshal(m, b) @@ -569,7 +585,7 @@ func (m *SignalResponse) Reset() { *m = SignalResponse{} } func (m *SignalResponse) String() string { return proto.CompactTextString(m) } func (*SignalResponse) ProtoMessage() {} func (*SignalResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{13} + return fileDescriptor_executor_b646d273b48eddd5, []int{13} } func (m *SignalResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignalResponse.Unmarshal(m, b) @@ -602,7 +618,7 @@ func (m *ExecRequest) Reset() { *m = ExecRequest{} } func (m *ExecRequest) String() string { return proto.CompactTextString(m) } func (*ExecRequest) ProtoMessage() {} func (*ExecRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{14} + return fileDescriptor_executor_b646d273b48eddd5, []int{14} } func (m *ExecRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ExecRequest.Unmarshal(m, b) @@ -655,7 +671,7 @@ func (m *ExecResponse) Reset() { *m = ExecResponse{} } func (m *ExecResponse) String() string { return proto.CompactTextString(m) } func (*ExecResponse) ProtoMessage() {} func (*ExecResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{15} + return fileDescriptor_executor_b646d273b48eddd5, []int{15} } func (m *ExecResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ExecResponse.Unmarshal(m, b) @@ -703,7 +719,7 @@ func (m *ProcessState) Reset() { *m = ProcessState{} } func (m *ProcessState) String() string { return proto.CompactTextString(m) } func (*ProcessState) ProtoMessage() {} func (*ProcessState) Descriptor() ([]byte, []int) { - return fileDescriptor_executor_47d1ec212828d159, []int{16} + return fileDescriptor_executor_b646d273b48eddd5, []int{16} } func (m *ProcessState) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ProcessState.Unmarshal(m, b) @@ -1075,61 +1091,64 @@ var _Executor_serviceDesc = grpc.ServiceDesc{ } func init() { - proto.RegisterFile("drivers/shared/executor/proto/executor.proto", fileDescriptor_executor_47d1ec212828d159) + proto.RegisterFile("drivers/shared/executor/proto/executor.proto", fileDescriptor_executor_b646d273b48eddd5) } -var fileDescriptor_executor_47d1ec212828d159 = []byte{ - // 827 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x4b, 0x6f, 0xe4, 0x44, - 0x10, 0x5e, 0xcf, 0x7b, 0x6a, 0x9e, 0x6a, 0xa1, 0xe0, 0x35, 0x87, 0x1d, 0x7c, 0x60, 0x47, 0x02, - 0xd9, 0xab, 0xec, 0x8b, 0x0b, 0x20, 0x11, 0x96, 0x53, 0xb4, 0x8a, 0x9c, 0x85, 0x95, 0x38, 0x30, - 0x74, 0xec, 0xc6, 0x6e, 0x65, 0xc6, 0x6d, 0xba, 0xdb, 0x43, 0x56, 0x42, 0xe2, 0xc4, 0x3f, 0xe0, - 0x1f, 0xf2, 0x27, 0x38, 0x22, 0xf7, 0xc3, 0x99, 0x49, 0x42, 0xe4, 0x01, 0xed, 0xc9, 0x5d, 0xe5, - 0xaa, 0xef, 0xab, 0xea, 0xae, 0xfa, 0xe0, 0xb3, 0x84, 0xd3, 0x2d, 0xe1, 0x22, 0x14, 0x19, 0xe6, - 0x24, 0x09, 0xc9, 0x15, 0x89, 0x4b, 0xc9, 0x78, 0x58, 0x70, 0x26, 0x59, 0x6d, 0x06, 0xca, 0x44, - 0x9f, 0x64, 0x58, 0x64, 0x34, 0x66, 0xbc, 0x08, 0x72, 0xb6, 0xc1, 0x49, 0x50, 0xac, 0xcb, 0x94, - 0xe6, 0x22, 0xd8, 0x8f, 0xf3, 0x1e, 0xa5, 0x8c, 0xa5, 0x6b, 0xa2, 0x41, 0x2e, 0xca, 0x9f, 0x43, - 0x49, 0x37, 0x44, 0x48, 0xbc, 0x29, 0x4c, 0xc0, 0x17, 0x29, 0x95, 0x59, 0x79, 0x11, 0xc4, 0x6c, - 0x13, 0xd6, 0x98, 0xa1, 0xc2, 0x0c, 0x0d, 0x66, 0x68, 0x2b, 0xd3, 0x95, 0x68, 0x4b, 0xa7, 0xfb, - 0x7f, 0xb5, 0x60, 0x72, 0x8a, 0xcb, 0x3c, 0xce, 0x22, 0xf2, 0x4b, 0x49, 0x84, 0x44, 0x73, 0x68, - 0xc7, 0x9b, 0xc4, 0x75, 0x16, 0xce, 0x72, 0x18, 0x55, 0x47, 0x84, 0xa0, 0x83, 0x79, 0x2a, 0xdc, - 0xd6, 0xa2, 0xbd, 0x1c, 0x46, 0xea, 0x8c, 0x5e, 0xc3, 0x90, 0x13, 0xc1, 0x4a, 0x1e, 0x13, 0xe1, - 0xb6, 0x17, 0xce, 0x72, 0x74, 0xfc, 0x24, 0xf8, 0xb7, 0x9e, 0x0c, 0xbf, 0xa6, 0x0c, 0x22, 0x9b, - 0x17, 0x5d, 0x43, 0xa0, 0x47, 0x30, 0x12, 0x32, 0x61, 0xa5, 0x5c, 0x15, 0x58, 0x66, 0x6e, 0x47, - 0xb1, 0x83, 0x76, 0x9d, 0x61, 0x99, 0x99, 0x00, 0xc2, 0xb9, 0x0e, 0xe8, 0xd6, 0x01, 0x84, 0x73, - 0x15, 0x30, 0x87, 0x36, 0xc9, 0xb7, 0x6e, 0x4f, 0x15, 0x59, 0x1d, 0xab, 0xba, 0x4b, 0x41, 0xb8, - 0xdb, 0x57, 0xb1, 0xea, 0x8c, 0x1e, 0xc2, 0x40, 0x62, 0x71, 0xb9, 0x4a, 0x28, 0x77, 0x07, 0xca, - 0xdf, 0xaf, 0xec, 0x6f, 0x28, 0x47, 0x8f, 0x61, 0x66, 0xeb, 0x59, 0xad, 0xe9, 0x86, 0x4a, 0xe1, - 0x0e, 0x17, 0xce, 0x72, 0x10, 0x4d, 0xad, 0xfb, 0x54, 0x79, 0xd1, 0x13, 0xf8, 0xe0, 0x02, 0x0b, - 0x1a, 0xaf, 0x0a, 0xce, 0x62, 0x22, 0xc4, 0x2a, 0x4e, 0x39, 0x2b, 0x0b, 0x17, 0x54, 0x34, 0x52, - 0xff, 0xce, 0xf4, 0xaf, 0x13, 0xf5, 0xc7, 0xff, 0x09, 0xa6, 0xf6, 0x92, 0x45, 0xc1, 0x72, 0x41, - 0xd0, 0x6b, 0xe8, 0x9b, 0x6c, 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 0xeb, 0xb2, 0x7e, 0x83, 0xbe, 0xd1, 0x07, 0xd4, 0xf8, 0x45, 0xf7, 0x25, 0xc6, 0x7b, 0x79, - 0x70, 0x5e, 0xcd, 0xbe, 0x85, 0xae, 0xd2, 0x05, 0xd4, 0xf8, 0x59, 0x77, 0xf5, 0xc9, 0x7b, 0x7e, - 0x60, 0x56, 0xcd, 0xfb, 0x0e, 0x7a, 0x5a, 0x56, 0x9a, 0x4f, 0xff, 0x9e, 0x5e, 0x35, 0x9f, 0xfe, - 0x1b, 0xea, 0xa5, 0xa6, 0xbf, 0x5a, 0xc2, 0xe6, 0xd3, 0xbf, 0xa3, 0x76, 0xcd, 0xa7, 0x7f, 0x57, - 0xb5, 0xfc, 0x07, 0x5f, 0xf7, 0x7f, 0xe8, 0x6a, 0x59, 0xe8, 0xa9, 0xcf, 0xd3, 0x7f, 0x02, 0x00, - 0x00, 0xff, 0xff, 0x6b, 0xfb, 0xa5, 0x9a, 0xfd, 0x09, 0x00, 0x00, +var fileDescriptor_executor_b646d273b48eddd5 = []byte{ + // 871 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4b, 0x8f, 0xdc, 0x44, + 0x10, 0xce, 0xac, 0x77, 0x5e, 0xe5, 0xd9, 0x87, 0x5a, 0x68, 0x71, 0xcc, 0x21, 0x83, 0x0f, 0x64, + 0x24, 0x82, 0x1d, 0x6d, 0x5e, 0x5c, 0x00, 0x89, 0xdd, 0xc0, 0x65, 0x89, 0x56, 0xde, 0x40, 0x24, + 0x0e, 0x0c, 0xbd, 0x76, 0x63, 0xb7, 0x76, 0xc6, 0x6d, 0xba, 0xdb, 0xc3, 0x46, 0x42, 0xe2, 0xc4, + 0x3f, 0xe0, 0x97, 0x72, 0xe2, 0x88, 0xfa, 0xe5, 0x9d, 0xd9, 0x84, 0xc8, 0x03, 0xe2, 0x34, 0x5d, + 0xe5, 0xfa, 0xbe, 0xaa, 0xea, 0xae, 0xfa, 0x06, 0x1e, 0xe4, 0x9c, 0xae, 0x08, 0x17, 0x89, 0x28, + 0x31, 0x27, 0x79, 0x42, 0xae, 0x49, 0xd6, 0x48, 0xc6, 0x93, 0x9a, 0x33, 0xc9, 0x5a, 0x33, 0xd6, + 0x26, 0xfa, 0xa8, 0xc4, 0xa2, 0xa4, 0x19, 0xe3, 0x75, 0x5c, 0xb1, 0x25, 0xce, 0xe3, 0x7a, 0xd1, + 0x14, 0xb4, 0x12, 0xf1, 0x66, 0x5c, 0x78, 0xaf, 0x60, 0xac, 0x58, 0x10, 0x43, 0x72, 0xd9, 0xfc, + 0x94, 0x48, 0xba, 0x24, 0x42, 0xe2, 0x65, 0x6d, 0x03, 0x3e, 0x2b, 0xa8, 0x2c, 0x9b, 0xcb, 0x38, + 0x63, 0xcb, 0xa4, 0xe5, 0x4c, 0x34, 0x67, 0x62, 0x39, 0x13, 0x57, 0x99, 0xa9, 0xc4, 0x58, 0x06, + 0x1e, 0xfd, 0xe9, 0xc1, 0xde, 0x19, 0x6e, 0xaa, 0xac, 0x4c, 0xc9, 0xcf, 0x0d, 0x11, 0x12, 0x1d, + 0x82, 0x97, 0x2d, 0xf3, 0xa0, 0x37, 0xed, 0xcd, 0xc6, 0xa9, 0x3a, 0x22, 0x04, 0xbb, 0x98, 0x17, + 0x22, 0xd8, 0x99, 0x7a, 0xb3, 0x71, 0xaa, 0xcf, 0xe8, 0x05, 0x8c, 0x39, 0x11, 0xac, 0xe1, 0x19, + 0x11, 0x81, 0x37, 0xed, 0xcd, 0xfc, 0xe3, 0x87, 0xf1, 0x3f, 0xf5, 0x64, 0xf3, 0x9b, 0x94, 0x71, + 0xea, 0x70, 0xe9, 0x0d, 0x05, 0xba, 0x07, 0xbe, 0x90, 0x39, 0x6b, 0xe4, 0xbc, 0xc6, 0xb2, 0x0c, + 0x76, 0x75, 0x76, 0x30, 0xae, 0x73, 0x2c, 0x4b, 0x1b, 0x40, 0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96, 0xa8, 0x36, 0xef, + 0x6b, 0x18, 0x18, 0x59, 0xe9, 0x3e, 0xfd, 0x1b, 0x7a, 0xd5, 0x7d, 0xfa, 0x6f, 0xa9, 0x97, 0x9e, + 0x7e, 0xb5, 0x84, 0xdd, 0xa7, 0x7f, 0x4d, 0xed, 0xba, 0x4f, 0xff, 0xba, 0x6a, 0x45, 0x77, 0xbe, + 0x1c, 0x7e, 0xdf, 0x37, 0xb2, 0x30, 0xd0, 0x3f, 0x8f, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x9f, + 0x81, 0x07, 0x03, 0x8c, 0x0a, 0x00, 0x00, } diff --git a/drivers/shared/executor/proto/executor.proto b/drivers/shared/executor/proto/executor.proto index 0ce382903..dd4f36e1d 100644 --- a/drivers/shared/executor/proto/executor.proto +++ b/drivers/shared/executor/proto/executor.proto @@ -27,6 +27,8 @@ message LaunchRequest { string task_dir = 8; bool resource_limits = 9; bool basic_process_cgroup = 10; + repeated hashicorp.nomad.plugins.drivers.proto.Mount mounts = 11; + repeated hashicorp.nomad.plugins.drivers.proto.Device devices = 12; } message LaunchResponse { diff --git a/drivers/shared/executor/server.go b/drivers/shared/executor/server.go index 2900334e7..8d9053299 100644 --- a/drivers/shared/executor/server.go +++ b/drivers/shared/executor/server.go @@ -26,6 +26,8 @@ func (s *grpcExecutorServer) Launch(ctx context.Context, req *proto.LaunchReques TaskDir: req.TaskDir, ResourceLimits: req.ResourceLimits, BasicProcessCgroup: req.BasicProcessCgroup, + Mounts: drivers.MountsFromProto(req.Mounts), + Devices: drivers.DevicesFromProto(req.Devices), }) if err != nil { diff --git a/plugins/drivers/utils.go b/plugins/drivers/utils.go index 34ad01d11..4b104bec0 100644 --- a/plugins/drivers/utils.go +++ b/plugins/drivers/utils.go @@ -57,8 +57,8 @@ func taskConfigFromProto(pb *proto.TaskConfig) *TaskConfig { Env: pb.Env, rawDriverConfig: pb.MsgpackDriverConfig, Resources: ResourcesFromProto(pb.Resources), - Devices: devicesFromProto(pb.Devices), - Mounts: mountsFromProto(pb.Mounts), + Devices: DevicesFromProto(pb.Devices), + Mounts: MountsFromProto(pb.Mounts), User: pb.User, AllocDir: pb.AllocDir, StdoutPath: pb.StdoutPath, @@ -78,8 +78,8 @@ func taskConfigToProto(cfg *TaskConfig) *proto.TaskConfig { Name: cfg.Name, Env: cfg.Env, Resources: ResourcesToProto(cfg.Resources), - Devices: devicesToProto(cfg.Devices), - Mounts: mountsToProto(cfg.Mounts), + Devices: DevicesToProto(cfg.Devices), + Mounts: MountsToProto(cfg.Mounts), User: cfg.User, AllocDir: cfg.AllocDir, MsgpackDriverConfig: cfg.rawDriverConfig, @@ -193,20 +193,20 @@ func ResourcesToProto(r *Resources) *proto.Resources { return &pb } -func devicesFromProto(devices []*proto.Device) []*DeviceConfig { +func DevicesFromProto(devices []*proto.Device) []*DeviceConfig { if devices == nil { return nil } out := make([]*DeviceConfig, len(devices)) for i, d := range devices { - out[i] = deviceFromProto(d) + out[i] = DeviceFromProto(d) } return out } -func deviceFromProto(device *proto.Device) *DeviceConfig { +func DeviceFromProto(device *proto.Device) *DeviceConfig { if device == nil { return nil } @@ -218,20 +218,20 @@ func deviceFromProto(device *proto.Device) *DeviceConfig { } } -func mountsFromProto(mounts []*proto.Mount) []*MountConfig { +func MountsFromProto(mounts []*proto.Mount) []*MountConfig { if mounts == nil { return nil } out := make([]*MountConfig, len(mounts)) for i, m := range mounts { - out[i] = mountFromProto(m) + out[i] = MountFromProto(m) } return out } -func mountFromProto(mount *proto.Mount) *MountConfig { +func MountFromProto(mount *proto.Mount) *MountConfig { if mount == nil { return nil } @@ -243,20 +243,20 @@ func mountFromProto(mount *proto.Mount) *MountConfig { } } -func devicesToProto(devices []*DeviceConfig) []*proto.Device { +func DevicesToProto(devices []*DeviceConfig) []*proto.Device { if devices == nil { return nil } out := make([]*proto.Device, len(devices)) for i, d := range devices { - out[i] = deviceToProto(d) + out[i] = DeviceToProto(d) } return out } -func deviceToProto(device *DeviceConfig) *proto.Device { +func DeviceToProto(device *DeviceConfig) *proto.Device { if device == nil { return nil } @@ -268,20 +268,20 @@ func deviceToProto(device *DeviceConfig) *proto.Device { } } -func mountsToProto(mounts []*MountConfig) []*proto.Mount { +func MountsToProto(mounts []*MountConfig) []*proto.Mount { if mounts == nil { return nil } out := make([]*proto.Mount, len(mounts)) for i, m := range mounts { - out[i] = mountToProto(m) + out[i] = MountToProto(m) } return out } -func mountToProto(mount *MountConfig) *proto.Mount { +func MountToProto(mount *MountConfig) *proto.Mount { if mount == nil { return nil }