Merge pull request #1779 from AkihiroSuda/resolve-util-bin

shim: support non-default binary name
This commit is contained in:
Michael Crosby 2017-11-17 17:53:43 -05:00 committed by GitHub
commit 67232e93dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 9 deletions

View File

@ -40,14 +40,15 @@ shim for container lifecycle and reconnection
` `
var ( var (
debugFlag bool debugFlag bool
namespaceFlag string namespaceFlag string
socketFlag string socketFlag string
addressFlag string addressFlag string
workdirFlag string workdirFlag string
runtimeRootFlag string runtimeRootFlag string
criuFlag string criuFlag string
systemdCgroupFlag bool systemdCgroupFlag bool
containerdBinaryFlag string
) )
func init() { func init() {
@ -59,6 +60,9 @@ func init() {
flag.StringVar(&runtimeRootFlag, "runtime-root", proc.RuncRoot, "root directory for the runtime") flag.StringVar(&runtimeRootFlag, "runtime-root", proc.RuncRoot, "root directory for the runtime")
flag.StringVar(&criuFlag, "criu", "", "path to criu binary") flag.StringVar(&criuFlag, "criu", "", "path to criu binary")
flag.BoolVar(&systemdCgroupFlag, "systemd-cgroup", false, "set runtime to use systemd-cgroup") flag.BoolVar(&systemdCgroupFlag, "systemd-cgroup", false, "set runtime to use systemd-cgroup")
// currently, the `containerd publish` utility is embedded in the daemon binary.
// The daemon invokes `containerd-shim -containerd-binary ...` with its own os.Executable() path.
flag.StringVar(&containerdBinaryFlag, "containerd-binary", "containerd", "path to containerd binary (used for `containerd publish`)")
flag.Parse() flag.Parse()
} }
@ -202,7 +206,7 @@ func (l *remoteEventsPublisher) Publish(ctx context.Context, topic string, event
if err != nil { if err != nil {
return err return err
} }
cmd := exec.CommandContext(ctx, "containerd", "--address", l.address, "publish", "--topic", topic, "--namespace", ns) cmd := exec.CommandContext(ctx, containerdBinaryFlag, "--address", l.address, "publish", "--topic", topic, "--namespace", ns)
cmd.Stdin = bytes.NewReader(data) cmd.Stdin = bytes.NewReader(data)
c, err := reaper.Default.Start(cmd) c, err := reaper.Default.Start(cmd)
if err != nil { if err != nil {

View File

@ -89,10 +89,15 @@ func WithStart(binary, address, daemonAddress, cgroup string, nonewns, debug boo
} }
func newCommand(binary, daemonAddress string, nonewns, debug bool, config shim.Config, socket *os.File) *exec.Cmd { func newCommand(binary, daemonAddress string, nonewns, debug bool, config shim.Config, socket *os.File) *exec.Cmd {
selfExe, err := os.Executable()
if err != nil {
panic(err)
}
args := []string{ args := []string{
"-namespace", config.Namespace, "-namespace", config.Namespace,
"-workdir", config.WorkDir, "-workdir", config.WorkDir,
"-address", daemonAddress, "-address", daemonAddress,
"-containerd-binary", selfExe,
} }
if config.Criu != "" { if config.Criu != "" {