From 5b6404f4b418e3a45301ff7d2a12ed5bf7246288 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Mon, 18 Mar 2019 17:36:31 -0400 Subject: [PATCH] Move libcontainer helper to executor package --- drivers/shared/executor/executor_linux.go | 8 +------- .../shared/executor/libcontainer_nsenter_linux.go | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) rename nsenter_linux.go => drivers/shared/executor/libcontainer_nsenter_linux.go (97%) diff --git a/drivers/shared/executor/executor_linux.go b/drivers/shared/executor/executor_linux.go index 20dcf1829c83..34b82638f055 100644 --- a/drivers/shared/executor/executor_linux.go +++ b/drivers/shared/executor/executor_linux.go @@ -20,7 +20,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/helper/discover" shelpers "github.com/hashicorp/nomad/helper/stats" "github.com/hashicorp/nomad/helper/uuid" "github.com/hashicorp/nomad/nomad/structs" @@ -102,11 +101,6 @@ 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) { l.logger.Debug("launching command", "command", command.Cmd, "args", strings.Join(command.Args, " ")) - // Find the nomad executable to launch the executor process with - bin, err := discover.NomadExecutable() - if err != nil { - return nil, fmt.Errorf("unable to find the nomad binary: %v", err) - } if command.Resources == nil { command.Resources = &drivers.Resources{ @@ -129,7 +123,7 @@ func (l *LibcontainerExecutor) Launch(command *ExecCommand) (*ProcessState, erro factory, err := libcontainer.New( path.Join(command.TaskDir, "../alloc/container"), libcontainer.Cgroupfs, - libcontainer.InitArgs(bin, "libcontainer-shim"), + libcontainer.InitArgs(os.Args[0], "libcontainer-shim"), ) if err != nil { return nil, fmt.Errorf("failed to create factory: %v", err) diff --git a/nsenter_linux.go b/drivers/shared/executor/libcontainer_nsenter_linux.go similarity index 97% rename from nsenter_linux.go rename to drivers/shared/executor/libcontainer_nsenter_linux.go index 7beacc79919d..fdde8c33ee5d 100644 --- a/nsenter_linux.go +++ b/drivers/shared/executor/libcontainer_nsenter_linux.go @@ -1,4 +1,4 @@ -package main +package executor import ( "os"