Handle shim delete workdir on Windows
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user