summaryrefslogtreecommitdiff
path: root/libpod/runtime_migrate.go
diff options
context:
space:
mode:
authorSascha Grunert <sgrunert@redhat.com>2022-06-30 16:47:21 +0200
committerSascha Grunert <sgrunert@redhat.com>2022-07-04 15:39:00 +0200
commit597de7a083c329bdaed7fc469555a4142f71bcb8 (patch)
tree5f49d85e2f273a71520dc4b391f051cb1cbf3d07 /libpod/runtime_migrate.go
parent3e8ab312395b32d0b43f1ac82adf53439b012893 (diff)
downloadpodman-597de7a083c329bdaed7fc469555a4142f71bcb8.tar.gz
podman-597de7a083c329bdaed7fc469555a4142f71bcb8.tar.bz2
podman-597de7a083c329bdaed7fc469555a4142f71bcb8.zip
libpod/runtime: switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of the deprecated github.com/pkg/errors package. [NO NEW TESTS NEEDED] Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
Diffstat (limited to 'libpod/runtime_migrate.go')
-rw-r--r--libpod/runtime_migrate.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/libpod/runtime_migrate.go b/libpod/runtime_migrate.go
index f56cb83a4..139638a6b 100644
--- a/libpod/runtime_migrate.go
+++ b/libpod/runtime_migrate.go
@@ -14,7 +14,6 @@ import (
"github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/pkg/rootless"
"github.com/containers/podman/v4/pkg/util"
- "github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -22,21 +21,21 @@ func (r *Runtime) stopPauseProcess() error {
if rootless.IsRootless() {
pausePidPath, err := util.GetRootlessPauseProcessPidPathGivenDir(r.config.Engine.TmpDir)
if err != nil {
- return errors.Wrapf(err, "could not get pause process pid file path")
+ return fmt.Errorf("could not get pause process pid file path: %w", err)
}
data, err := ioutil.ReadFile(pausePidPath)
if err != nil {
if os.IsNotExist(err) {
return nil
}
- return errors.Wrap(err, "cannot read pause process pid file")
+ return fmt.Errorf("cannot read pause process pid file: %w", err)
}
pausePid, err := strconv.Atoi(string(data))
if err != nil {
- return errors.Wrapf(err, "cannot parse pause pid file %s", pausePidPath)
+ return fmt.Errorf("cannot parse pause pid file %s: %w", pausePidPath, err)
}
if err := os.Remove(pausePidPath); err != nil {
- return errors.Wrapf(err, "cannot delete pause pid file %s", pausePidPath)
+ return fmt.Errorf("cannot delete pause pid file %s: %w", pausePidPath, err)
}
if err := syscall.Kill(pausePid, syscall.SIGKILL); err != nil {
return err
@@ -60,7 +59,7 @@ func (r *Runtime) migrate() error {
for _, ctr := range runningContainers {
fmt.Printf("stopped %s\n", ctr.ID())
if err := ctr.Stop(); err != nil {
- return errors.Wrapf(err, "cannot stop container %s", ctr.ID())
+ return fmt.Errorf("cannot stop container %s: %w", ctr.ID(), err)
}
}
@@ -68,7 +67,7 @@ func (r *Runtime) migrate() error {
runtimeChangeRequested := r.migrateRuntime != ""
requestedRuntime, runtimeExists := r.ociRuntimes[r.migrateRuntime]
if !runtimeExists && runtimeChangeRequested {
- return errors.Wrapf(define.ErrInvalidArg, "change to runtime %q requested but no such runtime is defined", r.migrateRuntime)
+ return fmt.Errorf("change to runtime %q requested but no such runtime is defined: %w", r.migrateRuntime, define.ErrInvalidArg)
}
for _, ctr := range allCtrs {
@@ -93,7 +92,7 @@ func (r *Runtime) migrate() error {
if needsWrite {
if err := r.state.RewriteContainerConfig(ctr, ctr.config); err != nil {
- return errors.Wrapf(err, "error rewriting config for container %s", ctr.ID())
+ return fmt.Errorf("error rewriting config for container %s: %w", ctr.ID(), err)
}
}
}