Skip to content

Commit f35c352

Browse files
Merge pull request #2960 from jterry75/shim_windows_lookpath
Add support for containerd shim activation's within the same folder not in PATH
2 parents 4259f63 + d63099c commit f35c352

5 files changed

Lines changed: 34 additions & 7 deletions

File tree

runtime/v2/shim/util.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ import (
3131
"github.com/pkg/errors"
3232
)
3333

34-
const shimBinaryFormat = "containerd-shim-%s-%s"
35-
3634
var runtimePaths sync.Map
3735

3836
// Command returns the shim command with the provided args and configuration
@@ -65,7 +63,19 @@ func Command(ctx context.Context, runtime, containerdAddress, path string, cmdAr
6563
if cmdPath, lerr = exec.LookPath(name); lerr != nil {
6664
if eerr, ok := lerr.(*exec.Error); ok {
6765
if eerr.Err == exec.ErrNotFound {
68-
return nil, errors.Wrapf(os.ErrNotExist, "runtime %q binary not installed %q", runtime, name)
66+
// LookPath only finds current directory matches based on
67+
// the callers current directory but the caller is not
68+
// likely in the same directory as the containerd
69+
// executables. Instead match the calling binaries path
70+
// (containerd) and see if they are side by side. If so
71+
// execute the shim found there.
72+
testPath := filepath.Join(filepath.Dir(self), name)
73+
if _, serr := os.Stat(testPath); serr == nil {
74+
path = testPath
75+
}
76+
if path == "" {
77+
return nil, errors.Wrapf(os.ErrNotExist, "runtime %q binary not installed %q", runtime, name)
78+
}
6979
}
7080
}
7181
}

runtime/v2/shim/util_unix.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import (
3131
"github.com/pkg/errors"
3232
)
3333

34+
const shimBinaryFormat = "containerd-shim-%s-%s"
35+
3436
func getSysProcAttr() *syscall.SysProcAttr {
3537
return &syscall.SysProcAttr{
3638
Setpgid: true,

runtime/v2/shim/util_windows.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import (
2929
"github.com/pkg/errors"
3030
)
3131

32+
const shimBinaryFormat = "containerd-shim-%s-%s.exe"
33+
3234
func getSysProcAttr() *syscall.SysProcAttr {
3335
return nil
3436
}

vendor.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c
3333
github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895
3434
github.com/grpc-ecosystem/go-grpc-prometheus 6b7015e65d366bf3f19b2b2a000a831940f0f7e0
3535
github.com/Microsoft/go-winio v0.4.11
36-
github.com/Microsoft/hcsshim v0.8.4
36+
github.com/Microsoft/hcsshim v0.8.5
3737
google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944
3838
golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4
3939
github.com/containerd/ttrpc f02858b1457c5ca3aaec3a0803eb0d59f96e41d6

vendor/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs.go

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)