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

@@ -195,13 +195,22 @@ func (s *service) Cleanup(ctx context.Context) (*taskAPI.DeleteResponse, error)
if err != nil {
return nil, err
}
path, err := os.Getwd()
if err != nil {
return nil, err
// Forcibly shut down any container in this bundle
rhcs := newRunhcs("")
dopts := &runhcs.DeleteOpts{
Force: true,
}
if err := os.RemoveAll(path); err != nil {
return nil, err
if err := rhcs.Delete(ctx, s.id, dopts); err != nil {
log.G(ctx).WithError(err).Debugf("failed to delete container")
}
opts, ok := ctx.Value(shim.OptsKey{}).(shim.Opts)
if ok && opts.BundlePath != "" {
if err := os.RemoveAll(opts.BundlePath); err != nil {
return nil, err
}
}
return &taskAPI.DeleteResponse{
ExitedAt: time.Now(),
ExitStatus: 255,