Skip to content

Commit

Permalink
Fix bundle removal with the reappearance of state dir
Browse files Browse the repository at this point in the history
Bundle removal now requires removing both workdir and path locations on
delete in shim.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
  • Loading branch information
estesp committed Aug 7, 2017
1 parent 738c22a commit c8cd3d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions linux/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import (
client "github.com/containerd/containerd/linux/shim"
"github.com/containerd/containerd/runtime"
"github.com/containerd/containerd/typeurl"
"github.com/pkg/errors"
)

func loadBundle(path, namespace string, events *events.Exchange) *bundle {
func loadBundle(path, workdir, namespace string, events *events.Exchange) *bundle {
return &bundle{
path: path,
namespace: namespace,
events: events,
workDir: workdir,
}
}

Expand Down Expand Up @@ -112,7 +114,16 @@ func (b *bundle) Connect(ctx context.Context, remote bool) (*client.Client, erro

// Delete deletes the bundle from disk
func (b *bundle) Delete() error {
return os.RemoveAll(b.path)
err := os.RemoveAll(b.path)
if err == nil {
return os.RemoveAll(b.workDir)
}
// error removing the bundle path; still attempt removing work dir
err2 := os.RemoveAll(b.workDir)
if err2 == nil {
return err
}
return errors.Wrapf(err, "Failed to remove both bundle and workdir locations: %v", err2)
}

func (b *bundle) shimAddress() string {
Expand Down
4 changes: 2 additions & 2 deletions linux/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (r *Runtime) Delete(ctx context.Context, c runtime.Task) (*runtime.Exit, er
}
r.tasks.Delete(ctx, lc)

bundle := loadBundle(filepath.Join(r.state, namespace, lc.id), namespace, r.events)
bundle := loadBundle(filepath.Join(r.state, namespace, lc.id), filepath.Join(r.root, namespace, lc.id), namespace, r.events)
if err := bundle.Delete(); err != nil {
return nil, err
}
Expand Down Expand Up @@ -262,7 +262,7 @@ func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) {
continue
}
id := path.Name()
bundle := loadBundle(filepath.Join(r.state, ns, id), ns, r.events)
bundle := loadBundle(filepath.Join(r.state, ns, id), filepath.Join(r.root, ns, id), ns, r.events)

s, err := bundle.Connect(ctx, r.remote)
if err != nil {
Expand Down

0 comments on commit c8cd3d9

Please sign in to comment.