summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-10-06 10:15:04 +0200
committerGitHub <noreply@github.com>2020-10-06 10:15:04 +0200
commit80a2317ca20b0e5e1cd064a8962beed642be3a36 (patch)
tree0730915a611542bf028d5b9c66ace1390a6c036f /libpod
parentf584d47a9d0c050c3b39793a73b0aba17b45e8ba (diff)
parentd4aa89bb40b3a2c1730c9bff31a681007a3feb97 (diff)
downloadpodman-80a2317ca20b0e5e1cd064a8962beed642be3a36.tar.gz
podman-80a2317ca20b0e5e1cd064a8962beed642be3a36.tar.bz2
podman-80a2317ca20b0e5e1cd064a8962beed642be3a36.zip
Merge pull request #7929 from kolyshkin/nits-err
Nits
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_internal.go4
-rw-r--r--libpod/container_internal_linux.go26
-rw-r--r--libpod/image/image.go2
-rw-r--r--libpod/lock/file/file_lock.go6
-rw-r--r--libpod/networking_linux.go4
-rw-r--r--libpod/oci_conmon_linux.go10
-rw-r--r--libpod/runtime.go14
-rw-r--r--libpod/runtime_ctr.go6
8 files changed, 31 insertions, 41 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 0514fb46f..d64d3ab87 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -496,7 +496,7 @@ func (c *Container) setupStorage(ctx context.Context) error {
artifacts := filepath.Join(c.config.StaticDir, artifactsDir)
if err := os.MkdirAll(artifacts, 0755); err != nil {
- return errors.Wrapf(err, "error creating artifacts directory %q", artifacts)
+ return errors.Wrap(err, "error creating artifacts directory")
}
return nil
@@ -1820,7 +1820,7 @@ func (c *Container) appendStringToRundir(destFile, output string) (string, error
f, err := os.OpenFile(destFileName, os.O_APPEND|os.O_WRONLY, 0600)
if err != nil {
- return "", errors.Wrapf(err, "unable to open %s", destFileName)
+ return "", err
}
defer f.Close()
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 514cdaee1..894982973 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -835,13 +835,13 @@ func (c *Container) checkpointRestoreLabelLog(fileName string) error {
logFile, err := os.OpenFile(dumpLog, os.O_CREATE, 0600)
if err != nil {
- return errors.Wrapf(err, "failed to create CRIU log file %q", dumpLog)
+ return errors.Wrap(err, "failed to create CRIU log file")
}
if err := logFile.Close(); err != nil {
- logrus.Errorf("unable to close log file: %q", err)
+ logrus.Error(err)
}
if err = label.SetFileLabel(dumpLog, c.MountLabel()); err != nil {
- return errors.Wrapf(err, "failed to label CRIU log file %q", dumpLog)
+ return err
}
return nil
}
@@ -919,7 +919,7 @@ func (c *Container) checkpoint(ctx context.Context, options ContainerCheckpointO
func (c *Container) importCheckpoint(input string) error {
archiveFile, err := os.Open(input)
if err != nil {
- return errors.Wrapf(err, "Failed to open checkpoint archive %s for import", input)
+ return errors.Wrap(err, "failed to open checkpoint archive for import")
}
defer archiveFile.Close()
@@ -1116,35 +1116,29 @@ func (c *Container) restore(ctx context.Context, options ContainerCheckpointOpti
// Only do this if a rootfs-diff.tar actually exists
rootfsDiffFile, err := os.Open(rootfsDiffPath)
if err != nil {
- return errors.Wrapf(err, "Failed to open root file-system diff file %s", rootfsDiffPath)
+ return errors.Wrap(err, "failed to open root file-system diff file")
}
defer rootfsDiffFile.Close()
if err := c.runtime.ApplyDiffTarStream(c.ID(), rootfsDiffFile); err != nil {
- return errors.Wrapf(err, "Failed to apply root file-system diff file %s", rootfsDiffPath)
+ return errors.Wrapf(err, "failed to apply root file-system diff file %s", rootfsDiffPath)
}
}
deletedFilesPath := filepath.Join(c.bundlePath(), "deleted.files")
if _, err := os.Stat(deletedFilesPath); err == nil {
- deletedFilesFile, err := os.Open(deletedFilesPath)
- if err != nil {
- return errors.Wrapf(err, "Failed to open deleted files file %s", deletedFilesPath)
- }
- defer deletedFilesFile.Close()
-
var deletedFiles []string
- deletedFilesJSON, err := ioutil.ReadAll(deletedFilesFile)
+ deletedFilesJSON, err := ioutil.ReadFile(deletedFilesPath)
if err != nil {
- return errors.Wrapf(err, "Failed to read deleted files file %s", deletedFilesPath)
+ return errors.Wrapf(err, "failed to read deleted files file")
}
if err := json.Unmarshal(deletedFilesJSON, &deletedFiles); err != nil {
- return errors.Wrapf(err, "Failed to read deleted files file %s", deletedFilesPath)
+ return errors.Wrapf(err, "failed to read deleted files file %s", deletedFilesPath)
}
for _, deleteFile := range deletedFiles {
// Using RemoveAll as deletedFiles, which is generated from 'podman diff'
// lists completely deleted directories as a single entry: 'D /root'.
err = os.RemoveAll(filepath.Join(c.state.Mountpoint, deleteFile))
if err != nil {
- return errors.Wrapf(err, "Failed to delete file %s from container %s during restore", deletedFilesPath, c.ID())
+ return errors.Wrapf(err, "failed to delete file %s from container %s during restore", deletedFilesPath, c.ID())
}
}
}
diff --git a/libpod/image/image.go b/libpod/image/image.go
index f5bf47694..0900944eb 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -867,7 +867,7 @@ func (i *Image) PushImageToReference(ctx context.Context, dest types.ImageRefere
// Copy the image to the remote destination
manifestBytes, err := cp.Image(ctx, policyContext, dest, src, copyOptions)
if err != nil {
- return errors.Wrapf(err, "Error copying image to the remote destination")
+ return errors.Wrapf(err, "error copying image to the remote destination")
}
digest, err := manifest.Digest(manifestBytes)
if err != nil {
diff --git a/libpod/lock/file/file_lock.go b/libpod/lock/file/file_lock.go
index e50d67321..2643c9211 100644
--- a/libpod/lock/file/file_lock.go
+++ b/libpod/lock/file/file_lock.go
@@ -26,7 +26,7 @@ func CreateFileLock(path string) (*FileLocks, error) {
return nil, errors.Wrapf(syscall.EEXIST, "directory %s exists", path)
}
if err := os.MkdirAll(path, 0711); err != nil {
- return nil, errors.Wrapf(err, "cannot create %s", path)
+ return nil, err
}
locks := new(FileLocks)
@@ -40,7 +40,7 @@ func CreateFileLock(path string) (*FileLocks, error) {
func OpenFileLock(path string) (*FileLocks, error) {
_, err := os.Stat(path)
if err != nil {
- return nil, errors.Wrapf(err, "accessing directory %s", path)
+ return nil, err
}
locks := new(FileLocks)
@@ -84,7 +84,7 @@ func (locks *FileLocks) AllocateLock() (uint32, error) {
if os.IsExist(err) {
continue
}
- return 0, errors.Wrapf(err, "creating lock file")
+ return 0, errors.Wrap(err, "creating lock file")
}
f.Close()
break
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index c0508ce39..d16bdc973 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -662,12 +662,12 @@ func (r *Runtime) setupNetNS(ctr *Container) error {
nsPath := fmt.Sprintf("/var/run/netns/cni-%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:])
if err := os.MkdirAll(filepath.Dir(nsPath), 0711); err != nil {
- return errors.Wrapf(err, "cannot create %s", filepath.Dir(nsPath))
+ return err
}
mountPointFd, err := os.Create(nsPath)
if err != nil {
- return errors.Wrapf(err, "cannot open %s", nsPath)
+ return err
}
if err := mountPointFd.Close(); err != nil {
return err
diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go
index 5e73bffe0..7fb374e0d 100644
--- a/libpod/oci_conmon_linux.go
+++ b/libpod/oci_conmon_linux.go
@@ -157,15 +157,13 @@ func newConmonOCIRuntime(name string, paths []string, conmonPath string, runtime
if err := os.MkdirAll(runtime.exitsDir, 0750); err != nil {
// The directory is allowed to exist
if !os.IsExist(err) {
- return nil, errors.Wrapf(err, "error creating OCI runtime exit files directory %s",
- runtime.exitsDir)
+ return nil, errors.Wrapf(err, "error creating OCI runtime exit files directory")
}
}
if err := os.MkdirAll(runtime.socketsDir, 0750); err != nil {
// The directory is allowed to exist
if !os.IsExist(err) {
- return nil, errors.Wrapf(err, "error creating OCI runtime attach sockets directory %s",
- runtime.socketsDir)
+ return nil, errors.Wrap(err, "error creating OCI runtime attach sockets directory")
}
}
@@ -1397,12 +1395,12 @@ func startCommandGivenSelinux(cmd *exec.Cmd) error {
)
plabel, err = selinux.CurrentLabel()
if err != nil {
- return errors.Wrapf(err, "Failed to get current SELinux label")
+ return errors.Wrapf(err, "failed to get current SELinux label")
}
con, err = selinux.NewContext(plabel)
if err != nil {
- return errors.Wrapf(err, "Failed to get new context from SELinux label")
+ return errors.Wrapf(err, "failed to get new context from SELinux label")
}
runtime.LockOSThread()
diff --git a/libpod/runtime.go b/libpod/runtime.go
index fdd9ebcc8..7da8b181f 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -251,8 +251,7 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) {
if err := os.MkdirAll(runtime.config.Engine.StaticDir, 0700); err != nil {
// The directory is allowed to exist
if !os.IsExist(err) {
- return errors.Wrapf(err, "error creating runtime static files directory %s",
- runtime.config.Engine.StaticDir)
+ return errors.Wrap(err, "error creating runtime static files directory")
}
}
@@ -348,7 +347,7 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) {
if err := os.MkdirAll(runtime.config.Engine.TmpDir, 0751); err != nil {
// The directory is allowed to exist
if !os.IsExist(err) {
- return errors.Wrapf(err, "error creating tmpdir %s", runtime.config.Engine.TmpDir)
+ return errors.Wrap(err, "error creating tmpdir")
}
}
@@ -356,7 +355,7 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) {
if err := os.MkdirAll(filepath.Dir(runtime.config.Engine.EventsLogFilePath), 0700); err != nil {
// The directory is allowed to exist
if !os.IsExist(err) {
- return errors.Wrapf(err, "error creating events dirs %s", filepath.Dir(runtime.config.Engine.EventsLogFilePath))
+ return errors.Wrap(err, "error creating events dirs")
}
}
@@ -416,8 +415,7 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) {
if err := os.MkdirAll(runtime.config.Engine.TmpDir, 0755); err != nil {
// The directory is allowed to exist
if !os.IsExist(err) {
- return errors.Wrapf(err, "error creating runtime temporary files directory %s",
- runtime.config.Engine.TmpDir)
+ return errors.Wrapf(err, "error creating runtime temporary files directory")
}
}
@@ -584,7 +582,7 @@ func (r *Runtime) Shutdown(force bool) error {
// attempt to shut it down
if r.store != nil {
if _, err := r.store.Shutdown(force); err != nil {
- lastError = errors.Wrapf(err, "Error shutting down container storage")
+ lastError = errors.Wrapf(err, "error shutting down container storage")
}
}
if err := r.state.Close(); err != nil {
@@ -649,7 +647,7 @@ func (r *Runtime) refresh(alivePath string) error {
// Create a file indicating the runtime is alive and ready
file, err := os.OpenFile(alivePath, os.O_RDONLY|os.O_CREATE, 0644)
if err != nil {
- return errors.Wrapf(err, "error creating runtime status file %s", alivePath)
+ return errors.Wrap(err, "error creating runtime status file")
}
defer file.Close()
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index 241448981..abb97293f 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -331,7 +331,7 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai
ctr.config.ShmDir = filepath.Join(ctr.bundlePath(), "shm")
if err := os.MkdirAll(ctr.config.ShmDir, 0700); err != nil {
if !os.IsExist(err) {
- return nil, errors.Wrapf(err, "unable to create shm %q dir", ctr.config.ShmDir)
+ return nil, errors.Wrap(err, "unable to create shm dir")
}
}
ctr.config.Mounts = append(ctr.config.Mounts, ctr.config.ShmDir)
@@ -620,7 +620,7 @@ func (r *Runtime) evictContainer(ctx context.Context, idOrName string, removeVol
id, err := r.state.LookupContainerID(idOrName)
if err != nil {
- return "", errors.Wrapf(err, "Failed to find container %q in state", idOrName)
+ return "", errors.Wrapf(err, "failed to find container %q in state", idOrName)
}
// Begin by trying a normal removal. Valid containers will be removed normally.
@@ -650,7 +650,7 @@ func (r *Runtime) evictContainer(ctx context.Context, idOrName string, removeVol
return id, err
}
if !exists {
- return id, errors.Wrapf(err, "Failed to find container ID %q for eviction", id)
+ return id, errors.Wrapf(err, "failed to find container ID %q for eviction", id)
}
// Re-create a container struct for removal purposes