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:
haoyun
2022-01-07 10:19:31 +08:00
parent 3ccd43c8f6
commit bbe46b8c43
299 changed files with 1896 additions and 1874 deletions

View File

@@ -17,10 +17,11 @@
package mount
import (
"errors"
"fmt"
"os"
"time"
"github.com/pkg/errors"
exec "golang.org/x/sys/execabs"
"golang.org/x/sys/unix"
)
@@ -64,7 +65,7 @@ func (m *Mount) mountWithHelper(target string) error {
return nil
}
if !errors.Is(err, unix.ECHILD) {
return errors.Wrapf(err, "mount [%v] failed: %q", args, string(out))
return fmt.Errorf("mount [%v] failed: %q: %w", args, string(out), err)
}
// We got ECHILD, we are not sure whether the mount was successful.
// If the mount ID has changed, we are sure we got some new mount, but still not sure it is fully completed.
@@ -77,7 +78,7 @@ func (m *Mount) mountWithHelper(target string) error {
_ = unmount(target, 0)
}
}
return errors.Errorf("mount [%v] failed with ECHILD (retired %d times)", args, retriesOnECHILD)
return fmt.Errorf("mount [%v] failed with ECHILD (retired %d times)", args, retriesOnECHILD)
}
// Unmount the provided mount path with the flags
@@ -101,7 +102,7 @@ func unmount(target string, flags int) error {
}
return nil
}
return errors.Wrapf(unix.EBUSY, "failed to unmount target %s", target)
return fmt.Errorf("failed to unmount target %s: %w", target, unix.EBUSY)
}
// UnmountAll repeatedly unmounts the given mount point until there