feat: replace github.com/pkg/errors to errors
Signed-off-by: haoyun <yun.hao@daocloud.io> Co-authored-by: zounengren <zouyee1989@gmail.com>
This commit is contained in:
@@ -25,7 +25,6 @@ import (
|
||||
"github.com/containerd/containerd/identifiers"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const configFilename = "config.json"
|
||||
@@ -46,7 +45,7 @@ func LoadBundle(ctx context.Context, root, id string) (*Bundle, error) {
|
||||
// NewBundle returns a new bundle on disk
|
||||
func NewBundle(ctx context.Context, root, state, id string, spec []byte) (b *Bundle, err error) {
|
||||
if err := identifiers.Validate(id); err != nil {
|
||||
return nil, errors.Wrapf(err, "invalid task id %s", id)
|
||||
return nil, fmt.Errorf("invalid task id %s: %w", id, err)
|
||||
}
|
||||
|
||||
ns, err := namespaces.NamespaceRequired(ctx)
|
||||
@@ -121,10 +120,10 @@ func (b *Bundle) Delete() error {
|
||||
work, werr := os.Readlink(filepath.Join(b.Path, "work"))
|
||||
rootfs := filepath.Join(b.Path, "rootfs")
|
||||
if err := mount.UnmountAll(rootfs, 0); err != nil {
|
||||
return errors.Wrapf(err, "unmount rootfs %s", rootfs)
|
||||
return fmt.Errorf("unmount rootfs %s: %w", rootfs, err)
|
||||
}
|
||||
if err := os.Remove(rootfs); err != nil && !os.IsNotExist(err) {
|
||||
return errors.Wrap(err, "failed to remove bundle rootfs")
|
||||
return fmt.Errorf("failed to remove bundle rootfs: %w", err)
|
||||
}
|
||||
err := atomicDelete(b.Path)
|
||||
if err == nil {
|
||||
@@ -141,7 +140,7 @@ func (b *Bundle) Delete() error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return errors.Wrapf(err, "failed to remove both bundle and workdir locations: %v", err2)
|
||||
return fmt.Errorf("failed to remove both bundle and workdir locations: %v: %w", err2, err)
|
||||
}
|
||||
|
||||
// atomicDelete renames the path to a hidden file before removal
|
||||
|
Reference in New Issue
Block a user