Handle shim delete workdir on Windows

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
This commit is contained in:
Justin Terry (VM)
2018-09-28 15:02:10 -07:00
parent b8945d35f5
commit 2ddbb2db05
3 changed files with 37 additions and 8 deletions

View File

@@ -21,6 +21,7 @@ import (
"context"
"io"
"os"
gruntime "runtime"
"strings"
eventstypes "github.com/containerd/containerd/api/events"
@@ -109,7 +110,23 @@ func (b *binary) Start(ctx context.Context) (_ *shim, err error) {
func (b *binary) Delete(ctx context.Context) (*runtime.Exit, error) {
log.G(ctx).Info("cleaning up dead shim")
cmd, err := client.Command(ctx, b.runtime, b.containerdAddress, b.bundle.Path, "-id", b.bundle.ID, "delete")
var bundlePath string
if gruntime.GOOS == "windows" {
// Windows cannot delete the current working directory while an
// executable is in use with it. For the cleanup case we invoke with the
// deafult work dir and forward the bundle path on the cmdline.
bundlePath = ""
} else {
bundlePath = b.bundle.Path
}
cmd, err := client.Command(ctx,
b.runtime,
b.containerdAddress,
bundlePath,
"-id", b.bundle.ID,
"-bundle", b.bundle.Path,
"delete")
if err != nil {
return nil, err
}