Fix bundle removal with the reappearance of state dir
Bundle removal now requires removing both workdir and path locations on delete in shim. Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
This commit is contained in:
parent
738c22a756
commit
c8cd3d9080
@ -14,13 +14,15 @@ import (
|
|||||||
client "github.com/containerd/containerd/linux/shim"
|
client "github.com/containerd/containerd/linux/shim"
|
||||||
"github.com/containerd/containerd/runtime"
|
"github.com/containerd/containerd/runtime"
|
||||||
"github.com/containerd/containerd/typeurl"
|
"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{
|
return &bundle{
|
||||||
path: path,
|
path: path,
|
||||||
namespace: namespace,
|
namespace: namespace,
|
||||||
events: events,
|
events: events,
|
||||||
|
workDir: workdir,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +114,16 @@ func (b *bundle) Connect(ctx context.Context, remote bool) (*client.Client, erro
|
|||||||
|
|
||||||
// Delete deletes the bundle from disk
|
// Delete deletes the bundle from disk
|
||||||
func (b *bundle) Delete() error {
|
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 {
|
func (b *bundle) shimAddress() string {
|
||||||
|
@ -211,7 +211,7 @@ func (r *Runtime) Delete(ctx context.Context, c runtime.Task) (*runtime.Exit, er
|
|||||||
}
|
}
|
||||||
r.tasks.Delete(ctx, lc)
|
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 {
|
if err := bundle.Delete(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -262,7 +262,7 @@ func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
id := path.Name()
|
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)
|
s, err := bundle.Connect(ctx, r.remote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user