diff options
117 files changed, 581 insertions, 580 deletions
diff --git a/cmd/podman/containers/cp.go b/cmd/podman/containers/cp.go index c38cba66e..93477feb8 100644 --- a/cmd/podman/containers/cp.go +++ b/cmd/podman/containers/cp.go @@ -172,7 +172,7 @@ func copyContainerToContainer(sourceContainer string, sourcePath string, destCon return err } if err := copyFunc(); err != nil { - return fmt.Errorf("error copying from container: %w", err) + return fmt.Errorf("copying from container: %w", err) } return nil } @@ -192,7 +192,7 @@ func copyContainerToContainer(sourceContainer string, sourcePath string, destCon return err } if err := copyFunc(); err != nil { - return fmt.Errorf("error copying to container: %w", err) + return fmt.Errorf("copying to container: %w", err) } return nil } @@ -315,7 +315,7 @@ func copyFromContainer(container string, containerPath string, hostPath string) dir = filepath.Dir(dir) } if err := buildahCopiah.Put(dir, "", putOptions, reader); err != nil { - return fmt.Errorf("error copying to host: %w", err) + return fmt.Errorf("copying to host: %w", err) } return nil } @@ -327,7 +327,7 @@ func copyFromContainer(container string, containerPath string, hostPath string) return err } if err := copyFunc(); err != nil { - return fmt.Errorf("error copying from container: %w", err) + return fmt.Errorf("copying from container: %w", err) } return nil } @@ -424,7 +424,7 @@ func copyToContainer(container string, containerPath string, hostPath string) er getOptions.Rename = map[string]string{filepath.Base(hostTarget): containerBaseName} } if err := buildahCopiah.Get("/", "", getOptions, []string{hostTarget}, writer); err != nil { - return fmt.Errorf("error copying from host: %w", err) + return fmt.Errorf("copying from host: %w", err) } return nil } @@ -441,7 +441,7 @@ func copyToContainer(container string, containerPath string, hostPath string) er return err } if err := copyFunc(); err != nil { - return fmt.Errorf("error copying to container: %w", err) + return fmt.Errorf("copying to container: %w", err) } return nil } diff --git a/cmd/podman/containers/exec.go b/cmd/podman/containers/exec.go index 303795489..cbd090852 100644 --- a/cmd/podman/containers/exec.go +++ b/cmd/podman/containers/exec.go @@ -126,7 +126,7 @@ func exec(_ *cobra.Command, args []string) error { cliEnv, err := envLib.ParseSlice(envInput) if err != nil { - return fmt.Errorf("error parsing environment variables: %w", err) + return fmt.Errorf("parsing environment variables: %w", err) } execOpts.Envs = envLib.Join(execOpts.Envs, cliEnv) diff --git a/cmd/podman/containers/kill.go b/cmd/podman/containers/kill.go index c08b3abb6..86a7e3ff2 100644 --- a/cmd/podman/containers/kill.go +++ b/cmd/podman/containers/kill.go @@ -98,7 +98,7 @@ func kill(_ *cobra.Command, args []string) error { for _, cidFile := range killCidFiles { content, err := ioutil.ReadFile(cidFile) if err != nil { - return fmt.Errorf("error reading CIDFile: %w", err) + return fmt.Errorf("reading CIDFile: %w", err) } id := strings.Split(string(content), "\n")[0] args = append(args, id) diff --git a/cmd/podman/containers/logs.go b/cmd/podman/containers/logs.go index 9a9749210..e285a24d8 100644 --- a/cmd/podman/containers/logs.go +++ b/cmd/podman/containers/logs.go @@ -126,7 +126,7 @@ func logs(_ *cobra.Command, args []string) error { // parse time, error out if something is wrong since, err := util.ParseInputTime(logsOptions.SinceRaw, true) if err != nil { - return fmt.Errorf("error parsing --since %q: %w", logsOptions.SinceRaw, err) + return fmt.Errorf("parsing --since %q: %w", logsOptions.SinceRaw, err) } logsOptions.Since = since } @@ -134,7 +134,7 @@ func logs(_ *cobra.Command, args []string) error { // parse time, error out if something is wrong until, err := util.ParseInputTime(logsOptions.UntilRaw, false) if err != nil { - return fmt.Errorf("error parsing --until %q: %w", logsOptions.UntilRaw, err) + return fmt.Errorf("parsing --until %q: %w", logsOptions.UntilRaw, err) } logsOptions.Until = until } diff --git a/cmd/podman/containers/pause.go b/cmd/podman/containers/pause.go index 38c4f45aa..591523cf9 100644 --- a/cmd/podman/containers/pause.go +++ b/cmd/podman/containers/pause.go @@ -94,7 +94,7 @@ func pause(cmd *cobra.Command, args []string) error { for _, cidFile := range pauseCidFiles { content, err := ioutil.ReadFile(cidFile) if err != nil { - return fmt.Errorf("error reading CIDFile: %w", err) + return fmt.Errorf("reading CIDFile: %w", err) } id := strings.Split(string(content), "\n")[0] args = append(args, id) diff --git a/cmd/podman/containers/restart.go b/cmd/podman/containers/restart.go index 4e0e96411..0cc7901f9 100644 --- a/cmd/podman/containers/restart.go +++ b/cmd/podman/containers/restart.go @@ -107,7 +107,7 @@ func restart(cmd *cobra.Command, args []string) error { for _, cidFile := range restartCidFiles { content, err := ioutil.ReadFile(cidFile) if err != nil { - return fmt.Errorf("error reading CIDFile: %w", err) + return fmt.Errorf("reading CIDFile: %w", err) } id := strings.Split(string(content), "\n")[0] args = append(args, id) diff --git a/cmd/podman/containers/rm.go b/cmd/podman/containers/rm.go index 9c760e752..44d03e9de 100644 --- a/cmd/podman/containers/rm.go +++ b/cmd/podman/containers/rm.go @@ -110,7 +110,7 @@ func rm(cmd *cobra.Command, args []string) error { for _, cidFile := range rmCidFiles { content, err := ioutil.ReadFile(cidFile) if err != nil { - return fmt.Errorf("error reading CIDFile: %w", err) + return fmt.Errorf("reading CIDFile: %w", err) } id := strings.Split(string(content), "\n")[0] args = append(args, id) diff --git a/cmd/podman/containers/stop.go b/cmd/podman/containers/stop.go index 7e31aa7d5..412c513e1 100644 --- a/cmd/podman/containers/stop.go +++ b/cmd/podman/containers/stop.go @@ -107,7 +107,7 @@ func stop(cmd *cobra.Command, args []string) error { for _, cidFile := range stopCidFiles { content, err := ioutil.ReadFile(cidFile) if err != nil { - return fmt.Errorf("error reading CIDFile: %w", err) + return fmt.Errorf("reading CIDFile: %w", err) } id := strings.Split(string(content), "\n")[0] args = append(args, id) diff --git a/cmd/podman/containers/unpause.go b/cmd/podman/containers/unpause.go index 617c0e3a4..988964266 100644 --- a/cmd/podman/containers/unpause.go +++ b/cmd/podman/containers/unpause.go @@ -101,7 +101,7 @@ func unpause(cmd *cobra.Command, args []string) error { for _, cidFile := range unpauseCidFiles { content, err := ioutil.ReadFile(cidFile) if err != nil { - return fmt.Errorf("error reading CIDFile: %w", err) + return fmt.Errorf("reading CIDFile: %w", err) } id := strings.Split(string(content), "\n")[0] args = append(args, id) diff --git a/cmd/podman/early_init_linux.go b/cmd/podman/early_init_linux.go index e26c4264e..99046a02b 100644 --- a/cmd/podman/early_init_linux.go +++ b/cmd/podman/early_init_linux.go @@ -14,11 +14,11 @@ func setRLimits() error { rlimits.Max = define.RLimitDefaultValue if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, rlimits); err != nil { if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, rlimits); err != nil { - return fmt.Errorf("error getting rlimits: %w", err) + return fmt.Errorf("getting rlimits: %w", err) } rlimits.Cur = rlimits.Max if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, rlimits); err != nil { - return fmt.Errorf("error setting new rlimits: %w", err) + return fmt.Errorf("setting new rlimits: %w", err) } } return nil diff --git a/cmd/podman/generate/systemd.go b/cmd/podman/generate/systemd.go index a7cdd9bfe..3473c9011 100644 --- a/cmd/podman/generate/systemd.go +++ b/cmd/podman/generate/systemd.go @@ -150,7 +150,7 @@ func systemd(cmd *cobra.Command, args []string) error { if cmd.Flags().Changed(envFlagName) { cliEnv, err := envLib.ParseSlice(envInput) if err != nil { - return fmt.Errorf("error parsing environment variables: %w", err) + return fmt.Errorf("parsing environment variables: %w", err) } systemdOptions.AdditionalEnvVariables = envLib.Slice(cliEnv) } @@ -169,7 +169,7 @@ func systemd(cmd *cobra.Command, args []string) error { if files { cwd, err := os.Getwd() if err != nil { - return fmt.Errorf("error getting current working directory: %w", err) + return fmt.Errorf("getting current working directory: %w", err) } for name, content := range reports.Units { path := filepath.Join(cwd, fmt.Sprintf("%s.service", name)) diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go index 837b233f4..2b24c1cff 100644 --- a/cmd/podman/images/build.go +++ b/cmd/podman/images/build.go @@ -222,7 +222,7 @@ func build(cmd *cobra.Command, args []string) error { // The context directory could be a URL. Try to handle that. tempDir, subDir, err := buildahDefine.TempDirForURL("", "buildah", args[0]) if err != nil { - return fmt.Errorf("error prepping temporary context directory: %w", err) + return fmt.Errorf("prepping temporary context directory: %w", err) } if tempDir != "" { // We had to download it to a temporary directory. @@ -237,7 +237,7 @@ func build(cmd *cobra.Command, args []string) error { // Nope, it was local. Use it as is. absDir, err := filepath.Abs(args[0]) if err != nil { - return fmt.Errorf("error determining path to directory %q: %w", args[0], err) + return fmt.Errorf("determining path to directory %q: %w", args[0], err) } contextDir = absDir } @@ -253,7 +253,7 @@ func build(cmd *cobra.Command, args []string) error { } absFile, err := filepath.Abs(containerFiles[i]) if err != nil { - return fmt.Errorf("error determining path to file %q: %w", containerFiles[i], err) + return fmt.Errorf("determining path to file %q: %w", containerFiles[i], err) } contextDir = filepath.Dir(absFile) containerFiles[i] = absFile diff --git a/cmd/podman/images/list.go b/cmd/podman/images/list.go index 94d8412e5..1c464d91c 100644 --- a/cmd/podman/images/list.go +++ b/cmd/podman/images/list.go @@ -225,7 +225,7 @@ func sortImages(imageS []*entities.ImageSummary) ([]imageReporter, error) { h.ImageSummary = *e h.Repository, h.Tag, err = tokenRepoTag(tag) if err != nil { - return nil, fmt.Errorf("error parsing repository tag: %q: %w", tag, err) + return nil, fmt.Errorf("parsing repository tag: %q: %w", tag, err) } if h.Tag == "<none>" { untagged = append(untagged, h) diff --git a/cmd/podman/images/utils_linux.go b/cmd/podman/images/utils_linux.go index 5923716ec..935a45667 100644 --- a/cmd/podman/images/utils_linux.go +++ b/cmd/podman/images/utils_linux.go @@ -26,7 +26,7 @@ func setupPipe() (string, func() <-chan error, error) { if e := os.RemoveAll(pipeDir); e != nil { logrus.Errorf("Removing named pipe: %q", e) } - return "", nil, fmt.Errorf("error creating named pipe: %w", err) + return "", nil, fmt.Errorf("creating named pipe: %w", err) } go func() { fpipe, err := os.Open(pipePath) diff --git a/cmd/podman/machine/info.go b/cmd/podman/machine/info.go index 418060675..1151f9e86 100644 --- a/cmd/podman/machine/info.go +++ b/cmd/podman/machine/info.go @@ -57,7 +57,7 @@ func info(cmd *cobra.Command, args []string) error { info := entities.MachineInfo{} version, err := define.GetVersion() if err != nil { - return fmt.Errorf("error getting version info %w", err) + return fmt.Errorf("getting version info %w", err) } info.Version = version diff --git a/cmd/podman/pods/logs.go b/cmd/podman/pods/logs.go index 0102d4b71..7093a7fa8 100644 --- a/cmd/podman/pods/logs.go +++ b/cmd/podman/pods/logs.go @@ -101,7 +101,7 @@ func logs(_ *cobra.Command, args []string) error { // parse time, error out if something is wrong since, err := util.ParseInputTime(logsPodOptions.SinceRaw, true) if err != nil { - return fmt.Errorf("error parsing --since %q: %w", logsPodOptions.SinceRaw, err) + return fmt.Errorf("parsing --since %q: %w", logsPodOptions.SinceRaw, err) } logsPodOptions.Since = since } @@ -109,7 +109,7 @@ func logs(_ *cobra.Command, args []string) error { // parse time, error out if something is wrong until, err := util.ParseInputTime(logsPodOptions.UntilRaw, false) if err != nil { - return fmt.Errorf("error parsing --until %q: %w", logsPodOptions.UntilRaw, err) + return fmt.Errorf("parsing --until %q: %w", logsPodOptions.UntilRaw, err) } logsPodOptions.Until = until } diff --git a/cmd/podman/system/dial_stdio.go b/cmd/podman/system/dial_stdio.go index 42ce65746..db079856c 100644 --- a/cmd/podman/system/dial_stdio.go +++ b/cmd/podman/system/dial_stdio.go @@ -97,7 +97,7 @@ func copier(to halfWriteCloser, from halfReadCloser, debugDescription string) er } }() if _, err := io.Copy(to, from); err != nil { - return fmt.Errorf("error while Copy (%s): %w", debugDescription, err) + return fmt.Errorf("while Copy (%s): %w", debugDescription, err) } return nil } diff --git a/docs/source/markdown/options/volume.md b/docs/source/markdown/options/volume.md index 6d0d9a4b3..9c4a7f981 100644 --- a/docs/source/markdown/options/volume.md +++ b/docs/source/markdown/options/volume.md @@ -1,7 +1,7 @@ #### **--volume**, **-v**=*[[SOURCE-VOLUME|HOST-DIR:]CONTAINER-DIR[:OPTIONS]]* Create a bind mount. If `-v /HOST-DIR:/CONTAINER-DIR` is specified, Podman -bind mounts `/HOST-DIR` in the host to `/CONTAINER-DIR` in the Podman +bind mounts `/HOST-DIR` from the host into `/CONTAINER-DIR` in the Podman container. Similarly, `-v SOURCE-VOLUME:/CONTAINER-DIR` will mount the named volume from the host into the container. If no such named volume exists, Podman will create one. (Note when using the remote client, including Mac and Windows (excluding WSL2) machines, the volumes will be mounted from the remote server, not necessarily the client machine.) diff --git a/docs/tutorials/image_signing.md b/docs/tutorials/image_signing.md index 0d1d63de2..f17aa0620 100644 --- a/docs/tutorials/image_signing.md +++ b/docs/tutorials/image_signing.md @@ -173,7 +173,7 @@ Then a pull is not possible any more: ```bash sudo podman pull --tls-verify=false localhost:5000/alpine Trying to pull localhost:5000/alpine... -Error: error pulling image "localhost:5000/alpine": unable to pull localhost:5000/alpine: unable to pull image: Source image rejected: Invalid GPG signature: … +Error: pulling image "localhost:5000/alpine": unable to pull localhost:5000/alpine: unable to pull image: Source image rejected: Invalid GPG signature: … ``` So in general there are four main things to be taken into consideration when diff --git a/hack/podman-registry-go/registry.go b/hack/podman-registry-go/registry.go index d66d092b6..30da3b6da 100644 --- a/hack/podman-registry-go/registry.go +++ b/hack/podman-registry-go/registry.go @@ -57,7 +57,7 @@ func StartWithOptions(options *Options) (*Registry, error) { // Start a registry. out, err := utils.ExecCmd(binary, args...) if err != nil { - return nil, fmt.Errorf("error running %q: %s: %w", binary, out, err) + return nil, fmt.Errorf("running %q: %s: %w", binary, out, err) } // Parse the output. @@ -112,7 +112,7 @@ func (r *Registry) Stop() error { return nil } if _, err := utils.ExecCmd(binary, "-P", r.Port, "stop"); err != nil { - return fmt.Errorf("error stopping registry (%v) with %q: %w", *r, binary, err) + return fmt.Errorf("stopping registry (%v) with %q: %w", *r, binary, err) } r.running = false return nil diff --git a/libpod/boltdb_state.go b/libpod/boltdb_state.go index e5a7e20fc..4fd95a3cf 100644 --- a/libpod/boltdb_state.go +++ b/libpod/boltdb_state.go @@ -85,7 +85,7 @@ func NewBoltState(path string, runtime *Runtime) (State, error) { db, err := bolt.Open(path, 0600, nil) if err != nil { - return nil, fmt.Errorf("error opening database %s: %w", path, err) + return nil, fmt.Errorf("opening database %s: %w", path, err) } // Everywhere else, we use s.deferredCloseDBCon(db) to ensure the state's DB // mutex is also unlocked. @@ -123,7 +123,7 @@ func NewBoltState(path string, runtime *Runtime) (State, error) { return nil }) if err != nil { - return nil, fmt.Errorf("error checking DB schema: %w", err) + return nil, fmt.Errorf("checking DB schema: %w", err) } if !needsUpdate { @@ -135,13 +135,13 @@ func NewBoltState(path string, runtime *Runtime) (State, error) { err = db.Update(func(tx *bolt.Tx) error { for _, bkt := range createBuckets { if _, err := tx.CreateBucketIfNotExists(bkt); err != nil { - return fmt.Errorf("error creating bucket %s: %w", string(bkt), err) + return fmt.Errorf("creating bucket %s: %w", string(bkt), err) } } return nil }) if err != nil { - return nil, fmt.Errorf("error creating buckets for DB: %w", err) + return nil, fmt.Errorf("creating buckets for DB: %w", err) } state.valid = true @@ -220,11 +220,11 @@ func (s *BoltState) Refresh() error { return nil }) if err != nil { - return fmt.Errorf("error reading exit codes bucket: %w", err) + return fmt.Errorf("reading exit codes bucket: %w", err) } for _, id := range toRemoveExitCodes { if err := exitCodeBucket.Delete([]byte(id)); err != nil { - return fmt.Errorf("error removing exit code for ID %s: %w", id, err) + return fmt.Errorf("removing exit code for ID %s: %w", id, err) } } @@ -276,7 +276,7 @@ func (s *BoltState) Refresh() error { state := new(podState) if err := json.Unmarshal(stateBytes, state); err != nil { - return fmt.Errorf("error unmarshalling state for pod %s: %w", string(id), err) + return fmt.Errorf("unmarshalling state for pod %s: %w", string(id), err) } // Clear the Cgroup path @@ -284,11 +284,11 @@ func (s *BoltState) Refresh() error { newStateBytes, err := json.Marshal(state) if err != nil { - return fmt.Errorf("error marshalling modified state for pod %s: %w", string(id), err) + return fmt.Errorf("marshalling modified state for pod %s: %w", string(id), err) } if err := podBkt.Put(stateKey, newStateBytes); err != nil { - return fmt.Errorf("error updating state for pod %s in DB: %w", string(id), err) + return fmt.Errorf("updating state for pod %s in DB: %w", string(id), err) } // It's not a container, nothing to do @@ -297,7 +297,7 @@ func (s *BoltState) Refresh() error { // First, delete the network namespace if err := ctrBkt.Delete(netNSKey); err != nil { - return fmt.Errorf("error removing network namespace for container %s: %w", string(id), err) + return fmt.Errorf("removing network namespace for container %s: %w", string(id), err) } stateBytes := ctrBkt.Get(stateKey) @@ -309,18 +309,18 @@ func (s *BoltState) Refresh() error { state := new(ContainerState) if err := json.Unmarshal(stateBytes, state); err != nil { - return fmt.Errorf("error unmarshalling state for container %s: %w", string(id), err) + return fmt.Errorf("unmarshalling state for container %s: %w", string(id), err) } resetState(state) newStateBytes, err := json.Marshal(state) if err != nil { - return fmt.Errorf("error marshalling modified state for container %s: %w", string(id), err) + return fmt.Errorf("marshalling modified state for container %s: %w", string(id), err) } if err := ctrBkt.Put(stateKey, newStateBytes); err != nil { - return fmt.Errorf("error updating state for container %s in DB: %w", string(id), err) + return fmt.Errorf("updating state for container %s in DB: %w", string(id), err) } // Delete all exec sessions, if there are any @@ -338,7 +338,7 @@ func (s *BoltState) Refresh() error { } for _, execID := range toRemove { if err := ctrExecBkt.Delete([]byte(execID)); err != nil { - return fmt.Errorf("error removing exec session %s from container %s: %w", execID, string(id), err) + return fmt.Errorf("removing exec session %s from container %s: %w", execID, string(id), err) } } } @@ -358,12 +358,12 @@ func (s *BoltState) Refresh() error { if testID := namesBucket.Get(name); testID != nil { logrus.Infof("Found dangling name %s (ID %s) in database", string(name), id) if err := namesBucket.Delete(name); err != nil { - return fmt.Errorf("error removing dangling name %s (ID %s) from database: %w", string(name), id, err) + return fmt.Errorf("removing dangling name %s (ID %s) from database: %w", string(name), id, err) } } } if err := idBucket.Delete([]byte(id)); err != nil { - return fmt.Errorf("error removing dangling ID %s from database: %w", id, err) + return fmt.Errorf("removing dangling ID %s from database: %w", id, err) } } @@ -384,7 +384,7 @@ func (s *BoltState) Refresh() error { oldState := new(VolumeState) if err := json.Unmarshal(volStateBytes, oldState); err != nil { - return fmt.Errorf("error unmarshalling state for volume %s: %w", string(id), err) + return fmt.Errorf("unmarshalling state for volume %s: %w", string(id), err) } // Reset mount count to 0 @@ -393,11 +393,11 @@ func (s *BoltState) Refresh() error { newState, err := json.Marshal(oldState) if err != nil { - return fmt.Errorf("error marshalling state for volume %s: %w", string(id), err) + return fmt.Errorf("marshalling state for volume %s: %w", string(id), err) } if err := dbVol.Put(stateKey, newState); err != nil { - return fmt.Errorf("error storing new state for volume %s: %w", string(id), err) + return fmt.Errorf("storing new state for volume %s: %w", string(id), err) } return nil @@ -421,7 +421,7 @@ func (s *BoltState) Refresh() error { for _, execSession := range toRemoveExec { if err := execBucket.Delete([]byte(execSession)); err != nil { - return fmt.Errorf("error deleting exec session %s registry from database: %w", execSession, err) + return fmt.Errorf("deleting exec session %s registry from database: %w", execSession, err) } } @@ -841,7 +841,7 @@ func (s *BoltState) UpdateContainer(ctr *Container) error { } if err := json.Unmarshal(newStateBytes, newState); err != nil { - return fmt.Errorf("error unmarshalling container %s state: %w", ctr.ID(), err) + return fmt.Errorf("unmarshalling container %s state: %w", ctr.ID(), err) } netNSBytes := ctrToUpdate.Get(netNSKey) @@ -886,7 +886,7 @@ func (s *BoltState) SaveContainer(ctr *Container) error { stateJSON, err := json.Marshal(ctr.state) if err != nil { - return fmt.Errorf("error marshalling container %s state to JSON: %w", ctr.ID(), err) + return fmt.Errorf("marshalling container %s state to JSON: %w", ctr.ID(), err) } netNSPath := getNetNSPath(ctr) @@ -912,17 +912,17 @@ func (s *BoltState) SaveContainer(ctr *Container) error { // Update the state if err := ctrToSave.Put(stateKey, stateJSON); err != nil { - return fmt.Errorf("error updating container %s state in DB: %w", ctr.ID(), err) + return fmt.Errorf("updating container %s state in DB: %w", ctr.ID(), err) } if netNSPath != "" { if err := ctrToSave.Put(netNSKey, []byte(netNSPath)); err != nil { - return fmt.Errorf("error updating network namespace path for container %s in DB: %w", ctr.ID(), err) + return fmt.Errorf("updating network namespace path for container %s in DB: %w", ctr.ID(), err) } } else { // Delete the existing network namespace if err := ctrToSave.Delete(netNSKey); err != nil { - return fmt.Errorf("error removing network namespace path for container %s in DB: %w", ctr.ID(), err) + return fmt.Errorf("removing network namespace path for container %s in DB: %w", ctr.ID(), err) } } @@ -1142,7 +1142,7 @@ func (s *BoltState) GetNetworks(ctr *Container) (map[string]types.PerNetworkOpti if ctrNetworkBkt == nil { ctrNetworkBkt, err = dbCtr.CreateBucket(networksBkt) if err != nil { - return fmt.Errorf("error creating networks bucket for container %s: %w", ctr.ID(), err) + return fmt.Errorf("creating networks bucket for container %s: %w", ctr.ID(), err) } // the container has no networks in the db lookup config and write to the db networkList = ctr.config.NetworksDeprecated @@ -1249,7 +1249,7 @@ func (s *BoltState) NetworkConnect(ctr *Container, network string, opts types.Pe optBytes, err := json.Marshal(opts) if err != nil { - return fmt.Errorf("error marshalling network options JSON for container %s: %w", ctr.ID(), err) + return fmt.Errorf("marshalling network options JSON for container %s: %w", ctr.ID(), err) } ctrID := []byte(ctr.ID()) @@ -1283,7 +1283,7 @@ func (s *BoltState) NetworkConnect(ctr *Container, network string, opts types.Pe // Add the network if err := ctrNetworksBkt.Put([]byte(network), optBytes); err != nil { - return fmt.Errorf("error adding container %s to network %s in DB: %w", ctr.ID(), network, err) + return fmt.Errorf("adding container %s to network %s in DB: %w", ctr.ID(), network, err) } return nil @@ -1340,7 +1340,7 @@ func (s *BoltState) NetworkDisconnect(ctr *Container, network string) error { } if err := ctrNetworksBkt.Delete([]byte(network)); err != nil { - return fmt.Errorf("error removing container %s from network %s: %w", ctr.ID(), network, err) + return fmt.Errorf("removing container %s from network %s: %w", ctr.ID(), network, err) } if ctrAliasesBkt != nil { @@ -1350,7 +1350,7 @@ func (s *BoltState) NetworkDisconnect(ctr *Container, network string) error { } if err := ctrAliasesBkt.DeleteBucket([]byte(network)); err != nil { - return fmt.Errorf("error removing container %s network aliases for network %s: %w", ctr.ID(), network, err) + return fmt.Errorf("removing container %s network aliases for network %s: %w", ctr.ID(), network, err) } } @@ -1626,7 +1626,7 @@ func (s *BoltState) AddExecSession(ctr *Container, session *ExecSession) error { ctrExecSessionBucket, err := dbCtr.CreateBucketIfNotExists(execBkt) if err != nil { - return fmt.Errorf("error creating exec sessions bucket for container %s: %w", ctr.ID(), err) + return fmt.Errorf("creating exec sessions bucket for container %s: %w", ctr.ID(), err) } execExists := execBucket.Get(sessionID) @@ -1635,11 +1635,11 @@ func (s *BoltState) AddExecSession(ctr *Container, session *ExecSession) error { } if err := execBucket.Put(sessionID, ctrID); err != nil { - return fmt.Errorf("error adding exec session %s to DB: %w", session.ID(), err) + return fmt.Errorf("adding exec session %s to DB: %w", session.ID(), err) } if err := ctrExecSessionBucket.Put(sessionID, ctrID); err != nil { - return fmt.Errorf("error adding exec session %s to container %s in DB: %w", session.ID(), ctr.ID(), err) + return fmt.Errorf("adding exec session %s to container %s in DB: %w", session.ID(), ctr.ID(), err) } return nil @@ -1716,7 +1716,7 @@ func (s *BoltState) RemoveExecSession(session *ExecSession) error { } if err := execBucket.Delete(sessionID); err != nil { - return fmt.Errorf("error removing exec session %s from database: %w", session.ID(), err) + return fmt.Errorf("removing exec session %s from database: %w", session.ID(), err) } dbCtr := ctrBucket.Bucket(containerID) @@ -1739,7 +1739,7 @@ func (s *BoltState) RemoveExecSession(session *ExecSession) error { ctrSessionExists := ctrExecBucket.Get(sessionID) if ctrSessionExists != nil { if err := ctrExecBucket.Delete(sessionID); err != nil { - return fmt.Errorf("error removing exec session %s from container %s in database: %w", session.ID(), session.ContainerID(), err) + return fmt.Errorf("removing exec session %s from container %s in database: %w", session.ID(), session.ContainerID(), err) } } @@ -1847,7 +1847,7 @@ func (s *BoltState) RemoveContainerExecSessions(ctr *Container) error { for _, session := range sessions { if err := ctrExecSessions.Delete([]byte(session)); err != nil { - return fmt.Errorf("error removing container %s exec session %s from database: %w", ctr.ID(), session, err) + return fmt.Errorf("removing container %s exec session %s from database: %w", ctr.ID(), session, err) } // Check if the session exists in the global table // before removing. It should, but in cases where the DB @@ -1861,7 +1861,7 @@ func (s *BoltState) RemoveContainerExecSessions(ctr *Container) error { return fmt.Errorf("database mismatch: exec session %s is associated with containers %s and %s: %w", session, ctr.ID(), string(sessionExists), define.ErrInternal) } if err := execBucket.Delete([]byte(session)); err != nil { - return fmt.Errorf("error removing container %s exec session %s from exec sessions: %w", ctr.ID(), session, err) + return fmt.Errorf("removing container %s exec session %s from exec sessions: %w", ctr.ID(), session, err) } } @@ -1884,7 +1884,7 @@ func (s *BoltState) RewriteContainerConfig(ctr *Container, newCfg *ContainerConf newCfgJSON, err := json.Marshal(newCfg) if err != nil { - return fmt.Errorf("error marshalling new configuration JSON for container %s: %w", ctr.ID(), err) + return fmt.Errorf("marshalling new configuration JSON for container %s: %w", ctr.ID(), err) } db, err := s.getDBCon() @@ -1906,7 +1906,7 @@ func (s *BoltState) RewriteContainerConfig(ctr *Container, newCfg *ContainerConf } if err := ctrDB.Put(configKey, newCfgJSON); err != nil { - return fmt.Errorf("error updating container %s config JSON: %w", ctr.ID(), err) + return fmt.Errorf("updating container %s config JSON: %w", ctr.ID(), err) } return nil @@ -1937,7 +1937,7 @@ func (s *BoltState) SafeRewriteContainerConfig(ctr *Container, oldName, newName newCfgJSON, err := json.Marshal(newCfg) if err != nil { - return fmt.Errorf("error marshalling new configuration JSON for container %s: %w", ctr.ID(), err) + return fmt.Errorf("marshalling new configuration JSON for container %s: %w", ctr.ID(), err) } db, err := s.getDBCon() @@ -1978,16 +1978,16 @@ func (s *BoltState) SafeRewriteContainerConfig(ctr *Container, oldName, newName // buckets are ID-indexed so we just need to // overwrite the values there. if err := namesBkt.Delete([]byte(oldName)); err != nil { - return fmt.Errorf("error deleting container %s old name from DB for rename: %w", ctr.ID(), err) + return fmt.Errorf("deleting container %s old name from DB for rename: %w", ctr.ID(), err) } if err := idBkt.Put([]byte(ctr.ID()), []byte(newName)); err != nil { - return fmt.Errorf("error renaming container %s in ID bucket in DB: %w", ctr.ID(), err) + return fmt.Errorf("renaming container %s in ID bucket in DB: %w", ctr.ID(), err) } if err := namesBkt.Put([]byte(newName), []byte(ctr.ID())); err != nil { - return fmt.Errorf("error adding new name %s for container %s in DB: %w", newName, ctr.ID(), err) + return fmt.Errorf("adding new name %s for container %s in DB: %w", newName, ctr.ID(), err) } if err := allCtrsBkt.Put([]byte(ctr.ID()), []byte(newName)); err != nil { - return fmt.Errorf("error renaming container %s in all containers bucket in DB: %w", ctr.ID(), err) + return fmt.Errorf("renaming container %s in all containers bucket in DB: %w", ctr.ID(), err) } if ctr.config.Pod != "" { podsBkt, err := getPodBucket(tx) @@ -2003,7 +2003,7 @@ func (s *BoltState) SafeRewriteContainerConfig(ctr *Container, oldName, newName return fmt.Errorf("pod %s does not have a containers bucket: %w", ctr.config.Pod, define.ErrInternal) } if err := podCtrBkt.Put([]byte(ctr.ID()), []byte(newName)); err != nil { - return fmt.Errorf("error renaming container %s in pod %s members bucket: %w", ctr.ID(), ctr.config.Pod, err) + return fmt.Errorf("renaming container %s in pod %s members bucket: %w", ctr.ID(), ctr.config.Pod, err) } } } @@ -2021,7 +2021,7 @@ func (s *BoltState) SafeRewriteContainerConfig(ctr *Container, oldName, newName } if err := ctrDB.Put(configKey, newCfgJSON); err != nil { - return fmt.Errorf("error updating container %s config JSON: %w", ctr.ID(), err) + return fmt.Errorf("updating container %s config JSON: %w", ctr.ID(), err) } return nil @@ -2043,7 +2043,7 @@ func (s *BoltState) RewritePodConfig(pod *Pod, newCfg *PodConfig) error { newCfgJSON, err := json.Marshal(newCfg) if err != nil { - return fmt.Errorf("error marshalling new configuration JSON for pod %s: %w", pod.ID(), err) + return fmt.Errorf("marshalling new configuration JSON for pod %s: %w", pod.ID(), err) } db, err := s.getDBCon() @@ -2065,7 +2065,7 @@ func (s *BoltState) RewritePodConfig(pod *Pod, newCfg *PodConfig) error { } if err := podDB.Put(configKey, newCfgJSON); err != nil { - return fmt.Errorf("error updating pod %s config JSON: %w", pod.ID(), err) + return fmt.Errorf("updating pod %s config JSON: %w", pod.ID(), err) } return nil @@ -2087,7 +2087,7 @@ func (s *BoltState) RewriteVolumeConfig(volume *Volume, newCfg *VolumeConfig) er newCfgJSON, err := json.Marshal(newCfg) if err != nil { - return fmt.Errorf("error marshalling new configuration JSON for volume %q: %w", volume.Name(), err) + return fmt.Errorf("marshalling new configuration JSON for volume %q: %w", volume.Name(), err) } db, err := s.getDBCon() @@ -2109,7 +2109,7 @@ func (s *BoltState) RewriteVolumeConfig(volume *Volume, newCfg *VolumeConfig) er } if err := volDB.Put(configKey, newCfgJSON); err != nil { - return fmt.Errorf("error updating volume %q config JSON: %w", volume.Name(), err) + return fmt.Errorf("updating volume %q config JSON: %w", volume.Name(), err) } return nil @@ -2522,7 +2522,7 @@ func (s *BoltState) AddVolume(volume *Volume) error { volConfigJSON, err := json.Marshal(volume.config) if err != nil { - return fmt.Errorf("error marshalling volume %s config to JSON: %w", volume.Name(), err) + return fmt.Errorf("marshalling volume %s config to JSON: %w", volume.Name(), err) } // Volume state is allowed to not exist @@ -2530,7 +2530,7 @@ func (s *BoltState) AddVolume(volume *Volume) error { if volume.state != nil { volStateJSON, err = json.Marshal(volume.state) if err != nil { - return fmt.Errorf("error marshalling volume %s state to JSON: %w", volume.Name(), err) + return fmt.Errorf("marshalling volume %s state to JSON: %w", volume.Name(), err) } } @@ -2561,27 +2561,27 @@ func (s *BoltState) AddVolume(volume *Volume) error { // Make a bucket for it newVol, err := volBkt.CreateBucket(volName) if err != nil { - return fmt.Errorf("error creating bucket for volume %s: %w", volume.Name(), err) + return fmt.Errorf("creating bucket for volume %s: %w", volume.Name(), err) } // Make a subbucket for the containers using the volume. Dependent container IDs will be addedremoved to // this bucket in addcontainer/removeContainer if _, err := newVol.CreateBucket(volDependenciesBkt); err != nil { - return fmt.Errorf("error creating bucket for containers using volume %s: %w", volume.Name(), err) + return fmt.Errorf("creating bucket for containers using volume %s: %w", volume.Name(), err) } if err := newVol.Put(configKey, volConfigJSON); err != nil { - return fmt.Errorf("error storing volume %s configuration in DB: %w", volume.Name(), err) + return fmt.Errorf("storing volume %s configuration in DB: %w", volume.Name(), err) } if volStateJSON != nil { if err := newVol.Put(stateKey, volStateJSON); err != nil { - return fmt.Errorf("error storing volume %s state in DB: %w", volume.Name(), err) + return fmt.Errorf("storing volume %s state in DB: %w", volume.Name(), err) } } if err := allVolsBkt.Put(volName, volName); err != nil { - return fmt.Errorf("error storing volume %s in all volumes bucket in DB: %w", volume.Name(), err) + return fmt.Errorf("storing volume %s in all volumes bucket in DB: %w", volume.Name(), err) } return nil @@ -2650,7 +2650,7 @@ func (s *BoltState) RemoveVolume(volume *Volume) error { return nil }) if err != nil { - return fmt.Errorf("error getting list of dependencies from dependencies bucket for volumes %q: %w", volume.Name(), err) + return fmt.Errorf("getting list of dependencies from dependencies bucket for volumes %q: %w", volume.Name(), err) } if len(deps) > 0 { return fmt.Errorf("volume %s is being used by container(s) %s: %w", volume.Name(), strings.Join(deps, ","), define.ErrVolumeBeingUsed) @@ -2660,10 +2660,10 @@ func (s *BoltState) RemoveVolume(volume *Volume) error { // volume is ready for removal // Let's kick it out if err := allVolsBkt.Delete(volName); err != nil { - return fmt.Errorf("error removing volume %s from all volumes bucket in DB: %w", volume.Name(), err) + return fmt.Errorf("removing volume %s from all volumes bucket in DB: %w", volume.Name(), err) } if err := volBkt.DeleteBucket(volName); err != nil { - return fmt.Errorf("error removing volume %s from DB: %w", volume.Name(), err) + return fmt.Errorf("removing volume %s from DB: %w", volume.Name(), err) } return nil @@ -2710,7 +2710,7 @@ func (s *BoltState) UpdateVolume(volume *Volume) error { } if err := json.Unmarshal(stateBytes, newState); err != nil { - return fmt.Errorf("error unmarshalling volume %s state: %w", volume.Name(), err) + return fmt.Errorf("unmarshalling volume %s state: %w", volume.Name(), err) } return nil @@ -2740,7 +2740,7 @@ func (s *BoltState) SaveVolume(volume *Volume) error { if volume.state != nil { stateJSON, err := json.Marshal(volume.state) if err != nil { - return fmt.Errorf("error marshalling volume %s state to JSON: %w", volume.Name(), err) + return fmt.Errorf("marshalling volume %s state to JSON: %w", volume.Name(), err) } newStateJSON = stateJSON } @@ -3060,12 +3060,12 @@ func (s *BoltState) AddPod(pod *Pod) error { podConfigJSON, err := json.Marshal(pod.config) if err != nil { - return fmt.Errorf("error marshalling pod %s config to JSON: %w", pod.ID(), err) + return fmt.Errorf("marshalling pod %s config to JSON: %w", pod.ID(), err) } podStateJSON, err := json.Marshal(pod.state) if err != nil { - return fmt.Errorf("error marshalling pod %s state to JSON: %w", pod.ID(), err) + return fmt.Errorf("marshalling pod %s state to JSON: %w", pod.ID(), err) } db, err := s.getDBCon() @@ -3122,40 +3122,40 @@ func (s *BoltState) AddPod(pod *Pod) error { // Make a bucket for it newPod, err := podBkt.CreateBucket(podID) if err != nil { - return fmt.Errorf("error creating bucket for pod %s: %w", pod.ID(), err) + return fmt.Errorf("creating bucket for pod %s: %w", pod.ID(), err) } // Make a subbucket for pod containers if _, err := newPod.CreateBucket(containersBkt); err != nil { - return fmt.Errorf("error creating bucket for pod %s containers: %w", pod.ID(), err) + return fmt.Errorf("creating bucket for pod %s containers: %w", pod.ID(), err) } if err := newPod.Put(configKey, podConfigJSON); err != nil { - return fmt.Errorf("error storing pod %s configuration in DB: %w", pod.ID(), err) + return fmt.Errorf("storing pod %s configuration in DB: %w", pod.ID(), err) } if err := newPod.Put(stateKey, podStateJSON); err != nil { - return fmt.Errorf("error storing pod %s state JSON in DB: %w", pod.ID(), err) + return fmt.Errorf("storing pod %s state JSON in DB: %w", pod.ID(), err) } if podNamespace != nil { if err := newPod.Put(namespaceKey, podNamespace); err != nil { - return fmt.Errorf("error storing pod %s namespace in DB: %w", pod.ID(), err) + return fmt.Errorf("storing pod %s namespace in DB: %w", pod.ID(), err) } if err := nsBkt.Put(podID, podNamespace); err != nil { - return fmt.Errorf("error storing pod %s namespace in DB: %w", pod.ID(), err) + return fmt.Errorf("storing pod %s namespace in DB: %w", pod.ID(), err) } } // Add us to the ID and names buckets if err := idsBkt.Put(podID, podName); err != nil { - return fmt.Errorf("error storing pod %s ID in DB: %w", pod.ID(), err) + return fmt.Errorf("storing pod %s ID in DB: %w", pod.ID(), err) } if err := namesBkt.Put(podName, podID); err != nil { - return fmt.Errorf("error storing pod %s name in DB: %w", pod.Name(), err) + return fmt.Errorf("storing pod %s name in DB: %w", pod.Name(), err) } if err := allPodsBkt.Put(podID, podName); err != nil { - return fmt.Errorf("error storing pod %s in all pods bucket in DB: %w", pod.ID(), err) + return fmt.Errorf("storing pod %s in all pods bucket in DB: %w", pod.ID(), err) } return nil @@ -3240,19 +3240,19 @@ func (s *BoltState) RemovePod(pod *Pod) error { // Pod is empty, and ready for removal // Let's kick it out if err := idsBkt.Delete(podID); err != nil { - return fmt.Errorf("error removing pod %s ID from DB: %w", pod.ID(), err) + return fmt.Errorf("removing pod %s ID from DB: %w", pod.ID(), err) } if err := namesBkt.Delete(podName); err != nil { - return fmt.Errorf("error removing pod %s name (%s) from DB: %w", pod.ID(), pod.Name(), err) + return fmt.Errorf("removing pod %s name (%s) from DB: %w", pod.ID(), pod.Name(), err) } if err := nsBkt.Delete(podID); err != nil { - return fmt.Errorf("error removing pod %s namespace from DB: %w", pod.ID(), err) + return fmt.Errorf("removing pod %s namespace from DB: %w", pod.ID(), err) } if err := allPodsBkt.Delete(podID); err != nil { - return fmt.Errorf("error removing pod %s ID from all pods bucket in DB: %w", pod.ID(), err) + return fmt.Errorf("removing pod %s ID from all pods bucket in DB: %w", pod.ID(), err) } if err := podBkt.DeleteBucket(podID); err != nil { - return fmt.Errorf("error removing pod %s from DB: %w", pod.ID(), err) + return fmt.Errorf("removing pod %s from DB: %w", pod.ID(), err) } return nil @@ -3353,19 +3353,19 @@ func (s *BoltState) RemovePodContainers(pod *Pod) error { // Dependencies are set, we're clear to remove if err := ctrBkt.DeleteBucket(id); err != nil { - return fmt.Errorf("error deleting container %s from DB: %w", string(id), define.ErrInternal) + return fmt.Errorf("deleting container %s from DB: %w", string(id), define.ErrInternal) } if err := idsBkt.Delete(id); err != nil { - return fmt.Errorf("error deleting container %s ID in DB: %w", string(id), err) + return fmt.Errorf("deleting container %s ID in DB: %w", string(id), err) } if err := namesBkt.Delete(name); err != nil { - return fmt.Errorf("error deleting container %s name in DB: %w", string(id), err) + return fmt.Errorf("deleting container %s name in DB: %w", string(id), err) } if err := allCtrsBkt.Delete(id); err != nil { - return fmt.Errorf("error deleting container %s ID from all containers bucket in DB: %w", string(id), err) + return fmt.Errorf("deleting container %s ID from all containers bucket in DB: %w", string(id), err) } return nil @@ -3376,10 +3376,10 @@ func (s *BoltState) RemovePodContainers(pod *Pod) error { // Delete and recreate the bucket to empty it if err := podDB.DeleteBucket(containersBkt); err != nil { - return fmt.Errorf("error removing pod %s containers bucket: %w", pod.ID(), err) + return fmt.Errorf("removing pod %s containers bucket: %w", pod.ID(), err) } if _, err := podDB.CreateBucket(containersBkt); err != nil { - return fmt.Errorf("error recreating pod %s containers bucket: %w", pod.ID(), err) + return fmt.Errorf("recreating pod %s containers bucket: %w", pod.ID(), err) } return nil @@ -3496,7 +3496,7 @@ func (s *BoltState) UpdatePod(pod *Pod) error { } if err := json.Unmarshal(podStateBytes, newState); err != nil { - return fmt.Errorf("error unmarshalling pod %s state JSON: %w", pod.ID(), err) + return fmt.Errorf("unmarshalling pod %s state JSON: %w", pod.ID(), err) } return nil @@ -3526,7 +3526,7 @@ func (s *BoltState) SavePod(pod *Pod) error { stateJSON, err := json.Marshal(pod.state) if err != nil { - return fmt.Errorf("error marshalling pod %s state to JSON: %w", pod.ID(), err) + return fmt.Errorf("marshalling pod %s state to JSON: %w", pod.ID(), err) } db, err := s.getDBCon() @@ -3551,7 +3551,7 @@ func (s *BoltState) SavePod(pod *Pod) error { // Set the pod state JSON if err := podDB.Put(stateKey, stateJSON); err != nil { - return fmt.Errorf("error updating pod %s state in database: %w", pod.ID(), err) + return fmt.Errorf("updating pod %s state in database: %w", pod.ID(), err) } return nil diff --git a/libpod/boltdb_state_internal.go b/libpod/boltdb_state_internal.go index f28fadfa9..87f1fa4eb 100644 --- a/libpod/boltdb_state_internal.go +++ b/libpod/boltdb_state_internal.go @@ -195,7 +195,7 @@ func checkRuntimeConfig(db *bolt.DB, rt *Runtime) error { } if err := configBkt.Put(missing.key, dbValue); err != nil { - return fmt.Errorf("error updating %s in DB runtime config: %w", missing.name, err) + return fmt.Errorf("updating %s in DB runtime config: %w", missing.name, err) } } @@ -254,7 +254,7 @@ func (s *BoltState) getDBCon() (*bolt.DB, error) { db, err := bolt.Open(s.dbPath, 0600, nil) if err != nil { - return nil, fmt.Errorf("error opening database %s: %w", s.dbPath, err) + return nil, fmt.Errorf("opening database %s: %w", s.dbPath, err) } return db, nil @@ -403,7 +403,7 @@ func (s *BoltState) getContainerConfigFromDB(id []byte, config *ContainerConfig, } if err := json.Unmarshal(configBytes, config); err != nil { - return fmt.Errorf("error unmarshalling container %s config: %w", string(id), err) + return fmt.Errorf("unmarshalling container %s config: %w", string(id), err) } // convert ports to the new format if needed @@ -426,7 +426,7 @@ func (s *BoltState) getContainerFromDB(id []byte, ctr *Container, ctrsBkt *bolt. // Get the lock lock, err := s.runtime.lockManager.RetrieveLock(ctr.config.LockID) if err != nil { - return fmt.Errorf("error retrieving lock for container %s: %w", string(id), err) + return fmt.Errorf("retrieving lock for container %s: %w", string(id), err) } ctr.lock = lock @@ -489,13 +489,13 @@ func (s *BoltState) getPodFromDB(id []byte, pod *Pod, podBkt *bolt.Bucket) error } if err := json.Unmarshal(podConfigBytes, pod.config); err != nil { - return fmt.Errorf("error unmarshalling pod %s config from DB: %w", string(id), err) + return fmt.Errorf("unmarshalling pod %s config from DB: %w", string(id), err) } // Get the lock lock, err := s.runtime.lockManager.RetrieveLock(pod.config.LockID) if err != nil { - return fmt.Errorf("error retrieving lock for pod %s: %w", string(id), err) + return fmt.Errorf("retrieving lock for pod %s: %w", string(id), err) } pod.lock = lock @@ -517,14 +517,14 @@ func (s *BoltState) getVolumeFromDB(name []byte, volume *Volume, volBkt *bolt.Bu } if err := json.Unmarshal(volConfigBytes, volume.config); err != nil { - return fmt.Errorf("error unmarshalling volume %s config from DB: %w", string(name), err) + return fmt.Errorf("unmarshalling volume %s config from DB: %w", string(name), err) } // Volume state is allowed to be nil for legacy compatibility volStateBytes := volDB.Get(stateKey) if volStateBytes != nil { if err := json.Unmarshal(volStateBytes, volume.state); err != nil { - return fmt.Errorf("error unmarshalling volume %s state from DB: %w", string(name), err) + return fmt.Errorf("unmarshalling volume %s state from DB: %w", string(name), err) } } @@ -546,7 +546,7 @@ func (s *BoltState) getVolumeFromDB(name []byte, volume *Volume, volBkt *bolt.Bu // Get the lock lock, err := s.runtime.lockManager.RetrieveLock(volume.config.LockID) if err != nil { - return fmt.Errorf("error retrieving lock for volume %q: %w", string(name), err) + return fmt.Errorf("retrieving lock for volume %q: %w", string(name), err) } volume.lock = lock @@ -572,11 +572,11 @@ func (s *BoltState) addContainer(ctr *Container, pod *Pod) error { // JSON container structs to insert into DB configJSON, err := json.Marshal(ctr.config) if err != nil { - return fmt.Errorf("error marshalling container %s config to JSON: %w", ctr.ID(), err) + return fmt.Errorf("marshalling container %s config to JSON: %w", ctr.ID(), err) } stateJSON, err := json.Marshal(ctr.state) if err != nil { - return fmt.Errorf("error marshalling container %s state to JSON: %w", ctr.ID(), err) + return fmt.Errorf("marshalling container %s state to JSON: %w", ctr.ID(), err) } netNSPath := getNetNSPath(ctr) dependsCtrs := ctr.Dependencies() @@ -603,7 +603,7 @@ func (s *BoltState) addContainer(ctr *Container, pod *Pod) error { opts.Aliases = append(opts.Aliases, ctr.config.ID[:12]) optBytes, err := json.Marshal(opts) if err != nil { - return fmt.Errorf("error marshalling network options JSON for container %s: %w", ctr.ID(), err) + return fmt.Errorf("marshalling network options JSON for container %s: %w", ctr.ID(), err) } networks[net] = optBytes } @@ -694,60 +694,60 @@ func (s *BoltState) addContainer(ctr *Container, pod *Pod) error { // No overlapping containers // Add the new container to the DB if err := idsBucket.Put(ctrID, ctrName); err != nil { - return fmt.Errorf("error adding container %s ID to DB: %w", ctr.ID(), err) + return fmt.Errorf("adding container %s ID to DB: %w", ctr.ID(), err) } if err := namesBucket.Put(ctrName, ctrID); err != nil { - return fmt.Errorf("error adding container %s name (%s) to DB: %w", ctr.ID(), ctr.Name(), err) + return fmt.Errorf("adding container %s name (%s) to DB: %w", ctr.ID(), ctr.Name(), err) } if ctrNamespace != nil { if err := nsBucket.Put(ctrID, ctrNamespace); err != nil { - return fmt.Errorf("error adding container %s namespace (%q) to DB: %w", ctr.ID(), ctr.Namespace(), err) + return fmt.Errorf("adding container %s namespace (%q) to DB: %w", ctr.ID(), ctr.Namespace(), err) } } if err := allCtrsBucket.Put(ctrID, ctrName); err != nil { - return fmt.Errorf("error adding container %s to all containers bucket in DB: %w", ctr.ID(), err) + return fmt.Errorf("adding container %s to all containers bucket in DB: %w", ctr.ID(), err) } newCtrBkt, err := ctrBucket.CreateBucket(ctrID) if err != nil { - return fmt.Errorf("error adding container %s bucket to DB: %w", ctr.ID(), err) + return fmt.Errorf("adding container %s bucket to DB: %w", ctr.ID(), err) } if err := newCtrBkt.Put(configKey, configJSON); err != nil { - return fmt.Errorf("error adding container %s config to DB: %w", ctr.ID(), err) + return fmt.Errorf("adding container %s config to DB: %w", ctr.ID(), err) } if err := newCtrBkt.Put(stateKey, stateJSON); err != nil { - return fmt.Errorf("error adding container %s state to DB: %w", ctr.ID(), err) + return fmt.Errorf("adding container %s state to DB: %w", ctr.ID(), err) } if ctrNamespace != nil { if err := newCtrBkt.Put(namespaceKey, ctrNamespace); err != nil { - return fmt.Errorf("error adding container %s namespace to DB: %w", ctr.ID(), err) + return fmt.Errorf("adding container %s namespace to DB: %w", ctr.ID(), err) } } if pod != nil { if err := newCtrBkt.Put(podIDKey, []byte(pod.ID())); err != nil { - return fmt.Errorf("error adding container %s pod to DB: %w", ctr.ID(), err) + return fmt.Errorf("adding container %s pod to DB: %w", ctr.ID(), err) } } if netNSPath != "" { if err := newCtrBkt.Put(netNSKey, []byte(netNSPath)); err != nil { - return fmt.Errorf("error adding container %s netns path to DB: %w", ctr.ID(), err) + return fmt.Errorf("adding container %s netns path to DB: %w", ctr.ID(), err) } } if len(networks) > 0 { ctrNetworksBkt, err := newCtrBkt.CreateBucket(networksBkt) if err != nil { - return fmt.Errorf("error creating networks bucket for container %s: %w", ctr.ID(), err) + return fmt.Errorf("creating networks bucket for container %s: %w", ctr.ID(), err) } for network, opts := range networks { if err := ctrNetworksBkt.Put([]byte(network), opts); err != nil { - return fmt.Errorf("error adding network %q to networks bucket for container %s: %w", network, ctr.ID(), err) + return fmt.Errorf("adding network %q to networks bucket for container %s: %w", network, ctr.ID(), err) } } } if _, err := newCtrBkt.CreateBucket(dependenciesBkt); err != nil { - return fmt.Errorf("error creating dependencies bucket for container %s: %w", ctr.ID(), err) + return fmt.Errorf("creating dependencies bucket for container %s: %w", ctr.ID(), err) } // Add dependencies for the container @@ -784,14 +784,14 @@ func (s *BoltState) addContainer(ctr *Container, pod *Pod) error { return fmt.Errorf("container %s does not have a dependencies bucket: %w", dependsCtr, define.ErrInternal) } if err := depCtrDependsBkt.Put(ctrID, ctrName); err != nil { - return fmt.Errorf("error adding ctr %s as dependency of container %s: %w", ctr.ID(), dependsCtr, err) + return fmt.Errorf("adding ctr %s as dependency of container %s: %w", ctr.ID(), dependsCtr, err) } } // Add ctr to pod if pod != nil && podCtrs != nil { if err := podCtrs.Put(ctrID, ctrName); err != nil { - return fmt.Errorf("error adding container %s to pod %s: %w", ctr.ID(), pod.ID(), err) + return fmt.Errorf("adding container %s to pod %s: %w", ctr.ID(), pod.ID(), err) } } @@ -804,11 +804,11 @@ func (s *BoltState) addContainer(ctr *Container, pod *Pod) error { ctrDepsBkt, err := volDB.CreateBucketIfNotExists(volDependenciesBkt) if err != nil { - return fmt.Errorf("error creating volume %s dependencies bucket to add container %s: %w", vol.Name, ctr.ID(), err) + return fmt.Errorf("creating volume %s dependencies bucket to add container %s: %w", vol.Name, ctr.ID(), err) } if depExists := ctrDepsBkt.Get(ctrID); depExists == nil { if err := ctrDepsBkt.Put(ctrID, ctrID); err != nil { - return fmt.Errorf("error adding container %s to volume %s dependencies: %w", ctr.ID(), vol.Name, err) + return fmt.Errorf("adding container %s to volume %s dependencies: %w", ctr.ID(), vol.Name, err) } } } @@ -902,7 +902,7 @@ func (s *BoltState) removeContainer(ctr *Container, pod *Pod, tx *bolt.Tx) error return fmt.Errorf("container %s is not in pod %s: %w", ctr.ID(), pod.ID(), define.ErrNoSuchCtr) } if err := podCtrs.Delete(ctrID); err != nil { - return fmt.Errorf("error removing container %s from pod %s: %w", ctr.ID(), pod.ID(), err) + return fmt.Errorf("removing container %s from pod %s: %w", ctr.ID(), pod.ID(), err) } } } @@ -943,21 +943,21 @@ func (s *BoltState) removeContainer(ctr *Container, pod *Pod, tx *bolt.Tx) error } if err := ctrBucket.DeleteBucket(ctrID); err != nil { - return fmt.Errorf("error deleting container %s from DB: %w", ctr.ID(), define.ErrInternal) + return fmt.Errorf("deleting container %s from DB: %w", ctr.ID(), define.ErrInternal) } if err := idsBucket.Delete(ctrID); err != nil { - return fmt.Errorf("error deleting container %s ID in DB: %w", ctr.ID(), err) + return fmt.Errorf("deleting container %s ID in DB: %w", ctr.ID(), err) } if err := namesBucket.Delete(ctrName); err != nil { - return fmt.Errorf("error deleting container %s name in DB: %w", ctr.ID(), err) + return fmt.Errorf("deleting container %s name in DB: %w", ctr.ID(), err) } if err := nsBucket.Delete(ctrID); err != nil { - return fmt.Errorf("error deleting container %s namespace in DB: %w", ctr.ID(), err) + return fmt.Errorf("deleting container %s namespace in DB: %w", ctr.ID(), err) } if err := allCtrsBucket.Delete(ctrID); err != nil { - return fmt.Errorf("error deleting container %s from all containers bucket in DB: %w", ctr.ID(), err) + return fmt.Errorf("deleting container %s from all containers bucket in DB: %w", ctr.ID(), err) } depCtrs := ctr.Dependencies() @@ -986,7 +986,7 @@ func (s *BoltState) removeContainer(ctr *Container, pod *Pod, tx *bolt.Tx) error } if err := depCtrDependsBkt.Delete(ctrID); err != nil { - return fmt.Errorf("error removing container %s as a dependency of container %s: %w", ctr.ID(), depCtr, err) + return fmt.Errorf("removing container %s as a dependency of container %s: %w", ctr.ID(), depCtr, err) } } @@ -1005,7 +1005,7 @@ func (s *BoltState) removeContainer(ctr *Container, pod *Pod, tx *bolt.Tx) error } if depExists := ctrDepsBkt.Get(ctrID); depExists == nil { if err := ctrDepsBkt.Delete(ctrID); err != nil { - return fmt.Errorf("error deleting container %s dependency on volume %s: %w", ctr.ID(), vol.Name, err) + return fmt.Errorf("deleting container %s dependency on volume %s: %w", ctr.ID(), vol.Name, err) } } } diff --git a/libpod/boltdb_state_linux.go b/libpod/boltdb_state_linux.go index 813afd8bf..3d9f5b6a2 100644 --- a/libpod/boltdb_state_linux.go +++ b/libpod/boltdb_state_linux.go @@ -30,7 +30,7 @@ func replaceNetNS(netNSPath string, ctr *Container, newState *ContainerState) er newState.NetNS = ns } else { if ctr.ensureState(define.ContainerStateRunning, define.ContainerStatePaused) { - return fmt.Errorf("error joining network namespace of container %s: %w", ctr.ID(), err) + return fmt.Errorf("joining network namespace of container %s: %w", ctr.ID(), err) } logrus.Errorf("Joining network namespace for container %s: %v", ctr.ID(), err) diff --git a/libpod/container.go b/libpod/container.go index 1891b124f..bdedafd22 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -353,14 +353,14 @@ func (c *Container) specFromState() (*spec.Spec, error) { returnSpec = new(spec.Spec) content, err := ioutil.ReadAll(f) if err != nil { - return nil, fmt.Errorf("error reading container config: %w", err) + return nil, fmt.Errorf("reading container config: %w", err) } if err := json.Unmarshal(content, &returnSpec); err != nil { - return nil, fmt.Errorf("error unmarshalling container config: %w", err) + return nil, fmt.Errorf("unmarshalling container config: %w", err) } } else if !os.IsNotExist(err) { // ignore when the file does not exist - return nil, fmt.Errorf("error opening container config: %w", err) + return nil, fmt.Errorf("opening container config: %w", err) } return returnSpec, nil @@ -703,7 +703,7 @@ func (c *Container) Mounted() (bool, string, error) { c.lock.Lock() defer c.lock.Unlock() if err := c.syncContainer(); err != nil { - return false, "", fmt.Errorf("error updating container %s state: %w", c.ID(), err) + return false, "", fmt.Errorf("updating container %s state: %w", c.ID(), err) } } // We cannot directly return c.state.Mountpoint as it is not guaranteed @@ -733,7 +733,7 @@ func (c *Container) StartedTime() (time.Time, error) { c.lock.Lock() defer c.lock.Unlock() if err := c.syncContainer(); err != nil { - return time.Time{}, fmt.Errorf("error updating container %s state: %w", c.ID(), err) + return time.Time{}, fmt.Errorf("updating container %s state: %w", c.ID(), err) } } return c.state.StartedTime, nil @@ -745,7 +745,7 @@ func (c *Container) FinishedTime() (time.Time, error) { c.lock.Lock() defer c.lock.Unlock() if err := c.syncContainer(); err != nil { - return time.Time{}, fmt.Errorf("error updating container %s state: %w", c.ID(), err) + return time.Time{}, fmt.Errorf("updating container %s state: %w", c.ID(), err) } } return c.state.FinishedTime, nil @@ -760,7 +760,7 @@ func (c *Container) ExitCode() (int32, bool, error) { c.lock.Lock() defer c.lock.Unlock() if err := c.syncContainer(); err != nil { - return 0, false, fmt.Errorf("error updating container %s state: %w", c.ID(), err) + return 0, false, fmt.Errorf("updating container %s state: %w", c.ID(), err) } } return c.state.ExitCode, c.state.Exited, nil @@ -772,7 +772,7 @@ func (c *Container) OOMKilled() (bool, error) { c.lock.Lock() defer c.lock.Unlock() if err := c.syncContainer(); err != nil { - return false, fmt.Errorf("error updating container %s state: %w", c.ID(), err) + return false, fmt.Errorf("updating container %s state: %w", c.ID(), err) } } return c.state.OOMKilled, nil @@ -859,7 +859,7 @@ func (c *Container) ExecSession(id string) (*ExecSession, error) { returnSession := new(ExecSession) if err := JSONDeepCopy(session, returnSession); err != nil { - return nil, fmt.Errorf("error copying contents of container %s exec session %s: %w", c.ID(), session.ID(), err) + return nil, fmt.Errorf("copying contents of container %s exec session %s: %w", c.ID(), session.ID(), err) } return returnSession, nil @@ -919,7 +919,7 @@ func (c *Container) NamespacePath(linuxNS LinuxNS) (string, error) { //nolint:in c.lock.Lock() defer c.lock.Unlock() if err := c.syncContainer(); err != nil { - return "", fmt.Errorf("error updating container %s state: %w", c.ID(), err) + return "", fmt.Errorf("updating container %s state: %w", c.ID(), err) } } @@ -957,7 +957,7 @@ func (c *Container) CgroupPath() (string, error) { c.lock.Lock() defer c.lock.Unlock() if err := c.syncContainer(); err != nil { - return "", fmt.Errorf("error updating container %s state: %w", c.ID(), err) + return "", fmt.Errorf("updating container %s state: %w", c.ID(), err) } } return c.cGroupPath() @@ -1057,7 +1057,7 @@ func (c *Container) RootFsSize() (int64, error) { c.lock.Lock() defer c.lock.Unlock() if err := c.syncContainer(); err != nil { - return -1, fmt.Errorf("error updating container %s state: %w", c.ID(), err) + return -1, fmt.Errorf("updating container %s state: %w", c.ID(), err) } } return c.rootFsSize() @@ -1069,7 +1069,7 @@ func (c *Container) RWSize() (int64, error) { c.lock.Lock() defer c.lock.Unlock() if err := c.syncContainer(); err != nil { - return -1, fmt.Errorf("error updating container %s state: %w", c.ID(), err) + return -1, fmt.Errorf("updating container %s state: %w", c.ID(), err) } } return c.rwSize() @@ -1157,7 +1157,7 @@ func (c *Container) ContainerState() (*ContainerState, error) { } returnConfig := new(ContainerState) if err := JSONDeepCopy(c.state, returnConfig); err != nil { - return nil, fmt.Errorf("error copying container %s state: %w", c.ID(), err) + return nil, fmt.Errorf("copying container %s state: %w", c.ID(), err) } return c.state, nil } diff --git a/libpod/container_api.go b/libpod/container_api.go index f88e38ce1..dd47b4d12 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -684,7 +684,7 @@ func (c *Container) Cleanup(ctx context.Context) error { // When the container has already been removed, the OCI runtime directory remain. if errors.Is(err, define.ErrNoSuchCtr) || errors.Is(err, define.ErrCtrRemoved) { if err := c.cleanupRuntime(ctx); err != nil { - return fmt.Errorf("error cleaning up container %s from OCI runtime: %w", c.ID(), err) + return fmt.Errorf("cleaning up container %s from OCI runtime: %w", c.ID(), err) } return nil } diff --git a/libpod/container_commit.go b/libpod/container_commit.go index c93c9c7bb..f447816e3 100644 --- a/libpod/container_commit.go +++ b/libpod/container_commit.go @@ -48,7 +48,7 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai if c.state.State == define.ContainerStateRunning && options.Pause { if err := c.pause(); err != nil { - return nil, fmt.Errorf("error pausing container %q to commit: %w", c.ID(), err) + return nil, fmt.Errorf("pausing container %q to commit: %w", c.ID(), err) } defer func() { if err := c.unpause(); err != nil { @@ -202,7 +202,7 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai imageRef, err := is.Transport.ParseStoreReference(c.runtime.store, resolvedImageName) if err != nil { - return nil, fmt.Errorf("error parsing target image name %q: %w", destImage, err) + return nil, fmt.Errorf("parsing target image name %q: %w", destImage, err) } commitRef = imageRef } diff --git a/libpod/container_exec.go b/libpod/container_exec.go index d3c80e896..ca3961d8a 100644 --- a/libpod/container_exec.go +++ b/libpod/container_exec.go @@ -205,7 +205,7 @@ func (c *Container) ExecCreate(config *ExecConfig) (string, error) { session.State = define.ExecStateCreated session.Config = new(ExecConfig) if err := JSONDeepCopy(config, session.Config); err != nil { - return "", fmt.Errorf("error copying exec configuration into exec session: %w", err) + return "", fmt.Errorf("copying exec configuration into exec session: %w", err) } if len(session.Config.ExitCommand) > 0 { @@ -372,7 +372,7 @@ func (c *Container) execStartAndAttach(sessionID string, streams *define.AttachS if lastErr != nil { logrus.Errorf("Container %s exec session %s error: %v", c.ID(), session.ID(), lastErr) } - return fmt.Errorf("error syncing container %s state to update exec session %s: %w", c.ID(), sessionID, err) + return fmt.Errorf("syncing container %s state to update exec session %s: %w", c.ID(), sessionID, err) } // Now handle the error from readExecExitCode above. @@ -809,7 +809,7 @@ func (c *Container) exec(config *ExecConfig, streams *define.AttachStreams, resi // streaming. diedEvent, err := c.runtime.GetExecDiedEvent(context.Background(), c.ID(), sessionID) if err != nil { - return -1, fmt.Errorf("error retrieving exec session %s exit code: %w", sessionID, err) + return -1, fmt.Errorf("retrieving exec session %s exit code: %w", sessionID, err) } return diedEvent.ContainerExitCode, nil } @@ -911,7 +911,7 @@ func (c *Container) createExecBundle(sessionID string) (retErr error) { if err := os.MkdirAll(c.execExitFileDir(sessionID), execDirPermission); err != nil { // The directory is allowed to exist if !os.IsExist(err) { - return fmt.Errorf("error creating OCI runtime exit file path %s: %w", c.execExitFileDir(sessionID), err) + return fmt.Errorf("creating OCI runtime exit file path %s: %w", c.execExitFileDir(sessionID), err) } } return nil @@ -1121,7 +1121,7 @@ func writeExecExitCode(c *Container, sessionID string, exitCode int) error { // need to. Exit without error. return nil } - return fmt.Errorf("error syncing container %s state to remove exec session %s: %w", c.ID(), sessionID, err) + return fmt.Errorf("syncing container %s state to remove exec session %s: %w", c.ID(), sessionID, err) } return justWriteExecExitCode(c, sessionID, exitCode) diff --git a/libpod/container_graph.go b/libpod/container_graph.go index 67b1abc34..96d61b756 100644 --- a/libpod/container_graph.go +++ b/libpod/container_graph.go @@ -160,7 +160,7 @@ func detectCycles(graph *ContainerGraph) (bool, error) { // Popped item is no longer on the stack, mark as such topInfo, ok := nodes[topOfStack.id] if !ok { - return false, fmt.Errorf("error finding node info for %s: %w", topOfStack.id, define.ErrInternal) + return false, fmt.Errorf("finding node info for %s: %w", topOfStack.id, define.ErrInternal) } topInfo.onStack = false diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go index ad8bae286..b72d843b6 100644 --- a/libpod/container_inspect.go +++ b/libpod/container_inspect.go @@ -24,15 +24,15 @@ import ( func (c *Container) inspectLocked(size bool) (*define.InspectContainerData, error) { storeCtr, err := c.runtime.store.Container(c.ID()) if err != nil { - return nil, fmt.Errorf("error getting container from store %q: %w", c.ID(), err) + return nil, fmt.Errorf("getting container from store %q: %w", c.ID(), err) } layer, err := c.runtime.store.Layer(storeCtr.LayerID) if err != nil { - return nil, fmt.Errorf("error reading information about layer %q: %w", storeCtr.LayerID, err) + return nil, fmt.Errorf("reading information about layer %q: %w", storeCtr.LayerID, err) } driverData, err := driver.GetDriverData(c.runtime.store, layer.ID) if err != nil { - return nil, fmt.Errorf("error getting graph driver info %q: %w", c.ID(), err) + return nil, fmt.Errorf("getting graph driver info %q: %w", c.ID(), err) } return c.getContainerInspectData(size, driverData) } @@ -241,7 +241,7 @@ func (c *Container) GetMounts(namedVolumes []*ContainerNamedVolume, imageVolumes // volume. volFromDB, err := c.runtime.state.Volume(volume.Name) if err != nil { - return nil, fmt.Errorf("error looking up volume %s in container %s config: %w", volume.Name, c.ID(), err) + return nil, fmt.Errorf("looking up volume %s in container %s config: %w", volume.Name, c.ID(), err) } mountStruct.Driver = volFromDB.Driver() diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 227bb7f1f..a7ea3c5c5 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -207,7 +207,7 @@ func (c *Container) handleExitFile(exitFile string, fi os.FileInfo) error { } statusCode, err := strconv.Atoi(string(statusCodeStr)) if err != nil { - return fmt.Errorf("error converting exit status code (%q, err) for container %s to int: %w", + return fmt.Errorf("converting exit status code (%q, err) for container %s to int: %w", c.ID(), statusCodeStr, err) } c.state.ExitCode = int32(statusCode) @@ -465,7 +465,7 @@ func (c *Container) setupStorage(ctx context.Context) error { defOptions, err := storage.GetMountOptions(c.runtime.store.GraphDriverName(), c.runtime.store.GraphOptions()) if err != nil { - return fmt.Errorf("error getting default mount options: %w", err) + return fmt.Errorf("getting default mount options: %w", err) } var newOptions []string for _, opt := range defOptions { @@ -500,7 +500,7 @@ func (c *Container) setupStorage(ctx context.Context) error { } } if containerInfoErr != nil { - return fmt.Errorf("error creating container storage: %w", containerInfoErr) + return fmt.Errorf("creating container storage: %w", containerInfoErr) } // Only reconfig IDMappings if layer was mounted from storage. @@ -542,7 +542,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 fmt.Errorf("error creating artifacts directory: %w", err) + return fmt.Errorf("creating artifacts directory: %w", err) } return nil @@ -576,7 +576,7 @@ func (c *Container) teardownStorage() error { artifacts := filepath.Join(c.config.StaticDir, artifactsDir) if err := os.RemoveAll(artifacts); err != nil { - return fmt.Errorf("error removing container %s artifacts %q: %w", c.ID(), artifacts, err) + return fmt.Errorf("removing container %s artifacts %q: %w", c.ID(), artifacts, err) } if err := c.cleanupStorage(); err != nil { @@ -593,7 +593,7 @@ func (c *Container) teardownStorage() error { return nil } - return fmt.Errorf("error removing container %s root filesystem: %w", c.ID(), err) + return fmt.Errorf("removing container %s root filesystem: %w", c.ID(), err) } return nil @@ -644,7 +644,7 @@ func (c *Container) refresh() error { // It was lost in the reboot and must be recreated dir, err := c.runtime.storageService.GetRunDir(c.ID()) if err != nil { - return fmt.Errorf("error retrieving temporary directory for container %s: %w", c.ID(), err) + return fmt.Errorf("retrieving temporary directory for container %s: %w", c.ID(), err) } c.state.RunDir = dir @@ -658,7 +658,7 @@ func (c *Container) refresh() error { } root := filepath.Join(c.runtime.config.Engine.TmpDir, "containers-root", c.ID()) if err := os.MkdirAll(root, 0755); err != nil { - return fmt.Errorf("error creating userNS tmpdir for container %s: %w", c.ID(), err) + return fmt.Errorf("creating userNS tmpdir for container %s: %w", c.ID(), err) } if err := os.Chown(root, c.RootUID(), c.RootGID()); err != nil { return err @@ -668,7 +668,7 @@ func (c *Container) refresh() error { // We need to pick up a new lock lock, err := c.runtime.lockManager.AllocateAndRetrieveLock(c.config.LockID) if err != nil { - return fmt.Errorf("error acquiring lock %d for container %s: %w", c.config.LockID, c.ID(), err) + return fmt.Errorf("acquiring lock %d for container %s: %w", c.config.LockID, c.ID(), err) } c.lock = lock @@ -689,7 +689,7 @@ func (c *Container) refresh() error { } if err := c.save(); err != nil { - return fmt.Errorf("error refreshing state for container %s: %w", c.ID(), err) + return fmt.Errorf("refreshing state for container %s: %w", c.ID(), err) } // Remove ctl and attach files, which may persist across reboot @@ -710,22 +710,22 @@ func (c *Container) removeConmonFiles() error { } if err := os.Remove(attachFile); err != nil && !os.IsNotExist(err) { - return fmt.Errorf("error removing container %s attach file: %w", c.ID(), err) + return fmt.Errorf("removing container %s attach file: %w", c.ID(), err) } ctlFile := filepath.Join(c.bundlePath(), "ctl") if err := os.Remove(ctlFile); err != nil && !os.IsNotExist(err) { - return fmt.Errorf("error removing container %s ctl file: %w", c.ID(), err) + return fmt.Errorf("removing container %s ctl file: %w", c.ID(), err) } winszFile := filepath.Join(c.bundlePath(), "winsz") if err := os.Remove(winszFile); err != nil && !os.IsNotExist(err) { - return fmt.Errorf("error removing container %s winsz file: %w", c.ID(), err) + return fmt.Errorf("removing container %s winsz file: %w", c.ID(), err) } oomFile := filepath.Join(c.bundlePath(), "oom") if err := os.Remove(oomFile); err != nil && !os.IsNotExist(err) { - return fmt.Errorf("error removing container %s OOM file: %w", c.ID(), err) + return fmt.Errorf("removing container %s OOM file: %w", c.ID(), err) } // Remove the exit file so we don't leak memory in tmpfs @@ -734,7 +734,7 @@ func (c *Container) removeConmonFiles() error { return err } if err := os.Remove(exitFile); err != nil && !os.IsNotExist(err) { - return fmt.Errorf("error removing container %s exit file: %w", c.ID(), err) + return fmt.Errorf("removing container %s exit file: %w", c.ID(), err) } return nil @@ -757,12 +757,12 @@ func (c *Container) export(path string) error { input, err := archive.Tar(mountPoint, archive.Uncompressed) if err != nil { - return fmt.Errorf("error reading container directory %q: %w", c.ID(), err) + return fmt.Errorf("reading container directory %q: %w", c.ID(), err) } outFile, err := os.Create(path) if err != nil { - return fmt.Errorf("error creating file %q: %w", path, err) + return fmt.Errorf("creating file %q: %w", path, err) } defer outFile.Close() @@ -778,7 +778,7 @@ func (c *Container) getArtifactPath(name string) string { // save container state to the database func (c *Container) save() error { if err := c.runtime.state.SaveContainer(c); err != nil { - return fmt.Errorf("error saving container %s state: %w", c.ID(), err) + return fmt.Errorf("saving container %s state: %w", c.ID(), err) } return nil } @@ -832,7 +832,7 @@ func (c *Container) prepareToStart(ctx context.Context, recursive bool) (retErr func (c *Container) checkDependenciesAndHandleError() error { notRunning, err := c.checkDependenciesRunning() if err != nil { - return fmt.Errorf("error checking dependencies for container %s: %w", c.ID(), err) + return fmt.Errorf("checking dependencies for container %s: %w", c.ID(), err) } if len(notRunning) > 0 { depString := strings.Join(notRunning, ",") @@ -851,7 +851,7 @@ func (c *Container) startDependencies(ctx context.Context) error { depVisitedCtrs := make(map[string]*Container) if err := c.getAllDependencies(depVisitedCtrs); err != nil { - return fmt.Errorf("error starting dependency for container %s: %w", c.ID(), err) + return fmt.Errorf("starting dependency for container %s: %w", c.ID(), err) } // Because of how Go handles passing slices through functions, a slice cannot grow between function calls @@ -864,7 +864,7 @@ func (c *Container) startDependencies(ctx context.Context) error { // Build a dependency graph of containers graph, err := BuildContainerGraph(depCtrs) if err != nil { - return fmt.Errorf("error generating dependency graph for container %s: %w", c.ID(), err) + return fmt.Errorf("generating dependency graph for container %s: %w", c.ID(), err) } // If there are no containers without dependencies, we can't start @@ -890,7 +890,7 @@ func (c *Container) startDependencies(ctx context.Context) error { for _, e := range ctrErrors { logrus.Errorf("%q", e) } - return fmt.Errorf("error starting some containers: %w", define.ErrInternal) + return fmt.Errorf("starting some containers: %w", define.ErrInternal) } return nil } @@ -946,13 +946,13 @@ func (c *Container) checkDependenciesRunning() ([]string, error) { // Get the dependency container depCtr, err := c.runtime.state.Container(dep) if err != nil { - return nil, fmt.Errorf("error retrieving dependency %s of container %s from state: %w", dep, c.ID(), err) + return nil, fmt.Errorf("retrieving dependency %s of container %s from state: %w", dep, c.ID(), err) } // Check the status state, err := depCtr.State() if err != nil { - return nil, fmt.Errorf("error retrieving state of dependency %s of container %s: %w", dep, c.ID(), err) + return nil, fmt.Errorf("retrieving state of dependency %s of container %s: %w", dep, c.ID(), err) } if state != define.ContainerStateRunning && !depCtr.config.IsInfra { notRunning = append(notRunning, dep) @@ -1280,7 +1280,7 @@ func (c *Container) stop(timeout uint) error { // is held when busy-waiting for the container to be stopped. c.state.State = define.ContainerStateStopping if err := c.save(); err != nil { - return fmt.Errorf("error saving container %s state before stopping: %w", c.ID(), err) + return fmt.Errorf("saving container %s state before stopping: %w", c.ID(), err) } if !c.batched { c.lock.Unlock() @@ -1340,7 +1340,7 @@ func (c *Container) stop(timeout uint) error { } if err := c.save(); err != nil { - return fmt.Errorf("error saving container %s state after stopping: %w", c.ID(), err) + return fmt.Errorf("saving container %s state after stopping: %w", c.ID(), err) } // Wait until we have an exit file, and sync once we do @@ -1627,7 +1627,7 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string) logrus.Debugf("Going to mount named volume %s", v.Name) vol, err := c.runtime.state.Volume(v.Name) if err != nil { - return nil, fmt.Errorf("error retrieving named volume %s for container %s: %w", v.Name, c.ID(), err) + return nil, fmt.Errorf("retrieving named volume %s for container %s: %w", v.Name, c.ID(), err) } if vol.config.LockID == c.config.LockID { @@ -1637,7 +1637,7 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string) defer vol.lock.Unlock() if vol.needsMount() { if err := vol.mount(); err != nil { - return nil, fmt.Errorf("error mounting volume %s for container %s: %w", vol.Name(), c.ID(), err) + return nil, fmt.Errorf("mounting volume %s for container %s: %w", vol.Name(), c.ID(), err) } } // The volume may need a copy-up. Check the state. @@ -1650,7 +1650,7 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string) srcDir, err := securejoin.SecureJoin(mountpoint, v.Dest) if err != nil { - return nil, fmt.Errorf("error calculating destination path to copy up container %s volume %s: %w", c.ID(), vol.Name(), err) + return nil, fmt.Errorf("calculating destination path to copy up container %s volume %s: %w", c.ID(), vol.Name(), err) } // Do a manual stat on the source directory to verify existence. // Skip the rest if it exists. @@ -1661,7 +1661,7 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string) // up. return vol, nil } - return nil, fmt.Errorf("error identifying source directory for copy up into volume %s: %w", vol.Name(), err) + return nil, fmt.Errorf("identifying source directory for copy up into volume %s: %w", vol.Name(), err) } // If it's not a directory we're mounting over it. if !srcStat.IsDir() { @@ -1673,7 +1673,7 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string) // RHBZ#1928643 srcContents, err := os.ReadDir(srcDir) if err != nil { - return nil, fmt.Errorf("error reading contents of source directory for copy up into volume %s: %w", vol.Name(), err) + return nil, fmt.Errorf("reading contents of source directory for copy up into volume %s: %w", vol.Name(), err) } if len(srcContents) == 0 { return vol, nil @@ -1683,7 +1683,7 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string) volMount := vol.mountPoint() contents, err := os.ReadDir(volMount) if err != nil { - return nil, fmt.Errorf("error listing contents of volume %s mountpoint when copying up from container %s: %w", vol.Name(), c.ID(), err) + return nil, fmt.Errorf("listing contents of volume %s mountpoint when copying up from container %s: %w", vol.Name(), c.ID(), err) } if len(contents) > 0 { // The volume is not empty. It was likely modified @@ -1725,11 +1725,11 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string) if err2 != nil { logrus.Errorf("Streaming contents of container %s directory for volume copy-up: %v", c.ID(), err2) } - return nil, fmt.Errorf("error copying up to volume %s: %w", vol.Name(), err) + return nil, fmt.Errorf("copying up to volume %s: %w", vol.Name(), err) } if err := <-errChan; err != nil { - return nil, fmt.Errorf("error streaming container content for copy up into volume %s: %w", vol.Name(), err) + return nil, fmt.Errorf("streaming container content for copy up into volume %s: %w", vol.Name(), err) } } return vol, nil @@ -1812,7 +1812,7 @@ func (c *Container) cleanupStorage() error { if cleanupErr != nil { logrus.Errorf("Unmounting container %s: %v", c.ID(), cleanupErr) } - cleanupErr = fmt.Errorf("error retrieving named volume %s for container %s: %w", v.Name, c.ID(), err) + cleanupErr = fmt.Errorf("retrieving named volume %s for container %s: %w", v.Name, c.ID(), err) // We need to try and unmount every volume, so continue // if they fail. @@ -1825,7 +1825,7 @@ func (c *Container) cleanupStorage() error { if cleanupErr != nil { logrus.Errorf("Unmounting container %s: %v", c.ID(), cleanupErr) } - cleanupErr = fmt.Errorf("error unmounting volume %s for container %s: %w", vol.Name(), c.ID(), err) + cleanupErr = fmt.Errorf("unmounting volume %s for container %s: %w", vol.Name(), c.ID(), err) } vol.lock.Unlock() } @@ -1850,7 +1850,7 @@ func (c *Container) cleanup(ctx context.Context) error { // Clean up network namespace, if present if err := c.cleanupNetwork(); err != nil { - lastError = fmt.Errorf("error removing container %s network: %w", c.ID(), err) + lastError = fmt.Errorf("removing container %s network: %w", c.ID(), err) } // cleanup host entry if it is shared @@ -1888,7 +1888,7 @@ func (c *Container) cleanup(ctx context.Context) error { if lastError != nil { logrus.Errorf("Unmounting container %s storage: %v", c.ID(), err) } else { - lastError = fmt.Errorf("error unmounting container %s storage: %w", c.ID(), err) + lastError = fmt.Errorf("unmounting container %s storage: %w", c.ID(), err) } } @@ -1972,7 +1972,7 @@ func (c *Container) stopPodIfNeeded(ctx context.Context) error { // hooks. func (c *Container) delete(ctx context.Context) error { if err := c.ociRuntime.DeleteContainer(c); err != nil { - return fmt.Errorf("error removing container %s from runtime: %w", c.ID(), err) + return fmt.Errorf("removing container %s from runtime: %w", c.ID(), err) } if err := c.postDeleteHooks(ctx); err != nil { @@ -2035,7 +2035,7 @@ func (c *Container) writeStringToRundir(destFile, contents string) (string, erro destFileName := filepath.Join(c.state.RunDir, destFile) if err := os.Remove(destFileName); err != nil && !os.IsNotExist(err) { - return "", fmt.Errorf("error removing %s for container %s: %w", destFile, c.ID(), err) + return "", fmt.Errorf("removing %s for container %s: %w", destFile, c.ID(), err) } if err := writeStringToPath(destFileName, contents, c.config.MountLabel, c.RootUID(), c.RootGID()); err != nil { @@ -2069,22 +2069,22 @@ func (c *Container) saveSpec(spec *spec.Spec) error { jsonPath := filepath.Join(c.bundlePath(), "config.json") if _, err := os.Stat(jsonPath); err != nil { if !os.IsNotExist(err) { - return fmt.Errorf("error doing stat on container %s spec: %w", c.ID(), err) + return fmt.Errorf("doing stat on container %s spec: %w", c.ID(), err) } // The spec does not exist, we're fine } else { // The spec exists, need to remove it if err := os.Remove(jsonPath); err != nil { - return fmt.Errorf("error replacing runtime spec for container %s: %w", c.ID(), err) + return fmt.Errorf("replacing runtime spec for container %s: %w", c.ID(), err) } } fileJSON, err := json.Marshal(spec) if err != nil { - return fmt.Errorf("error exporting runtime spec for container %s to JSON: %w", c.ID(), err) + return fmt.Errorf("exporting runtime spec for container %s to JSON: %w", c.ID(), err) } if err := ioutil.WriteFile(jsonPath, fileJSON, 0644); err != nil { - return fmt.Errorf("error writing runtime spec JSON for container %s to disk: %w", c.ID(), err) + return fmt.Errorf("writing runtime spec JSON for container %s to disk: %w", c.ID(), err) } logrus.Debugf("Created OCI spec for container %s at %s", c.ID(), jsonPath) @@ -2152,11 +2152,11 @@ func (c *Container) mount() (string, error) { mountPoint, err := c.runtime.storageService.MountContainerImage(c.ID()) if err != nil { - return "", fmt.Errorf("error mounting storage for container %s: %w", c.ID(), err) + return "", fmt.Errorf("mounting storage for container %s: %w", c.ID(), err) } mountPoint, err = filepath.EvalSymlinks(mountPoint) if err != nil { - return "", fmt.Errorf("error resolving storage path for container %s: %w", c.ID(), err) + return "", fmt.Errorf("resolving storage path for container %s: %w", c.ID(), err) } if err := os.Chown(mountPoint, c.RootUID(), c.RootGID()); err != nil { return "", fmt.Errorf("cannot chown %s to %d:%d: %w", mountPoint, c.RootUID(), c.RootGID(), err) @@ -2168,7 +2168,7 @@ func (c *Container) mount() (string, error) { func (c *Container) unmount(force bool) error { // Also unmount storage if _, err := c.runtime.storageService.UnmountContainerImage(c.ID(), force); err != nil { - return fmt.Errorf("error unmounting container %s root filesystem: %w", c.ID(), err) + return fmt.Errorf("unmounting container %s root filesystem: %w", c.ID(), err) } return nil @@ -2297,7 +2297,7 @@ func (c *Container) checkExitFile() error { return nil } - return fmt.Errorf("error running stat on container %s exit file: %w", c.ID(), err) + return fmt.Errorf("running stat on container %s exit file: %w", c.ID(), err) } // Alright, it exists. Transition to Stopped state. diff --git a/libpod/container_internal_common.go b/libpod/container_internal_common.go index 192a86b6a..f1d3f5e89 100644 --- a/libpod/container_internal_common.go +++ b/libpod/container_internal_common.go @@ -147,7 +147,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) { for _, namedVol := range c.config.NamedVolumes { volume, err := c.runtime.GetVolume(namedVol.Name) if err != nil { - return nil, fmt.Errorf("error retrieving volume %s to add to container %s: %w", namedVol.Name, c.ID(), err) + return nil, fmt.Errorf("retrieving volume %s to add to container %s: %w", namedVol.Name, c.ID(), err) } mountPoint, err := volume.MountPoint() if err != nil { @@ -308,11 +308,11 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) { // Mount the specified image. img, _, err := c.runtime.LibimageRuntime().LookupImage(volume.Source, nil) if err != nil { - return nil, fmt.Errorf("error creating image volume %q:%q: %w", volume.Source, volume.Dest, err) + return nil, fmt.Errorf("creating image volume %q:%q: %w", volume.Source, volume.Dest, err) } mountPoint, err := img.Mount(ctx, nil, "") if err != nil { - return nil, fmt.Errorf("error mounting image volume %q:%q: %w", volume.Source, volume.Dest, err) + return nil, fmt.Errorf("mounting image volume %q:%q: %w", volume.Source, volume.Dest, err) } contentDir, err := overlay.TempDir(c.config.StaticDir, c.RootUID(), c.RootGID()) @@ -363,7 +363,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) { if len(c.config.Groups) > 0 { gids, err := lookup.GetContainerGroups(c.config.Groups, c.state.Mountpoint, overrides) if err != nil { - return nil, fmt.Errorf("error looking up supplemental groups for container %s: %w", c.ID(), err) + return nil, fmt.Errorf("looking up supplemental groups for container %s: %w", c.ID(), err) } for _, gid := range gids { g.AddProcessAdditionalGid(gid) @@ -443,7 +443,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) { } _, err := registry.InjectDevices(g.Config, c.config.CDIDevices...) if err != nil { - return nil, fmt.Errorf("error setting up CDI devices: %w", err) + return nil, fmt.Errorf("setting up CDI devices: %w", err) } } @@ -459,7 +459,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) { if m.Type == "tmpfs" { finalPath, err := securejoin.SecureJoin(c.state.Mountpoint, m.Destination) if err != nil { - return nil, fmt.Errorf("error resolving symlinks for mount destination %s: %w", m.Destination, err) + return nil, fmt.Errorf("resolving symlinks for mount destination %s: %w", m.Destination, err) } trimmedPath := strings.TrimPrefix(finalPath, strings.TrimSuffix(c.state.Mountpoint, "/")) m.Destination = trimmedPath @@ -473,7 +473,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) { // Warning: precreate hooks may alter g.Config in place. if c.state.ExtensionStageHooks, err = c.setupOCIHooks(ctx, g.Config); err != nil { - return nil, fmt.Errorf("error setting up OCI Hooks: %w", err) + return nil, fmt.Errorf("setting up OCI Hooks: %w", err) } if len(c.config.EnvSecrets) > 0 { manager, err := c.runtime.SecretsManager() @@ -596,7 +596,7 @@ func (c *Container) resolveWorkDir() error { } // This might be a serious error (e.g., permission), so // we need to return the full error. - return fmt.Errorf("error detecting workdir %q on container %s: %w", workdir, c.ID(), err) + return fmt.Errorf("detecting workdir %q on container %s: %w", workdir, c.ID(), err) } return nil } @@ -604,16 +604,16 @@ func (c *Container) resolveWorkDir() error { if os.IsExist(err) { return nil } - return fmt.Errorf("error creating container %s workdir: %w", c.ID(), err) + return fmt.Errorf("creating container %s workdir: %w", c.ID(), err) } // Ensure container entrypoint is created (if required). uid, gid, _, err := chrootuser.GetUser(c.state.Mountpoint, c.User()) if err != nil { - return fmt.Errorf("error looking up %s inside of the container %s: %w", c.User(), c.ID(), err) + return fmt.Errorf("looking up %s inside of the container %s: %w", c.User(), c.ID(), err) } if err := os.Chown(resolvedWorkdir, int(uid), int(gid)); err != nil { - return fmt.Errorf("error chowning container %s workdir to container root: %w", c.ID(), err) + return fmt.Errorf("chowning container %s workdir to container root: %w", c.ID(), err) } return nil @@ -873,7 +873,7 @@ func (c *Container) exportCheckpoint(options ContainerCheckpointOptions) error { // To correctly track deleted files, let's go through the output of 'podman diff' rootFsChanges, err := c.runtime.GetDiff("", c.ID(), define.DiffContainer) if err != nil { - return fmt.Errorf("error exporting root file-system diff for %q: %w", c.ID(), err) + return fmt.Errorf("exporting root file-system diff for %q: %w", c.ID(), err) } addToTarFiles, err := crutils.CRCreateRootFsDiffTar(&rootFsChanges, c.state.Mountpoint, c.bundlePath()) @@ -890,7 +890,7 @@ func (c *Container) exportCheckpoint(options ContainerCheckpointOptions) error { // Create an archive for each volume associated with the container if !options.IgnoreVolumes { if err := os.MkdirAll(expVolDir, 0700); err != nil { - return fmt.Errorf("error creating volumes export directory %q: %w", expVolDir, err) + return fmt.Errorf("creating volumes export directory %q: %w", expVolDir, err) } for _, v := range c.config.NamedVolumes { @@ -899,7 +899,7 @@ func (c *Container) exportCheckpoint(options ContainerCheckpointOptions) error { volumeTarFile, err := os.Create(volumeTarFileFullPath) if err != nil { - return fmt.Errorf("error creating %q: %w", volumeTarFileFullPath, err) + return fmt.Errorf("creating %q: %w", volumeTarFileFullPath, err) } volume, err := c.runtime.GetVolume(v.Name) @@ -920,7 +920,7 @@ func (c *Container) exportCheckpoint(options ContainerCheckpointOptions) error { IncludeSourceDir: true, }) if err != nil { - return fmt.Errorf("error reading volume directory %q: %w", v.Dest, err) + return fmt.Errorf("reading volume directory %q: %w", v.Dest, err) } _, err = io.Copy(volumeTarFile, input) @@ -940,12 +940,12 @@ func (c *Container) exportCheckpoint(options ContainerCheckpointOptions) error { }) if err != nil { - return fmt.Errorf("error reading checkpoint directory %q: %w", c.ID(), err) + return fmt.Errorf("reading checkpoint directory %q: %w", c.ID(), err) } outFile, err := os.Create(options.TargetFile) if err != nil { - return fmt.Errorf("error creating checkpoint export file %q: %w", options.TargetFile, err) + return fmt.Errorf("creating checkpoint export file %q: %w", options.TargetFile, err) } defer outFile.Close() @@ -1343,12 +1343,12 @@ func (c *Container) restore(ctx context.Context, options ContainerCheckpointOpti infraContainer.lock.Lock() if err := infraContainer.syncContainer(); err != nil { infraContainer.lock.Unlock() - return nil, 0, fmt.Errorf("error syncing infrastructure container %s status: %w", infraContainer.ID(), err) + return nil, 0, fmt.Errorf("syncing infrastructure container %s status: %w", infraContainer.ID(), err) } if infraContainer.state.State != define.ContainerStateRunning { if err := infraContainer.initAndStart(ctx); err != nil { infraContainer.lock.Unlock() - return nil, 0, fmt.Errorf("error starting infrastructure container %s status: %w", infraContainer.ID(), err) + return nil, 0, fmt.Errorf("starting infrastructure container %s status: %w", infraContainer.ID(), err) } } infraContainer.lock.Unlock() @@ -1591,7 +1591,7 @@ func (c *Container) getRootNetNsDepCtr() (depCtr *Container, err error) { depCtr, err = c.runtime.state.Container(nextCtr) if err != nil { - return nil, fmt.Errorf("error fetching dependency %s of container %s: %w", c.config.NetNsCtr, c.ID(), err) + return nil, fmt.Errorf("fetching dependency %s of container %s: %w", c.config.NetNsCtr, c.ID(), err) } // This should never happen without an error if depCtr == nil { @@ -1657,13 +1657,13 @@ func (c *Container) makeBindMounts() error { // them. depCtr, err := c.getRootNetNsDepCtr() if err != nil { - return fmt.Errorf("error fetching network namespace dependency container for container %s: %w", c.ID(), err) + return fmt.Errorf("fetching network namespace dependency container for container %s: %w", c.ID(), err) } // We need that container's bind mounts bindMounts, err := depCtr.BindMounts() if err != nil { - return fmt.Errorf("error fetching bind mounts from dependency %s of container %s: %w", depCtr.ID(), c.ID(), err) + return fmt.Errorf("fetching bind mounts from dependency %s of container %s: %w", depCtr.ID(), c.ID(), err) } // The other container may not have a resolv.conf or /etc/hosts @@ -1673,7 +1673,7 @@ func (c *Container) makeBindMounts() error { err := c.mountIntoRootDirs("/etc/resolv.conf", resolvPath) if err != nil { - return fmt.Errorf("error assigning mounts to container %s: %w", c.ID(), err) + return fmt.Errorf("assigning mounts to container %s: %w", c.ID(), err) } } @@ -1693,13 +1693,13 @@ func (c *Container) makeBindMounts() error { err = etchosts.Add(hostsPath, getLocalhostHostEntry(c)) lock.Unlock() if err != nil { - return fmt.Errorf("error creating hosts file for container %s which depends on container %s: %w", c.ID(), depCtr.ID(), err) + return fmt.Errorf("creating hosts file for container %s which depends on container %s: %w", c.ID(), depCtr.ID(), err) } // finally, save it in the new container err = c.mountIntoRootDirs(config.DefaultHostsFile, hostsPath) if err != nil { - return fmt.Errorf("error assigning mounts to container %s: %w", c.ID(), err) + return fmt.Errorf("assigning mounts to container %s: %w", c.ID(), err) } } @@ -1714,13 +1714,13 @@ func (c *Container) makeBindMounts() error { } else { if !c.config.UseImageResolvConf { if err := c.generateResolvConf(); err != nil { - return fmt.Errorf("error creating resolv.conf for container %s: %w", c.ID(), err) + return fmt.Errorf("creating resolv.conf for container %s: %w", c.ID(), err) } } if !c.config.UseImageHosts { if err := c.createHosts(); err != nil { - return fmt.Errorf("error creating hosts file for container %s: %w", c.ID(), err) + return fmt.Errorf("creating hosts file for container %s: %w", c.ID(), err) } } } @@ -1738,7 +1738,7 @@ func (c *Container) makeBindMounts() error { } } else if !c.config.UseImageHosts && c.state.BindMounts["/etc/hosts"] == "" { if err := c.createHosts(); err != nil { - return fmt.Errorf("error creating hosts file for container %s: %w", c.ID(), err) + return fmt.Errorf("creating hosts file for container %s: %w", c.ID(), err) } } @@ -1750,7 +1750,7 @@ func (c *Container) makeBindMounts() error { if c.config.Passwd == nil || *c.config.Passwd { newPasswd, newGroup, err := c.generatePasswdAndGroup() if err != nil { - return fmt.Errorf("error creating temporary passwd file for container %s: %w", c.ID(), err) + return fmt.Errorf("creating temporary passwd file for container %s: %w", c.ID(), err) } if newPasswd != "" { // Make /etc/passwd @@ -1771,7 +1771,7 @@ func (c *Container) makeBindMounts() error { if _, ok := c.state.BindMounts["/etc/hostname"]; !ok { hostnamePath, err := c.writeStringToRundir("hostname", c.Hostname()) if err != nil { - return fmt.Errorf("error creating hostname file for container %s: %w", c.ID(), err) + return fmt.Errorf("creating hostname file for container %s: %w", c.ID(), err) } c.state.BindMounts["/etc/hostname"] = hostnamePath } @@ -1783,7 +1783,7 @@ func (c *Container) makeBindMounts() error { if ctrTimezone != "local" { _, err = time.LoadLocation(ctrTimezone) if err != nil { - return fmt.Errorf("error finding timezone for container %s: %w", c.ID(), err) + return fmt.Errorf("finding timezone for container %s: %w", c.ID(), err) } } if _, ok := c.state.BindMounts["/etc/localtime"]; !ok { @@ -1791,18 +1791,18 @@ func (c *Container) makeBindMounts() error { if ctrTimezone == "local" { zonePath, err = filepath.EvalSymlinks("/etc/localtime") if err != nil { - return fmt.Errorf("error finding local timezone for container %s: %w", c.ID(), err) + return fmt.Errorf("finding local timezone for container %s: %w", c.ID(), err) } } else { zone := filepath.Join("/usr/share/zoneinfo", ctrTimezone) zonePath, err = filepath.EvalSymlinks(zone) if err != nil { - return fmt.Errorf("error setting timezone for container %s: %w", c.ID(), err) + return fmt.Errorf("setting timezone for container %s: %w", c.ID(), err) } } localtimePath, err := c.copyTimezoneFile(zonePath) if err != nil { - return fmt.Errorf("error setting timezone for container %s: %w", c.ID(), err) + return fmt.Errorf("setting timezone for container %s: %w", c.ID(), err) } c.state.BindMounts["/etc/localtime"] = localtimePath } @@ -1840,7 +1840,7 @@ rootless=%d } containerenvPath, err := c.writeStringToRundir(".containerenv", containerenv) if err != nil { - return fmt.Errorf("error creating containerenv file for container %s: %w", c.ID(), err) + return fmt.Errorf("creating containerenv file for container %s: %w", c.ID(), err) } c.state.BindMounts["/run/.containerenv"] = containerenvPath } @@ -1861,7 +1861,7 @@ rootless=%d if len(c.Secrets()) > 0 { // create /run/secrets if subscriptions did not create if err := c.createSecretMountDir(); err != nil { - return fmt.Errorf("error creating secrets mount: %w", err) + return fmt.Errorf("creating secrets mount: %w", err) } for _, secret := range c.Secrets() { secretFileName := secret.Name @@ -1948,7 +1948,7 @@ func (c *Container) generateResolvConf() error { Path: destPath, Searches: search, }); err != nil { - return fmt.Errorf("error building resolv.conf for container %s: %w", c.ID(), err) + return fmt.Errorf("building resolv.conf for container %s: %w", c.ID(), err) } return c.bindMountRootFile(destPath, resolvconf.DefaultResolvConf) @@ -2445,7 +2445,7 @@ func (c *Container) generatePasswdAndGroup() (string, string, error) { logrus.Debugf("Making /etc/passwd for container %s", c.ID()) originPasswdFile, err := securejoin.SecureJoin(c.state.Mountpoint, "/etc/passwd") if err != nil { - return "", "", fmt.Errorf("error creating path to container %s /etc/passwd: %w", c.ID(), err) + return "", "", fmt.Errorf("creating path to container %s /etc/passwd: %w", c.ID(), err) } orig, err := ioutil.ReadFile(originPasswdFile) if err != nil && !os.IsNotExist(err) { @@ -2463,7 +2463,7 @@ func (c *Container) generatePasswdAndGroup() (string, string, error) { logrus.Debugf("Modifying container %s /etc/passwd", c.ID()) containerPasswd, err := securejoin.SecureJoin(c.state.Mountpoint, "/etc/passwd") if err != nil { - return "", "", fmt.Errorf("error looking up location of container %s /etc/passwd: %w", c.ID(), err) + return "", "", fmt.Errorf("looking up location of container %s /etc/passwd: %w", c.ID(), err) } f, err := os.OpenFile(containerPasswd, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600) @@ -2491,7 +2491,7 @@ func (c *Container) generatePasswdAndGroup() (string, string, error) { logrus.Debugf("Making /etc/group for container %s", c.ID()) originGroupFile, err := securejoin.SecureJoin(c.state.Mountpoint, "/etc/group") if err != nil { - return "", "", fmt.Errorf("error creating path to container %s /etc/group: %w", c.ID(), err) + return "", "", fmt.Errorf("creating path to container %s /etc/group: %w", c.ID(), err) } orig, err := ioutil.ReadFile(originGroupFile) if err != nil && !os.IsNotExist(err) { @@ -2509,7 +2509,7 @@ func (c *Container) generatePasswdAndGroup() (string, string, error) { logrus.Debugf("Modifying container %s /etc/group", c.ID()) containerGroup, err := securejoin.SecureJoin(c.state.Mountpoint, "/etc/group") if err != nil { - return "", "", fmt.Errorf("error looking up location of container %s /etc/group: %w", c.ID(), err) + return "", "", fmt.Errorf("looking up location of container %s /etc/group: %w", c.ID(), err) } f, err := os.OpenFile(containerGroup, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600) @@ -2593,7 +2593,7 @@ func (c *Container) createSecretMountDir() error { func (c *Container) fixVolumePermissions(v *ContainerNamedVolume) error { vol, err := c.runtime.state.Volume(v.Name) if err != nil { - return fmt.Errorf("error retrieving named volume %s for container %s: %w", v.Name, c.ID(), err) + return fmt.Errorf("retrieving named volume %s for container %s: %w", v.Name, c.ID(), err) } vol.lock.Lock() @@ -2620,7 +2620,7 @@ func (c *Container) fixVolumePermissions(v *ContainerNamedVolume) error { mappings := idtools.NewIDMappingsFromMaps(c.config.IDMappings.UIDMap, c.config.IDMappings.GIDMap) newPair, err := mappings.ToHost(p) if err != nil { - return fmt.Errorf("error mapping user %d:%d: %w", uid, gid, err) + return fmt.Errorf("mapping user %d:%d: %w", uid, gid, err) } uid = newPair.UID gid = newPair.GID diff --git a/libpod/container_internal_freebsd.go b/libpod/container_internal_freebsd.go index 40c6c5ebf..c6ed6147c 100644 --- a/libpod/container_internal_freebsd.go +++ b/libpod/container_internal_freebsd.go @@ -162,7 +162,7 @@ func (c *Container) addNetworkContainer(g *generate.Generator, ctr string) error nsCtr, err := c.runtime.state.Container(ctr) c.runtime.state.UpdateContainer(nsCtr) if err != nil { - return fmt.Errorf("error retrieving dependency %s of container %s from state: %w", ctr, c.ID(), err) + return fmt.Errorf("retrieving dependency %s of container %s from state: %w", ctr, c.ID(), err) } g.AddAnnotation("org.freebsd.parentJail", nsCtr.state.NetworkJail) return nil diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 9b05a2d61..0fec1a7d2 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -43,7 +43,7 @@ func (c *Container) mountSHM(shmOptions string) error { func (c *Container) unmountSHM(mount string) error { if err := unix.Unmount(mount, 0); err != nil { if err != syscall.EINVAL && err != syscall.ENOENT { - return fmt.Errorf("error unmounting container %s SHM mount %s: %w", c.ID(), mount, err) + return fmt.Errorf("unmounting container %s SHM mount %s: %w", c.ID(), mount, err) } // If it's just an EINVAL or ENOENT, debug logs only logrus.Debugf("Container %s failed to unmount %s : %v", c.ID(), mount, err) @@ -122,7 +122,7 @@ func (c *Container) prepare() error { // createErr is guaranteed non-nil, so print // unconditionally logrus.Errorf("Preparing container %s: %v", c.ID(), createErr) - createErr = fmt.Errorf("error unmounting storage for container %s after network create failure: %w", c.ID(), err) + createErr = fmt.Errorf("unmounting storage for container %s after network create failure: %w", c.ID(), err) } } @@ -131,7 +131,7 @@ func (c *Container) prepare() error { if createErr != nil { if err := c.cleanupNetwork(); err != nil { logrus.Errorf("Preparing container %s: %v", c.ID(), createErr) - createErr = fmt.Errorf("error cleaning up container %s network after setup failure: %w", c.ID(), err) + createErr = fmt.Errorf("cleaning up container %s network after setup failure: %w", c.ID(), err) } } @@ -310,7 +310,7 @@ func (c *Container) setupSystemd(mounts []spec.Mount, g generate.Generator) erro func (c *Container) addNamespaceContainer(g *generate.Generator, ns LinuxNS, ctr string, specNS spec.LinuxNamespaceType) error { nsCtr, err := c.runtime.state.Container(ctr) if err != nil { - return fmt.Errorf("error retrieving dependency %s of container %s from state: %w", ctr, c.ID(), err) + return fmt.Errorf("retrieving dependency %s of container %s from state: %w", ctr, c.ID(), err) } if specNS == spec.UTSNamespace { @@ -441,7 +441,7 @@ func (c *Container) addNetworkNamespace(g *generate.Generator) error { func (c *Container) addSystemdMounts(g *generate.Generator) error { if c.Systemd() { if err := c.setupSystemd(g.Mounts(), *g); err != nil { - return fmt.Errorf("error adding systemd-specific mounts: %w", err) + return fmt.Errorf("adding systemd-specific mounts: %w", err) } } return nil diff --git a/libpod/container_stat_linux.go b/libpod/container_stat_linux.go index 72aabb516..dc3a524f5 100644 --- a/libpod/container_stat_linux.go +++ b/libpod/container_stat_linux.go @@ -168,7 +168,7 @@ func secureStat(root string, path string) (*copier.StatForItem, error) { if stat.IsSymlink { target, err := copier.Eval(root, path, copier.EvalOptions{}) if err != nil { - return nil, fmt.Errorf("error evaluating symlink in container: %w", err) + return nil, fmt.Errorf("evaluating symlink in container: %w", err) } // Need to make sure the symlink is relative to the root! target = strings.TrimPrefix(target, root) diff --git a/libpod/container_top_linux.go b/libpod/container_top_linux.go index 5571edf73..b9916c3a3 100644 --- a/libpod/container_top_linux.go +++ b/libpod/container_top_linux.go @@ -70,7 +70,7 @@ func (c *Container) Top(descriptors []string) ([]string, error) { output, err = c.execPS(psDescriptors) if err != nil { - return nil, fmt.Errorf("error executing ps(1) in the container: %w", err) + return nil, fmt.Errorf("executing ps(1) in the container: %w", err) } // Trick: filter the ps command from the output instead of diff --git a/libpod/info.go b/libpod/info.go index 1990dc044..ad8f65432 100644 --- a/libpod/info.go +++ b/libpod/info.go @@ -28,20 +28,20 @@ func (r *Runtime) info() (*define.Info, error) { info := define.Info{} versionInfo, err := define.GetVersion() if err != nil { - return nil, fmt.Errorf("error getting version info: %w", err) + return nil, fmt.Errorf("getting version info: %w", err) } info.Version = versionInfo // get host information hostInfo, err := r.hostInfo() if err != nil { - return nil, fmt.Errorf("error getting host info: %w", err) + return nil, fmt.Errorf("getting host info: %w", err) } info.Host = hostInfo // get store information storeInfo, err := r.storeInfo() if err != nil { - return nil, fmt.Errorf("error getting store info: %w", err) + return nil, fmt.Errorf("getting store info: %w", err) } info.Store = storeInfo registries := make(map[string]interface{}) @@ -49,14 +49,14 @@ func (r *Runtime) info() (*define.Info, error) { sys := r.SystemContext() data, err := sysregistriesv2.GetRegistries(sys) if err != nil { - return nil, fmt.Errorf("error getting registries: %w", err) + return nil, fmt.Errorf("getting registries: %w", err) } for _, reg := range data { registries[reg.Prefix] = reg } regs, err := sysregistriesv2.UnqualifiedSearchRegistries(sys) if err != nil { - return nil, fmt.Errorf("error getting registries: %w", err) + return nil, fmt.Errorf("getting registries: %w", err) } if len(regs) > 0 { registries["search"] = regs @@ -80,19 +80,19 @@ func (r *Runtime) hostInfo() (*define.HostInfo, error) { // lets say OS, arch, number of cpus, amount of memory, maybe os distribution/version, hostname, kernel version, uptime mi, err := system.ReadMemInfo() if err != nil { - return nil, fmt.Errorf("error reading memory info: %w", err) + return nil, fmt.Errorf("reading memory info: %w", err) } hostDistributionInfo := r.GetHostDistributionInfo() kv, err := util.ReadKernelVersion() if err != nil { - return nil, fmt.Errorf("error reading kernel version: %w", err) + return nil, fmt.Errorf("reading kernel version: %w", err) } host, err := os.Hostname() if err != nil { - return nil, fmt.Errorf("error getting hostname: %w", err) + return nil, fmt.Errorf("getting hostname: %w", err) } cpuUtil, err := getCPUUtilization() @@ -131,7 +131,7 @@ func (r *Runtime) hostInfo() (*define.HostInfo, error) { duration, err := util.ReadUptime() if err != nil { - return nil, fmt.Errorf("error reading up time: %w", err) + return nil, fmt.Errorf("reading up time: %w", err) } uptime := struct { @@ -201,7 +201,7 @@ func (r *Runtime) storeInfo() (*define.StoreInfo, error) { } images, err := r.store.Images() if err != nil { - return nil, fmt.Errorf("error getting number of images: %w", err) + return nil, fmt.Errorf("getting number of images: %w", err) } conInfo, err := r.getContainerStoreInfo() if err != nil { diff --git a/libpod/info_freebsd.go b/libpod/info_freebsd.go index ef7b6817c..1be988350 100644 --- a/libpod/info_freebsd.go +++ b/libpod/info_freebsd.go @@ -21,7 +21,7 @@ func timeToPercent(time uint64, total uint64) float64 { func getCPUUtilization() (*define.CPUUsage, error) { buf, err := unix.SysctlRaw("kern.cp_time") if err != nil { - return nil, fmt.Errorf("error reading sysctl kern.cp_time: %w", err) + return nil, fmt.Errorf("reading sysctl kern.cp_time: %w", err) } var total uint64 = 0 diff --git a/libpod/info_linux.go b/libpod/info_linux.go index 801dcdb43..44beafa8c 100644 --- a/libpod/info_linux.go +++ b/libpod/info_linux.go @@ -21,19 +21,19 @@ import ( func (r *Runtime) setPlatformHostInfo(info *define.HostInfo) error { seccompProfilePath, err := DefaultSeccompPath() if err != nil { - return fmt.Errorf("error getting Seccomp profile path: %w", err) + return fmt.Errorf("getting Seccomp profile path: %w", err) } // Cgroups version unified, err := cgroups.IsCgroup2UnifiedMode() if err != nil { - return fmt.Errorf("error reading cgroups mode: %w", err) + return fmt.Errorf("reading cgroups mode: %w", err) } // Get Map of all available controllers availableControllers, err := cgroups.GetAvailableControllers(nil, unified) if err != nil { - return fmt.Errorf("error getting available cgroup controllers: %w", err) + return fmt.Errorf("getting available cgroup controllers: %w", err) } info.CgroupManager = r.config.Engine.CgroupManager @@ -75,11 +75,11 @@ func (r *Runtime) setPlatformHostInfo(info *define.HostInfo) error { if rootless.IsRootless() { uidmappings, err := rootless.ReadMappingsProc("/proc/self/uid_map") if err != nil { - return fmt.Errorf("error reading uid mappings: %w", err) + return fmt.Errorf("reading uid mappings: %w", err) } gidmappings, err := rootless.ReadMappingsProc("/proc/self/gid_map") if err != nil { - return fmt.Errorf("error reading gid mappings: %w", err) + return fmt.Errorf("reading gid mappings: %w", err) } idmappings := define.IDMappings{ GIDMap: gidmappings, diff --git a/libpod/lock/file/file_lock.go b/libpod/lock/file/file_lock.go index 55110fc0b..bcbaea5e6 100644 --- a/libpod/lock/file/file_lock.go +++ b/libpod/lock/file/file_lock.go @@ -102,7 +102,7 @@ func (locks *FileLocks) AllocateGivenLock(lck uint32) error { f, err := os.OpenFile(locks.getLockPath(lck), os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) if err != nil { - return fmt.Errorf("error creating lock %d: %w", lck, err) + return fmt.Errorf("creating lock %d: %w", lck, err) } f.Close() @@ -130,7 +130,7 @@ func (locks *FileLocks) DeallocateAllLocks() error { } files, err := os.ReadDir(locks.lockPath) if err != nil { - return fmt.Errorf("error reading directory %s: %w", locks.lockPath, err) + return fmt.Errorf("reading directory %s: %w", locks.lockPath, err) } var lastErr error for _, f := range files { @@ -152,7 +152,7 @@ func (locks *FileLocks) LockFileLock(lck uint32) error { l, err := storage.GetLockfile(locks.getLockPath(lck)) if err != nil { - return fmt.Errorf("error acquiring lock: %w", err) + return fmt.Errorf("acquiring lock: %w", err) } l.Lock() @@ -166,7 +166,7 @@ func (locks *FileLocks) UnlockFileLock(lck uint32) error { } l, err := storage.GetLockfile(locks.getLockPath(lck)) if err != nil { - return fmt.Errorf("error acquiring lock: %w", err) + return fmt.Errorf("acquiring lock: %w", err) } l.Unlock() diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go index c10c3c0b2..a8050d130 100644 --- a/libpod/networking_linux.go +++ b/libpod/networking_linux.go @@ -354,7 +354,7 @@ func (r *RootlessNetNS) Cleanup(runtime *Runtime) error { } } if err != nil { - logrus.Errorf("Failed to kill slirp4netns process: %s", err) + logrus.Errorf("Failed to kill slirp4netns process: %v", err) } err = os.RemoveAll(r.dir) if err != nil { @@ -411,13 +411,13 @@ func (r *Runtime) GetRootlessNetNs(new bool) (*RootlessNetNS, error) { if err != nil { if !new { // return a error if we could not get the namespace and should no create one - return nil, fmt.Errorf("error getting rootless network namespace: %w", err) + return nil, fmt.Errorf("getting rootless network namespace: %w", err) } // create a new namespace logrus.Debugf("creating rootless network namespace with name %q", netnsName) ns, err = netns.NewNSWithName(netnsName) if err != nil { - return nil, fmt.Errorf("error creating rootless network namespace: %w", err) + return nil, fmt.Errorf("creating rootless network namespace: %w", err) } // set up slirp4netns here path := r.config.Engine.NetworkCmdPath @@ -442,7 +442,7 @@ func (r *Runtime) GetRootlessNetNs(new bool) (*RootlessNetNS, error) { } slirpFeatures, err := checkSlirpFlags(path) if err != nil { - return nil, fmt.Errorf("error checking slirp4netns binary %s: %q: %w", path, err, err) + return nil, fmt.Errorf("checking slirp4netns binary %s: %q: %w", path, err, err) } cmdArgs, err := createBasicSlirp4netnsCmdArgs(netOptions, slirpFeatures) if err != nil { @@ -675,7 +675,7 @@ func (r *Runtime) configureNetNS(ctr *Container, ctrNS ns.NetNS) (status map[str func (r *Runtime) createNetNS(ctr *Container) (n ns.NetNS, q map[string]types.StatusBlock, retErr error) { ctrNS, err := netns.NewNS() if err != nil { - return nil, nil, fmt.Errorf("error creating network namespace for container %s: %w", ctr.ID(), err) + return nil, nil, fmt.Errorf("creating network namespace for container %s: %w", ctr.ID(), err) } defer func() { if retErr != nil { @@ -742,7 +742,7 @@ func (r *Runtime) setupNetNS(ctr *Container) error { func joinNetNS(path string) (ns.NetNS, error) { netNS, err := ns.GetNS(path) if err != nil { - return nil, fmt.Errorf("error retrieving network namespace at %s: %w", path, err) + return nil, fmt.Errorf("retrieving network namespace at %s: %w", path, err) } return netNS, nil @@ -758,7 +758,7 @@ func (r *Runtime) closeNetNS(ctr *Container) error { } if err := ctr.state.NetNS.Close(); err != nil { - return fmt.Errorf("error closing network namespace for container %s: %w", ctr.ID(), err) + return fmt.Errorf("closing network namespace for container %s: %w", ctr.ID(), err) } ctr.state.NetNS = nil @@ -775,7 +775,7 @@ func (r *Runtime) teardownNetwork(ns string, opts types.NetworkOptions) error { } tearDownPod := func() error { if err := r.network.Teardown(ns, types.TeardownOptions{NetworkOptions: opts}); err != nil { - return fmt.Errorf("error tearing down network namespace configuration for container %s: %w", opts.ContainerID, err) + return fmt.Errorf("tearing down network namespace configuration for container %s: %w", opts.ContainerID, err) } return nil } @@ -828,12 +828,12 @@ func (r *Runtime) teardownNetNS(ctr *Container) error { // First unmount the namespace if err := netns.UnmountNS(ctr.state.NetNS); err != nil { - return fmt.Errorf("error unmounting network namespace for container %s: %w", ctr.ID(), err) + return fmt.Errorf("unmounting network namespace for container %s: %w", ctr.ID(), err) } // Now close the open file descriptor if err := ctr.state.NetNS.Close(); err != nil { - return fmt.Errorf("error closing network namespace for container %s: %w", ctr.ID(), err) + return fmt.Errorf("closing network namespace for container %s: %w", ctr.ID(), err) } ctr.state.NetNS = nil diff --git a/libpod/networking_slirp4netns.go b/libpod/networking_slirp4netns.go index 4a6462d46..d4ec9082b 100644 --- a/libpod/networking_slirp4netns.go +++ b/libpod/networking_slirp4netns.go @@ -243,7 +243,7 @@ func (r *Runtime) setupSlirp4netns(ctr *Container, netns ns.NetNS) error { } slirpFeatures, err := checkSlirpFlags(path) if err != nil { - return fmt.Errorf("error checking slirp4netns binary %s: %q: %w", path, err, err) + return fmt.Errorf("checking slirp4netns binary %s: %q: %w", path, err, err) } cmdArgs, err := createBasicSlirp4netnsCmdArgs(netOptions, slirpFeatures) if err != nil { @@ -405,7 +405,7 @@ func GetSlirp4netnsIP(subnet *net.IPNet) (*net.IP, error) { } expectedIP, err := addToIP(slirpSubnet, uint32(100)) if err != nil { - return nil, fmt.Errorf("error calculating expected ip for slirp4netns: %w", err) + return nil, fmt.Errorf("calculating expected ip for slirp4netns: %w", err) } return expectedIP, nil } @@ -419,7 +419,7 @@ func GetSlirp4netnsGateway(subnet *net.IPNet) (*net.IP, error) { } expectedGatewayIP, err := addToIP(slirpSubnet, uint32(2)) if err != nil { - return nil, fmt.Errorf("error calculating expected gateway ip for slirp4netns: %w", err) + return nil, fmt.Errorf("calculating expected gateway ip for slirp4netns: %w", err) } return expectedGatewayIP, nil } @@ -433,7 +433,7 @@ func GetSlirp4netnsDNS(subnet *net.IPNet) (*net.IP, error) { } expectedDNSIP, err := addToIP(slirpSubnet, uint32(3)) if err != nil { - return nil, fmt.Errorf("error calculating expected dns ip for slirp4netns: %w", err) + return nil, fmt.Errorf("calculating expected dns ip for slirp4netns: %w", err) } return expectedDNSIP, nil } @@ -465,7 +465,7 @@ func waitForSync(syncR *os.File, cmd *exec.Cmd, logFile io.ReadSeeker, timeout t b := make([]byte, 16) for { if err := syncR.SetDeadline(time.Now().Add(timeout)); err != nil { - return fmt.Errorf("error setting %s pipe timeout: %w", prog, err) + return fmt.Errorf("setting %s pipe timeout: %w", prog, err) } // FIXME: return err as soon as proc exits, without waiting for timeout if _, err := syncR.Read(b); err == nil { @@ -676,7 +676,7 @@ func openSlirp4netnsPort(apiSocket, proto, hostip string, hostport, guestport ui // successful. var y map[string]interface{} if err := json.Unmarshal(buf[0:readLength], &y); err != nil { - return fmt.Errorf("error parsing error status from slirp4netns: %w", err) + return fmt.Errorf("parsing error status from slirp4netns: %w", err) } if e, found := y["error"]; found { return fmt.Errorf("from slirp4netns while setting up port redirection: %v", e) diff --git a/libpod/oci_conmon_common.go b/libpod/oci_conmon_common.go index 8ef8ae721..53dddd064 100644 --- a/libpod/oci_conmon_common.go +++ b/libpod/oci_conmon_common.go @@ -150,7 +150,7 @@ 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, fmt.Errorf("error creating OCI runtime exit files directory: %w", err) + return nil, fmt.Errorf("creating OCI runtime exit files directory: %w", err) } } return runtime, nil @@ -234,7 +234,7 @@ func (r *ConmonOCIRuntime) UpdateContainerStatus(ctr *Container) error { if err := cmd.Start(); err != nil { out, err2 := ioutil.ReadAll(errPipe) if err2 != nil { - return fmt.Errorf("error getting container %s state: %w", ctr.ID(), err) + return fmt.Errorf("getting container %s state: %w", ctr.ID(), err) } if strings.Contains(string(out), "does not exist") || strings.Contains(string(out), "No such file") { if err := ctr.removeConmonFiles(); err != nil { @@ -245,7 +245,7 @@ func (r *ConmonOCIRuntime) UpdateContainerStatus(ctr *Container) error { ctr.state.State = define.ContainerStateExited return ctr.runtime.state.AddContainerExitCode(ctr.ID(), ctr.state.ExitCode) } - return fmt.Errorf("error getting container %s state. stderr/out: %s: %w", ctr.ID(), out, err) + return fmt.Errorf("getting container %s state. stderr/out: %s: %w", ctr.ID(), out, err) } defer func() { _ = cmd.Wait() @@ -256,10 +256,10 @@ func (r *ConmonOCIRuntime) UpdateContainerStatus(ctr *Container) error { } out, err := ioutil.ReadAll(outPipe) if err != nil { - return fmt.Errorf("error reading stdout: %s: %w", ctr.ID(), err) + return fmt.Errorf("reading stdout: %s: %w", ctr.ID(), err) } if err := json.NewDecoder(bytes.NewBuffer(out)).Decode(state); err != nil { - return fmt.Errorf("error decoding container status for container %s: %w", ctr.ID(), err) + return fmt.Errorf("decoding container status for container %s: %w", ctr.ID(), err) } ctr.state.PID = state.Pid @@ -379,7 +379,7 @@ func (r *ConmonOCIRuntime) KillContainer(ctr *Container, signal uint, all bool) if ctr.ensureState(define.ContainerStateStopped, define.ContainerStateExited) { return define.ErrCtrStateInvalid } - return fmt.Errorf("error sending signal to container %s: %w", ctr.ID(), err) + return fmt.Errorf("sending signal to container %s: %w", ctr.ID(), err) } return nil @@ -434,7 +434,7 @@ func (r *ConmonOCIRuntime) StopContainer(ctr *Container, timeout uint, all bool) if aliveErr := unix.Kill(ctr.state.PID, 0); errors.Is(aliveErr, unix.ESRCH) { return nil } - return fmt.Errorf("error sending SIGKILL to container %s: %w", ctr.ID(), err) + return fmt.Errorf("sending SIGKILL to container %s: %w", ctr.ID(), err) } // Give runtime a few seconds to make it happen @@ -554,7 +554,7 @@ func (r *ConmonOCIRuntime) HTTPAttach(ctr *Container, req *http.Request, w http. httpCon, httpBuf, err := hijacker.Hijack() if err != nil { - return fmt.Errorf("error hijacking connection: %w", err) + return fmt.Errorf("hijacking connection: %w", err) } hijackDone <- true @@ -563,7 +563,7 @@ func (r *ConmonOCIRuntime) HTTPAttach(ctr *Container, req *http.Request, w http. // Force a flush after the header is written. if err := httpBuf.Flush(); err != nil { - return fmt.Errorf("error flushing HTTP hijack header: %w", err) + return fmt.Errorf("flushing HTTP hijack header: %w", err) } defer func() { @@ -838,7 +838,7 @@ func (r *ConmonOCIRuntime) CheckConmonRunning(ctr *Container) (bool, error) { if err == unix.ESRCH { return false, nil } - return false, fmt.Errorf("error pinging container %s conmon with signal 0: %w", ctr.ID(), err) + return false, fmt.Errorf("pinging container %s conmon with signal 0: %w", ctr.ID(), err) } return true, nil } @@ -890,11 +890,11 @@ func (r *ConmonOCIRuntime) RuntimeInfo() (*define.ConmonInfo, *define.OCIRuntime conmonPackage := packageVersion(r.conmonPath) runtimeVersion, err := r.getOCIRuntimeVersion() if err != nil { - return nil, nil, fmt.Errorf("error getting version of OCI runtime %s: %w", r.name, err) + return nil, nil, fmt.Errorf("getting version of OCI runtime %s: %w", r.name, err) } conmonVersion, err := r.getConmonVersion() if err != nil { - return nil, nil, fmt.Errorf("error getting conmon version: %w", err) + return nil, nil, fmt.Errorf("getting conmon version: %w", err) } conmon := define.ConmonInfo{ @@ -1001,13 +1001,13 @@ func (r *ConmonOCIRuntime) createOCIContainer(ctr *Container, restoreOptions *Co parentSyncPipe, childSyncPipe, err := newPipe() if err != nil { - return 0, fmt.Errorf("error creating socket pair: %w", err) + return 0, fmt.Errorf("creating socket pair: %w", err) } defer errorhandling.CloseQuiet(parentSyncPipe) childStartPipe, parentStartPipe, err := newPipe() if err != nil { - return 0, fmt.Errorf("error creating socket pair for start pipe: %w", err) + return 0, fmt.Errorf("creating socket pair for start pipe: %w", err) } defer errorhandling.CloseQuiet(parentStartPipe) diff --git a/libpod/oci_conmon_exec_common.go b/libpod/oci_conmon_exec_common.go index 735dbb9c4..e5080942b 100644 --- a/libpod/oci_conmon_exec_common.go +++ b/libpod/oci_conmon_exec_common.go @@ -225,7 +225,7 @@ func (r *ConmonOCIRuntime) ExecStopContainer(ctr *Container, sessionID string, t if err == unix.ESRCH { return nil } - return fmt.Errorf("error pinging container %s exec session %s PID %d with signal 0: %w", ctr.ID(), sessionID, pid, err) + return fmt.Errorf("pinging container %s exec session %s PID %d with signal 0: %w", ctr.ID(), sessionID, pid, err) } if timeout > 0 { @@ -235,7 +235,7 @@ func (r *ConmonOCIRuntime) ExecStopContainer(ctr *Container, sessionID string, t if err == unix.ESRCH { return nil } - return fmt.Errorf("error killing container %s exec session %s PID %d with SIGTERM: %w", ctr.ID(), sessionID, pid, err) + return fmt.Errorf("killing container %s exec session %s PID %d with SIGTERM: %w", ctr.ID(), sessionID, pid, err) } // Wait for the PID to stop @@ -253,7 +253,7 @@ func (r *ConmonOCIRuntime) ExecStopContainer(ctr *Container, sessionID string, t if err == unix.ESRCH { return nil } - return fmt.Errorf("error killing container %s exec session %s PID %d with SIGKILL: %w", ctr.ID(), sessionID, pid, err) + return fmt.Errorf("killing container %s exec session %s PID %d with SIGKILL: %w", ctr.ID(), sessionID, pid, err) } // Wait for the PID to stop @@ -279,7 +279,7 @@ func (r *ConmonOCIRuntime) ExecUpdateStatus(ctr *Container, sessionID string) (b if err == unix.ESRCH { return false, nil } - return false, fmt.Errorf("error pinging container %s exec session %s PID %d with signal 0: %w", ctr.ID(), sessionID, pid, err) + return false, fmt.Errorf("pinging container %s exec session %s PID %d with signal 0: %w", ctr.ID(), sessionID, pid, err) } return true, nil @@ -338,7 +338,7 @@ func (r *ConmonOCIRuntime) startExec(c *Container, sessionID string, options *Ex // create sync pipe to receive the pid parentSyncPipe, childSyncPipe, err := newPipe() if err != nil { - return nil, nil, fmt.Errorf("error creating socket pair: %w", err) + return nil, nil, fmt.Errorf("creating socket pair: %w", err) } pipes.syncPipe = parentSyncPipe @@ -352,7 +352,7 @@ func (r *ConmonOCIRuntime) startExec(c *Container, sessionID string, options *Ex // attachToExec is responsible for closing parentStartPipe childStartPipe, parentStartPipe, err := newPipe() if err != nil { - return nil, nil, fmt.Errorf("error creating socket pair: %w", err) + return nil, nil, fmt.Errorf("creating socket pair: %w", err) } pipes.startPipe = parentStartPipe @@ -362,7 +362,7 @@ func (r *ConmonOCIRuntime) startExec(c *Container, sessionID string, options *Ex // attachToExec is responsible for closing parentAttachPipe parentAttachPipe, childAttachPipe, err := newPipe() if err != nil { - return nil, nil, fmt.Errorf("error creating socket pair: %w", err) + return nil, nil, fmt.Errorf("creating socket pair: %w", err) } pipes.attachPipe = parentAttachPipe @@ -564,7 +564,7 @@ func attachExecHTTP(c *Container, sessionID string, r *http.Request, w http.Resp httpCon, httpBuf, err := hijacker.Hijack() if err != nil { conmonPipeDataChan <- conmonPipeData{-1, err} - return fmt.Errorf("error hijacking connection: %w", err) + return fmt.Errorf("hijacking connection: %w", err) } hijackDone <- true @@ -575,7 +575,7 @@ func attachExecHTTP(c *Container, sessionID string, r *http.Request, w http.Resp // Force a flush after the header is written. if err := httpBuf.Flush(); err != nil { conmonPipeDataChan <- conmonPipeData{-1, err} - return fmt.Errorf("error flushing HTTP hijack header: %w", err) + return fmt.Errorf("flushing HTTP hijack header: %w", err) } go func() { @@ -723,7 +723,7 @@ func (c *Container) prepareProcessExec(options *ExecOptions, env []string, sessi if len(addGroups) > 0 { sgids, err = lookup.GetContainerGroups(addGroups, c.state.Mountpoint, overrides) if err != nil { - return nil, fmt.Errorf("error looking up supplemental groups for container %s exec session %s: %w", c.ID(), sessionID, err) + return nil, fmt.Errorf("looking up supplemental groups for container %s exec session %s: %w", c.ID(), sessionID, err) } } diff --git a/libpod/plugin/volume_api.go b/libpod/plugin/volume_api.go index b13578388..522895798 100644 --- a/libpod/plugin/volume_api.go +++ b/libpod/plugin/volume_api.go @@ -76,7 +76,7 @@ func validatePlugin(newPlugin *VolumePlugin) error { // Hit the Activate endpoint to find out if it is, and if so what kind req, err := http.NewRequest("POST", "http://plugin"+activatePath, nil) if err != nil { - return fmt.Errorf("error making request to volume plugin %s activation endpoint: %w", newPlugin.Name, err) + return fmt.Errorf("making request to volume plugin %s activation endpoint: %w", newPlugin.Name, err) } req.Header.Set("Host", newPlugin.getURI()) @@ -84,7 +84,7 @@ func validatePlugin(newPlugin *VolumePlugin) error { resp, err := newPlugin.Client.Do(req) if err != nil { - return fmt.Errorf("error sending request to plugin %s activation endpoint: %w", newPlugin.Name, err) + return fmt.Errorf("sending request to plugin %s activation endpoint: %w", newPlugin.Name, err) } defer resp.Body.Close() @@ -97,12 +97,12 @@ func validatePlugin(newPlugin *VolumePlugin) error { // Read and decode the body so we can tell if this is a volume plugin. respBytes, err := ioutil.ReadAll(resp.Body) if err != nil { - return fmt.Errorf("error reading activation response body from plugin %s: %w", newPlugin.Name, err) + return fmt.Errorf("reading activation response body from plugin %s: %w", newPlugin.Name, err) } respStruct := new(activateResponse) if err := json.Unmarshal(respBytes, respStruct); err != nil { - return fmt.Errorf("error unmarshalling plugin %s activation response: %w", newPlugin.Name, err) + return fmt.Errorf("unmarshalling plugin %s activation response: %w", newPlugin.Name, err) } foundVolume := false @@ -196,7 +196,7 @@ func (p *VolumePlugin) verifyReachable() error { return fmt.Errorf("%s: %w", p.Name, ErrPluginRemoved) } - return fmt.Errorf("error accessing plugin %s: %w", p.Name, err) + return fmt.Errorf("accessing plugin %s: %w", p.Name, err) } return nil } @@ -212,13 +212,13 @@ func (p *VolumePlugin) sendRequest(toJSON interface{}, endpoint string) (*http.R if toJSON != nil { reqJSON, err = json.Marshal(toJSON) if err != nil { - return nil, fmt.Errorf("error marshalling request JSON for volume plugin %s endpoint %s: %w", p.Name, endpoint, err) + return nil, fmt.Errorf("marshalling request JSON for volume plugin %s endpoint %s: %w", p.Name, endpoint, err) } } req, err := http.NewRequest("POST", "http://plugin"+endpoint, bytes.NewReader(reqJSON)) if err != nil { - return nil, fmt.Errorf("error making request to volume plugin %s endpoint %s: %w", p.Name, endpoint, err) + return nil, fmt.Errorf("making request to volume plugin %s endpoint %s: %w", p.Name, endpoint, err) } req.Header.Set("Host", p.getURI()) @@ -226,7 +226,7 @@ func (p *VolumePlugin) sendRequest(toJSON interface{}, endpoint string) (*http.R resp, err := p.Client.Do(req) if err != nil { - return nil, fmt.Errorf("error sending request to volume plugin %s endpoint %s: %w", p.Name, endpoint, err) + return nil, fmt.Errorf("sending request to volume plugin %s endpoint %s: %w", p.Name, endpoint, err) } // We are *deliberately not closing* response here. It is the // responsibility of the caller to do so after reading the response. @@ -240,9 +240,9 @@ func (p *VolumePlugin) makeErrorResponse(err, endpoint, volName string) error { err = "empty error from plugin" } if volName != "" { - return fmt.Errorf("error on %s on volume %s in volume plugin %s: %w", endpoint, volName, p.Name, errors.New(err)) + return fmt.Errorf("on %s on volume %s in volume plugin %s: %w", endpoint, volName, p.Name, errors.New(err)) } - return fmt.Errorf("error on %s in volume plugin %s: %w", endpoint, p.Name, errors.New(err)) + return fmt.Errorf("on %s in volume plugin %s: %w", endpoint, p.Name, errors.New(err)) } // Handle error responses from plugin @@ -254,12 +254,12 @@ func (p *VolumePlugin) handleErrorResponse(resp *http.Response, endpoint, volNam if resp.StatusCode != 200 { errResp, err := ioutil.ReadAll(resp.Body) if err != nil { - return fmt.Errorf("error reading response body from volume plugin %s: %w", p.Name, err) + return fmt.Errorf("reading response body from volume plugin %s: %w", p.Name, err) } errStruct := new(volume.ErrorResponse) if err := json.Unmarshal(errResp, errStruct); err != nil { - return fmt.Errorf("error unmarshalling JSON response from volume plugin %s: %w", p.Name, err) + return fmt.Errorf("unmarshalling JSON response from volume plugin %s: %w", p.Name, err) } return p.makeErrorResponse(errStruct.Err, endpoint, volName) @@ -309,12 +309,12 @@ func (p *VolumePlugin) ListVolumes() ([]*volume.Volume, error) { volumeRespBytes, err := ioutil.ReadAll(resp.Body) if err != nil { - return nil, fmt.Errorf("error reading response body from volume plugin %s: %w", p.Name, err) + return nil, fmt.Errorf("reading response body from volume plugin %s: %w", p.Name, err) } volumeResp := new(volume.ListResponse) if err := json.Unmarshal(volumeRespBytes, volumeResp); err != nil { - return nil, fmt.Errorf("error unmarshalling volume plugin %s list response: %w", p.Name, err) + return nil, fmt.Errorf("unmarshalling volume plugin %s list response: %w", p.Name, err) } return volumeResp.Volumes, nil @@ -344,12 +344,12 @@ func (p *VolumePlugin) GetVolume(req *volume.GetRequest) (*volume.Volume, error) getRespBytes, err := ioutil.ReadAll(resp.Body) if err != nil { - return nil, fmt.Errorf("error reading response body from volume plugin %s: %w", p.Name, err) + return nil, fmt.Errorf("reading response body from volume plugin %s: %w", p.Name, err) } getResp := new(volume.GetResponse) if err := json.Unmarshal(getRespBytes, getResp); err != nil { - return nil, fmt.Errorf("error unmarshalling volume plugin %s get response: %w", p.Name, err) + return nil, fmt.Errorf("unmarshalling volume plugin %s get response: %w", p.Name, err) } return getResp.Volume, nil @@ -400,12 +400,12 @@ func (p *VolumePlugin) GetVolumePath(req *volume.PathRequest) (string, error) { pathRespBytes, err := ioutil.ReadAll(resp.Body) if err != nil { - return "", fmt.Errorf("error reading response body from volume plugin %s: %w", p.Name, err) + return "", fmt.Errorf("reading response body from volume plugin %s: %w", p.Name, err) } pathResp := new(volume.PathResponse) if err := json.Unmarshal(pathRespBytes, pathResp); err != nil { - return "", fmt.Errorf("error unmarshalling volume plugin %s path response: %w", p.Name, err) + return "", fmt.Errorf("unmarshalling volume plugin %s path response: %w", p.Name, err) } return pathResp.Mountpoint, nil @@ -437,12 +437,12 @@ func (p *VolumePlugin) MountVolume(req *volume.MountRequest) (string, error) { mountRespBytes, err := ioutil.ReadAll(resp.Body) if err != nil { - return "", fmt.Errorf("error reading response body from volume plugin %s: %w", p.Name, err) + return "", fmt.Errorf("reading response body from volume plugin %s: %w", p.Name, err) } mountResp := new(volume.MountResponse) if err := json.Unmarshal(mountRespBytes, mountResp); err != nil { - return "", fmt.Errorf("error unmarshalling volume plugin %s path response: %w", p.Name, err) + return "", fmt.Errorf("unmarshalling volume plugin %s path response: %w", p.Name, err) } return mountResp.Mountpoint, nil diff --git a/libpod/pod_api.go b/libpod/pod_api.go index 29964ae95..1bd686ddc 100644 --- a/libpod/pod_api.go +++ b/libpod/pod_api.go @@ -92,7 +92,7 @@ func (p *Pod) Start(ctx context.Context) (map[string]error, error) { // Build a dependency graph of containers in the pod graph, err := BuildContainerGraph(allCtrs) if err != nil { - return nil, fmt.Errorf("error generating dependency graph for pod %s: %w", p.ID(), err) + return nil, fmt.Errorf("generating dependency graph for pod %s: %w", p.ID(), err) } // If there are no containers without dependencies, we can't start // Error out @@ -109,7 +109,7 @@ func (p *Pod) Start(ctx context.Context) (map[string]error, error) { } if len(ctrErrors) > 0 { - return ctrErrors, fmt.Errorf("error starting some containers: %w", define.ErrPodPartialFail) + return ctrErrors, fmt.Errorf("starting some containers: %w", define.ErrPodPartialFail) } defer p.newPodEvent(events.Start) return nil, nil @@ -201,7 +201,7 @@ func (p *Pod) stopWithTimeout(ctx context.Context, cleanup bool, timeout int) (m } if len(ctrErrors) > 0 { - return ctrErrors, fmt.Errorf("error stopping some containers: %w", define.ErrPodPartialFail) + return ctrErrors, fmt.Errorf("stopping some containers: %w", define.ErrPodPartialFail) } if err := p.maybeStopServiceContainer(); err != nil { @@ -305,7 +305,7 @@ func (p *Pod) Cleanup(ctx context.Context) (map[string]error, error) { } if len(ctrErrors) > 0 { - return ctrErrors, fmt.Errorf("error cleaning up some containers: %w", define.ErrPodPartialFail) + return ctrErrors, fmt.Errorf("cleaning up some containers: %w", define.ErrPodPartialFail) } if err := p.maybeStopServiceContainer(); err != nil { @@ -376,7 +376,7 @@ func (p *Pod) Pause(ctx context.Context) (map[string]error, error) { } if len(ctrErrors) > 0 { - return ctrErrors, fmt.Errorf("error pausing some containers: %w", define.ErrPodPartialFail) + return ctrErrors, fmt.Errorf("pausing some containers: %w", define.ErrPodPartialFail) } return nil, nil } @@ -432,7 +432,7 @@ func (p *Pod) Unpause(ctx context.Context) (map[string]error, error) { } if len(ctrErrors) > 0 { - return ctrErrors, fmt.Errorf("error unpausing some containers: %w", define.ErrPodPartialFail) + return ctrErrors, fmt.Errorf("unpausing some containers: %w", define.ErrPodPartialFail) } return nil, nil } @@ -470,7 +470,7 @@ func (p *Pod) Restart(ctx context.Context) (map[string]error, error) { // Build a dependency graph of containers in the pod graph, err := BuildContainerGraph(allCtrs) if err != nil { - return nil, fmt.Errorf("error generating dependency graph for pod %s: %w", p.ID(), err) + return nil, fmt.Errorf("generating dependency graph for pod %s: %w", p.ID(), err) } ctrErrors := make(map[string]error) @@ -488,7 +488,7 @@ func (p *Pod) Restart(ctx context.Context) (map[string]error, error) { } if len(ctrErrors) > 0 { - return ctrErrors, fmt.Errorf("error stopping some containers: %w", define.ErrPodPartialFail) + return ctrErrors, fmt.Errorf("stopping some containers: %w", define.ErrPodPartialFail) } p.newPodEvent(events.Stop) p.newPodEvent(events.Start) @@ -547,7 +547,7 @@ func (p *Pod) Kill(ctx context.Context, signal uint) (map[string]error, error) { } if len(ctrErrors) > 0 { - return ctrErrors, fmt.Errorf("error killing some containers: %w", define.ErrPodPartialFail) + return ctrErrors, fmt.Errorf("killing some containers: %w", define.ErrPodPartialFail) } if err := p.maybeStopServiceContainer(); err != nil { diff --git a/libpod/pod_internal.go b/libpod/pod_internal.go index a86cd6d21..9f89fd55d 100644 --- a/libpod/pod_internal.go +++ b/libpod/pod_internal.go @@ -38,7 +38,7 @@ func (p *Pod) updatePod() error { // Save pod state to database func (p *Pod) save() error { if err := p.runtime.state.SavePod(p); err != nil { - return fmt.Errorf("error saving pod %s state: %w", p.ID(), err) + return fmt.Errorf("saving pod %s state: %w", p.ID(), err) } return nil @@ -60,7 +60,7 @@ func (p *Pod) refresh() error { // Retrieve the pod's lock lock, err := p.runtime.lockManager.AllocateAndRetrieveLock(p.config.LockID) if err != nil { - return fmt.Errorf("error retrieving lock %d for pod %s: %w", p.config.LockID, p.ID(), err) + return fmt.Errorf("retrieving lock %d for pod %s: %w", p.config.LockID, p.ID(), err) } p.lock = lock diff --git a/libpod/runtime.go b/libpod/runtime.go index 1503b2344..fe90b6df1 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -207,7 +207,7 @@ func newRuntimeFromConfig(conf *config.Config, options ...RuntimeOption) (*Runti // Overwrite config with user-given configuration options for _, opt := range options { if err := opt(runtime); err != nil { - return nil, fmt.Errorf("error configuring runtime: %w", err) + return nil, fmt.Errorf("configuring runtime: %w", err) } } @@ -223,7 +223,7 @@ func newRuntimeFromConfig(conf *config.Config, options ...RuntimeOption) (*Runti } if err := shutdown.Start(); err != nil { - return nil, fmt.Errorf("error starting shutdown signal handler: %w", err) + return nil, fmt.Errorf("starting shutdown signal handler: %w", err) } if err := makeRuntime(runtime); err != nil { @@ -280,7 +280,7 @@ func getLockManager(runtime *Runtime) (lock.Manager, error) { // Since we're renumbering, this is not fatal. // Remove the earlier set of locks and recreate. if err := os.Remove(filepath.Join("/dev/shm", lockPath)); err != nil { - return nil, fmt.Errorf("error removing libpod locks file %s: %w", lockPath, err) + return nil, fmt.Errorf("removing libpod locks file %s: %w", lockPath, err) } manager, err = lock.NewSHMLockManager(lockPath, runtime.config.Engine.NumLocks) @@ -318,7 +318,7 @@ func makeRuntime(runtime *Runtime) (retErr error) { if err := os.MkdirAll(runtime.config.Engine.StaticDir, 0700); err != nil { // The directory is allowed to exist if !errors.Is(err, os.ErrExist) { - return fmt.Errorf("error creating runtime static files directory: %w", err) + return fmt.Errorf("creating runtime static files directory: %w", err) } } @@ -362,7 +362,7 @@ func makeRuntime(runtime *Runtime) (retErr error) { } } - return fmt.Errorf("error retrieving runtime configuration from database: %w", err) + return fmt.Errorf("retrieving runtime configuration from database: %w", err) } runtime.mergeDBConfig(dbConfig) @@ -405,7 +405,7 @@ func makeRuntime(runtime *Runtime) (retErr error) { } if err := runtime.state.SetNamespace(runtime.config.Engine.Namespace); err != nil { - return fmt.Errorf("error setting libpod namespace in state: %w", err) + return fmt.Errorf("setting libpod namespace in state: %w", err) } logrus.Debugf("Set libpod namespace to %q", runtime.config.Engine.Namespace) @@ -462,7 +462,7 @@ func makeRuntime(runtime *Runtime) (retErr error) { if err := os.MkdirAll(runtime.config.Engine.TmpDir, 0751); err != nil { // The directory is allowed to exist if !errors.Is(err, os.ErrExist) { - return fmt.Errorf("error creating tmpdir: %w", err) + return fmt.Errorf("creating tmpdir: %w", err) } } @@ -470,7 +470,7 @@ func makeRuntime(runtime *Runtime) (retErr error) { if err := os.MkdirAll(filepath.Dir(runtime.config.Engine.EventsLogFilePath), 0700); err != nil { // The directory is allowed to exist if !errors.Is(err, os.ErrExist) { - return fmt.Errorf("error creating events dirs: %w", err) + return fmt.Errorf("creating events dirs: %w", err) } } @@ -528,7 +528,7 @@ func makeRuntime(runtime *Runtime) (retErr error) { if err := os.MkdirAll(runtime.config.Engine.TmpDir, 0755); err != nil { // The directory is allowed to exist if !errors.Is(err, os.ErrExist) { - return fmt.Errorf("error creating runtime temporary files directory: %w", err) + return fmt.Errorf("creating runtime temporary files directory: %w", err) } } @@ -549,7 +549,7 @@ func makeRuntime(runtime *Runtime) (retErr error) { runtimeAliveFile := filepath.Join(runtime.config.Engine.TmpDir, "alive") aliveLock, err := storage.GetLockfile(runtimeAliveLock) if err != nil { - return fmt.Errorf("error acquiring runtime init lock: %w", err) + return fmt.Errorf("acquiring runtime init lock: %w", err) } // Acquire the lock and hold it until we return // This ensures that no two processes will be in runtime.refresh at once @@ -603,7 +603,7 @@ func makeRuntime(runtime *Runtime) (retErr error) { if errors.Is(err, os.ErrNotExist) { doRefresh = true } else { - return fmt.Errorf("error reading runtime status file %s: %w", runtimeAliveFile, err) + return fmt.Errorf("reading runtime status file %s: %w", runtimeAliveFile, err) } } @@ -695,7 +695,7 @@ func (r *Runtime) GetConfig() (*config.Config, error) { // Copy so the caller won't be able to modify the actual config if err := JSONDeepCopy(rtConfig, config); err != nil { - return nil, fmt.Errorf("error copying config: %w", err) + return nil, fmt.Errorf("copying config: %w", err) } return config, nil @@ -806,7 +806,7 @@ func (r *Runtime) Shutdown(force bool) error { // Note that the libimage runtime shuts down the store. if err := r.libimageRuntime.Shutdown(force); err != nil { - lastError = fmt.Errorf("error shutting down container storage: %w", err) + lastError = fmt.Errorf("shutting down container storage: %w", err) } } if err := r.state.Close(); err != nil { @@ -838,15 +838,15 @@ func (r *Runtime) refresh(alivePath string) error { // Containers, pods, and volumes must also reacquire their locks. ctrs, err := r.state.AllContainers() if err != nil { - return fmt.Errorf("error retrieving all containers from state: %w", err) + return fmt.Errorf("retrieving all containers from state: %w", err) } pods, err := r.state.AllPods() if err != nil { - return fmt.Errorf("error retrieving all pods from state: %w", err) + return fmt.Errorf("retrieving all pods from state: %w", err) } vols, err := r.state.AllVolumes() if err != nil { - return fmt.Errorf("error retrieving all volumes from state: %w", err) + return fmt.Errorf("retrieving all volumes from state: %w", err) } // No locks are taken during pod, volume, and container refresh. // Furthermore, the pod/volume/container refresh() functions are not @@ -874,7 +874,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 fmt.Errorf("error creating runtime status file: %w", err) + return fmt.Errorf("creating runtime status file: %w", err) } defer file.Close() diff --git a/libpod/runtime_cstorage.go b/libpod/runtime_cstorage.go index 047375628..372434b49 100644 --- a/libpod/runtime_cstorage.go +++ b/libpod/runtime_cstorage.go @@ -39,7 +39,7 @@ func (r *Runtime) ListStorageContainers() ([]*StorageContainer, error) { // Look up if container is in state hasCtr, err := r.state.HasContainer(ctr.ID) if err != nil { - return nil, fmt.Errorf("error looking up container %s in state: %w", ctr.ID, err) + return nil, fmt.Errorf("looking up container %s in state: %w", ctr.ID, err) } storageCtr.PresentInLibpod = hasCtr @@ -64,7 +64,7 @@ func (r *Runtime) RemoveStorageContainer(idOrName string, force bool) error { if errors.Is(err, storage.ErrLayerUnknown) { return fmt.Errorf("no container with ID or name %q found: %w", idOrName, define.ErrNoSuchCtr) } - return fmt.Errorf("error looking up container %q: %w", idOrName, err) + return fmt.Errorf("looking up container %q: %w", idOrName, err) } // Lookup returns an ID but it's not guaranteed to be a container ID. @@ -74,7 +74,7 @@ func (r *Runtime) RemoveStorageContainer(idOrName string, force bool) error { if errors.Is(err, storage.ErrContainerUnknown) { return fmt.Errorf("%q does not refer to a container: %w", idOrName, define.ErrNoSuchCtr) } - return fmt.Errorf("error retrieving container %q: %w", idOrName, err) + return fmt.Errorf("retrieving container %q: %w", idOrName, err) } // Error out if the container exists in libpod @@ -115,7 +115,7 @@ func (r *Runtime) RemoveStorageContainer(idOrName string, force bool) error { logrus.Infof("Storage for container %s already removed", ctr.ID) return nil } - return fmt.Errorf("error removing storage for container %q: %w", idOrName, err) + return fmt.Errorf("removing storage for container %q: %w", idOrName, err) } return nil diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index fb4f80aa6..c9dc74403 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -86,7 +86,7 @@ func (r *Runtime) RestoreContainer(ctx context.Context, rSpec *spec.Spec, config ctr, err := r.initContainerVariables(rSpec, config) if err != nil { - return nil, fmt.Errorf("error initializing container variables: %w", err) + return nil, fmt.Errorf("initializing container variables: %w", err) } // For an imported checkpoint no one has ever set the StartedTime. Set it now. ctr.state.StartedTime = time.Now() @@ -126,7 +126,7 @@ func (r *Runtime) RenameContainer(ctx context.Context, ctr *Container, newName s // the config was re-written. newConf, err := r.state.GetContainerConfig(ctr.ID()) if err != nil { - return nil, fmt.Errorf("error retrieving container %s configuration from DB to remove: %w", ctr.ID(), err) + return nil, fmt.Errorf("retrieving container %s configuration from DB to remove: %w", ctr.ID(), err) } ctr.config = newConf @@ -143,7 +143,7 @@ func (r *Runtime) RenameContainer(ctx context.Context, ctr *Container, newName s // Set config back to the old name so reflect what is actually // present in the DB. ctr.config.Name = oldName - return nil, fmt.Errorf("error renaming container %s: %w", ctr.ID(), err) + return nil, fmt.Errorf("renaming container %s: %w", ctr.ID(), err) } // Step 3: rename the container in c/storage. @@ -189,7 +189,7 @@ func (r *Runtime) initContainerVariables(rSpec *spec.Spec, config *ContainerConf // This is a restore from an imported checkpoint ctr.restoreFromCheckpoint = true if err := JSONDeepCopy(config, ctr.config); err != nil { - return nil, fmt.Errorf("error copying container config for restore: %w", err) + return nil, fmt.Errorf("copying container config for restore: %w", err) } // If the ID is empty a new name for the restored container was requested if ctr.config.ID == "" { @@ -229,12 +229,12 @@ func (r *Runtime) newContainer(ctx context.Context, rSpec *spec.Spec, options .. ctr, err = r.initContainerVariables(rSpec, nil) if err != nil { - return nil, fmt.Errorf("error initializing container variables: %w", err) + return nil, fmt.Errorf("initializing container variables: %w", err) } for _, option := range options { if err := option(ctr); err != nil { - return nil, fmt.Errorf("error running container create option: %w", err) + return nil, fmt.Errorf("running container create option: %w", err) } } @@ -301,7 +301,7 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai // Allocate a lock for the container lock, err := r.lockManager.AllocateLock() if err != nil { - return nil, fmt.Errorf("error allocating lock for new container: %w", err) + return nil, fmt.Errorf("allocating lock for new container: %w", err) } ctr.lock = lock ctr.config.LockID = ctr.lock.ID() @@ -355,7 +355,7 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai if pod != nil && pod.config.UsePodCgroup && !ctr.IsInfra() { podCgroup, err := pod.CgroupPath() if err != nil { - return nil, fmt.Errorf("error retrieving pod %s cgroup: %w", pod.ID(), err) + return nil, fmt.Errorf("retrieving pod %s cgroup: %w", pod.ID(), err) } expectPodCgroup, err := ctr.expectPodCgroup() if err != nil { @@ -380,7 +380,7 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai case pod != nil && pod.config.UsePodCgroup && !ctr.IsInfra(): podCgroup, err := pod.CgroupPath() if err != nil { - return nil, fmt.Errorf("error retrieving pod %s cgroup: %w", pod.ID(), err) + return nil, fmt.Errorf("retrieving pod %s cgroup: %w", pod.ID(), err) } ctr.config.CgroupParent = podCgroup case rootless.IsRootless() && ctr.config.CgroupsMode != cgroupSplit: @@ -432,7 +432,7 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai defer func() { if retErr != nil { if err := ctr.teardownStorage(); err != nil { - logrus.Errorf("Removing partially-created container root filesystem: %s", err) + logrus.Errorf("Removing partially-created container root filesystem: %v", err) } } }() @@ -476,7 +476,7 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai // The volume exists, we're good continue } else if !errors.Is(err, define.ErrNoSuchVolume) { - return nil, fmt.Errorf("error retrieving named volume %s for new container: %w", vol.Name, err) + return nil, fmt.Errorf("retrieving named volume %s for new container: %w", vol.Name, err) } } if vol.IsAnonymous { @@ -514,7 +514,7 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai } newVol, err := r.newVolume(false, volOptions...) if err != nil { - return nil, fmt.Errorf("error creating named volume %q: %w", vol.Name, err) + return nil, fmt.Errorf("creating named volume %q: %w", vol.Name, err) } ctrNamedVolumes = append(ctrNamedVolumes, newVol) @@ -606,7 +606,7 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force, remo // exist once we're done. newConf, err := r.state.GetContainerConfig(c.ID()) if err != nil { - return fmt.Errorf("error retrieving container %s configuration from DB to remove: %w", c.ID(), err) + return fmt.Errorf("retrieving container %s configuration from DB to remove: %w", c.ID(), err) } c.config = newConf @@ -727,7 +727,7 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force, remo if ok, _ := r.state.HasContainer(c.ID()); !ok { // When the container has already been removed, the OCI runtime directory remain. if err := c.cleanupRuntime(ctx); err != nil { - return fmt.Errorf("error cleaning up container %s from OCI runtime: %w", c.ID(), err) + return fmt.Errorf("cleaning up container %s from OCI runtime: %w", c.ID(), err) } return nil } @@ -739,7 +739,7 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force, remo // Do this before we set ContainerStateRemoving, to ensure that we can // actually remove from the OCI runtime. if err := c.cleanup(ctx); err != nil { - cleanupErr = fmt.Errorf("error cleaning up container %s: %w", c.ID(), err) + cleanupErr = fmt.Errorf("cleaning up container %s: %w", c.ID(), err) } // Set ContainerStateRemoving @@ -799,7 +799,7 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force, remo // Deallocate the container's lock if err := c.lock.Free(); err != nil { if cleanupErr == nil && !os.IsNotExist(err) { - cleanupErr = fmt.Errorf("error freeing lock for container %s: %w", c.ID(), err) + cleanupErr = fmt.Errorf("freeing lock for container %s: %w", c.ID(), err) } else { logrus.Errorf("Free container lock: %v", err) } @@ -1227,7 +1227,7 @@ func (r *Runtime) MountStorageContainer(id string) (string, error) { } mountPoint, err := r.store.Mount(container.ID, "") if err != nil { - return "", fmt.Errorf("error mounting storage for container %s: %w", id, err) + return "", fmt.Errorf("mounting storage for container %s: %w", id, err) } return mountPoint, nil } @@ -1275,7 +1275,7 @@ func (r *Runtime) StorageContainers() ([]storage.Container, error) { storeContainers, err := r.store.Containers() if err != nil { - return nil, fmt.Errorf("error reading list of all storage containers: %w", err) + return nil, fmt.Errorf("reading list of all storage containers: %w", err) } retCtrs := []storage.Container{} for _, container := range storeContainers { diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go index d04607d2e..5510b2af6 100644 --- a/libpod/runtime_img.go +++ b/libpod/runtime_img.go @@ -107,7 +107,7 @@ func (r *Runtime) Build(ctx context.Context, options buildahDefine.BuildOptions, func DownloadFromFile(reader *os.File) (string, error) { outFile, err := ioutil.TempFile(util.Tmpdir(), "import") if err != nil { - return "", fmt.Errorf("error creating file: %w", err) + return "", fmt.Errorf("creating file: %w", err) } defer outFile.Close() @@ -115,7 +115,7 @@ func DownloadFromFile(reader *os.File) (string, error) { _, err = io.Copy(outFile, reader) if err != nil { - return "", fmt.Errorf("error saving %s to %s: %w", reader.Name(), outFile.Name(), err) + return "", fmt.Errorf("saving %s to %s: %w", reader.Name(), outFile.Name(), err) } return outFile.Name(), nil diff --git a/libpod/runtime_migrate.go b/libpod/runtime_migrate.go index 139638a6b..36901d4d0 100644 --- a/libpod/runtime_migrate.go +++ b/libpod/runtime_migrate.go @@ -92,7 +92,7 @@ func (r *Runtime) migrate() error { if needsWrite { if err := r.state.RewriteContainerConfig(ctr, ctr.config); err != nil { - return fmt.Errorf("error rewriting config for container %s: %w", ctr.ID(), err) + return fmt.Errorf("rewriting config for container %s: %w", ctr.ID(), err) } } } diff --git a/libpod/runtime_pod_linux.go b/libpod/runtime_pod_linux.go index 57c0b5c48..3eeef69d8 100644 --- a/libpod/runtime_pod_linux.go +++ b/libpod/runtime_pod_linux.go @@ -36,14 +36,14 @@ func (r *Runtime) NewPod(ctx context.Context, p specgen.PodSpecGenerator, option for _, option := range options { if err := option(pod); err != nil { - return nil, fmt.Errorf("error running pod create option: %w", err) + return nil, fmt.Errorf("running pod create option: %w", err) } } // Allocate a lock for the pod lock, err := r.lockManager.AllocateLock() if err != nil { - return nil, fmt.Errorf("error allocating lock for new pod: %w", err) + return nil, fmt.Errorf("allocating lock for new pod: %w", err) } pod.lock = lock pod.config.LockID = pod.lock.ID() @@ -160,7 +160,7 @@ func (r *Runtime) NewPod(ctx context.Context, p specgen.PodSpecGenerator, option } } if addPodErr != nil { - return nil, fmt.Errorf("error adding pod to state: %w", addPodErr) + return nil, fmt.Errorf("adding pod to state: %w", addPodErr) } return pod, nil @@ -286,7 +286,7 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool, case config.SystemdCgroupsManager: if err := deleteSystemdCgroup(p.state.CgroupPath, p.ResourceLim()); err != nil { if removalErr == nil { - removalErr = fmt.Errorf("error removing pod %s cgroup: %w", p.ID(), err) + removalErr = fmt.Errorf("removing pod %s cgroup: %w", p.ID(), err) } else { logrus.Errorf("Deleting pod %s cgroup %s: %v", p.ID(), p.state.CgroupPath, err) } @@ -300,7 +300,7 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool, conmonCgroup, err := cgroups.Load(conmonCgroupPath) if err != nil && err != cgroups.ErrCgroupDeleted && err != cgroups.ErrCgroupV1Rootless { if removalErr == nil { - removalErr = fmt.Errorf("error retrieving pod %s conmon cgroup: %w", p.ID(), err) + removalErr = fmt.Errorf("retrieving pod %s conmon cgroup: %w", p.ID(), err) } else { logrus.Debugf("Error retrieving pod %s conmon cgroup %s: %v", p.ID(), conmonCgroupPath, err) } @@ -308,7 +308,7 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool, if err == nil { if err = conmonCgroup.Delete(); err != nil { if removalErr == nil { - removalErr = fmt.Errorf("error removing pod %s conmon cgroup: %w", p.ID(), err) + removalErr = fmt.Errorf("removing pod %s conmon cgroup: %w", p.ID(), err) } else { logrus.Errorf("Deleting pod %s conmon cgroup %s: %v", p.ID(), conmonCgroupPath, err) } @@ -317,7 +317,7 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool, cgroup, err := cgroups.Load(p.state.CgroupPath) if err != nil && err != cgroups.ErrCgroupDeleted && err != cgroups.ErrCgroupV1Rootless { if removalErr == nil { - removalErr = fmt.Errorf("error retrieving pod %s cgroup: %w", p.ID(), err) + removalErr = fmt.Errorf("retrieving pod %s cgroup: %w", p.ID(), err) } else { logrus.Errorf("Retrieving pod %s cgroup %s: %v", p.ID(), p.state.CgroupPath, err) } @@ -325,7 +325,7 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool, if err == nil { if err := cgroup.Delete(); err != nil { if removalErr == nil { - removalErr = fmt.Errorf("error removing pod %s cgroup: %w", p.ID(), err) + removalErr = fmt.Errorf("removing pod %s cgroup: %w", p.ID(), err) } else { logrus.Errorf("Deleting pod %s cgroup %s: %v", p.ID(), p.state.CgroupPath, err) } @@ -362,7 +362,7 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool, // Deallocate the pod lock if err := p.lock.Free(); err != nil { if removalErr == nil { - removalErr = fmt.Errorf("error freeing pod %s lock: %w", p.ID(), err) + removalErr = fmt.Errorf("freeing pod %s lock: %w", p.ID(), err) } else { logrus.Errorf("Freeing pod %s lock: %v", p.ID(), err) } diff --git a/libpod/runtime_renumber.go b/libpod/runtime_renumber.go index 9149dd72f..ff70081d8 100644 --- a/libpod/runtime_renumber.go +++ b/libpod/runtime_renumber.go @@ -27,7 +27,7 @@ func (r *Runtime) renumberLocks() error { for _, ctr := range allCtrs { lock, err := r.lockManager.AllocateLock() if err != nil { - return fmt.Errorf("error allocating lock for container %s: %w", ctr.ID(), err) + return fmt.Errorf("allocating lock for container %s: %w", ctr.ID(), err) } ctr.config.LockID = lock.ID() @@ -44,7 +44,7 @@ func (r *Runtime) renumberLocks() error { for _, pod := range allPods { lock, err := r.lockManager.AllocateLock() if err != nil { - return fmt.Errorf("error allocating lock for pod %s: %w", pod.ID(), err) + return fmt.Errorf("allocating lock for pod %s: %w", pod.ID(), err) } pod.config.LockID = lock.ID() @@ -61,7 +61,7 @@ func (r *Runtime) renumberLocks() error { for _, vol := range allVols { lock, err := r.lockManager.AllocateLock() if err != nil { - return fmt.Errorf("error allocating lock for volume %s: %w", vol.Name(), err) + return fmt.Errorf("allocating lock for volume %s: %w", vol.Name(), err) } vol.config.LockID = lock.ID() diff --git a/libpod/util.go b/libpod/util.go index a6e6a4f3e..c5a2b81bd 100644 --- a/libpod/util.go +++ b/libpod/util.go @@ -231,7 +231,7 @@ func DefaultSeccompPath() (string, error) { func checkDependencyContainer(depCtr, ctr *Container) error { state, err := depCtr.State() if err != nil { - return fmt.Errorf("error accessing dependency container %s state: %w", depCtr.ID(), err) + return fmt.Errorf("accessing dependency container %s state: %w", depCtr.ID(), err) } if state == define.ContainerStateRemoving { return fmt.Errorf("cannot use container %s as a dependency as it is being removed: %w", depCtr.ID(), define.ErrCtrStateInvalid) diff --git a/libpod/util_linux.go b/libpod/util_linux.go index 7c79e6ce4..efc11710f 100644 --- a/libpod/util_linux.go +++ b/libpod/util_linux.go @@ -29,7 +29,7 @@ func systemdSliceFromPath(parent, name string, resources *spec.LinuxResources) ( logrus.Debugf("Created cgroup path %s for parent %s and name %s", cgroupPath, parent, name) if err := makeSystemdCgroup(cgroupPath, resources); err != nil { - return "", fmt.Errorf("error creating cgroup %s: %w", cgroupPath, err) + return "", fmt.Errorf("creating cgroup %s: %w", cgroupPath, err) } logrus.Debugf("Created cgroup %s", cgroupPath) @@ -112,17 +112,17 @@ var lvpReleaseLabel = label.ReleaseLabel func LabelVolumePath(path string) error { _, mountLabel, err := lvpInitLabels([]string{}) if err != nil { - return fmt.Errorf("error getting default mountlabels: %w", err) + return fmt.Errorf("getting default mountlabels: %w", err) } if err := lvpReleaseLabel(mountLabel); err != nil { - return fmt.Errorf("error releasing label %q: %w", mountLabel, err) + return fmt.Errorf("releasing label %q: %w", mountLabel, err) } if err := lvpRelabel(path, mountLabel, true); err != nil { if err == syscall.ENOTSUP { logrus.Debugf("Labeling not supported on %q", path) } else { - return fmt.Errorf("error setting selinux label for %s to %q as shared: %w", path, mountLabel, err) + return fmt.Errorf("setting selinux label for %s to %q as shared: %w", path, mountLabel, err) } } return nil diff --git a/libpod/volume_inspect.go b/libpod/volume_inspect.go index c3872bca7..73441576b 100644 --- a/libpod/volume_inspect.go +++ b/libpod/volume_inspect.go @@ -39,7 +39,7 @@ func (v *Volume) Inspect() (*define.InspectVolumeData, error) { req.Name = v.Name() resp, err := v.plugin.GetVolume(req) if err != nil { - return nil, fmt.Errorf("error retrieving volume %s information from plugin %s: %w", v.Name(), v.Driver(), err) + return nil, fmt.Errorf("retrieving volume %s information from plugin %s: %w", v.Name(), v.Driver(), err) } if resp != nil { data.Status = resp.Status diff --git a/pkg/api/handlers/compat/containers_attach.go b/pkg/api/handlers/compat/containers_attach.go index e804e628a..c37dc09af 100644 --- a/pkg/api/handlers/compat/containers_attach.go +++ b/pkg/api/handlers/compat/containers_attach.go @@ -86,7 +86,7 @@ func AttachContainer(w http.ResponseWriter, r *http.Request) { // For Docker compatibility, we need to re-initialize containers in these states. if state == define.ContainerStateConfigured || state == define.ContainerStateExited || state == define.ContainerStateStopped { if err := ctr.Init(r.Context(), ctr.PodID() != ""); err != nil { - utils.Error(w, http.StatusConflict, fmt.Errorf("error preparing container %s for attach: %w", ctr.ID(), err)) + utils.Error(w, http.StatusConflict, fmt.Errorf("preparing container %s for attach: %w", ctr.ID(), err)) return } } else if !(state == define.ContainerStateCreated || state == define.ContainerStateRunning) { diff --git a/pkg/api/handlers/compat/containers_create.go b/pkg/api/handlers/compat/containers_create.go index d4f5d5f36..a86b0b0d5 100644 --- a/pkg/api/handlers/compat/containers_create.go +++ b/pkg/api/handlers/compat/containers_create.go @@ -64,7 +64,7 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) { imageName, err := utils.NormalizeToDockerHub(r, body.Config.Image) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } body.Config.Image = imageName @@ -76,7 +76,7 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) { return } - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error looking up image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("looking up image: %w", err)) return } @@ -480,7 +480,7 @@ func cliOpts(cc handlers.CreateContainerConfig, rtc *config.Config) (*entities.C } if err := os.MkdirAll(vol, 0o755); err != nil { if !os.IsExist(err) { - return nil, nil, fmt.Errorf("error making volume mountpoint for volume %s: %w", vol, err) + return nil, nil, fmt.Errorf("making volume mountpoint for volume %s: %w", vol, err) } } } diff --git a/pkg/api/handlers/compat/exec.go b/pkg/api/handlers/compat/exec.go index 1b4dead8b..17f199a8b 100644 --- a/pkg/api/handlers/compat/exec.go +++ b/pkg/api/handlers/compat/exec.go @@ -26,7 +26,7 @@ func ExecCreateHandler(w http.ResponseWriter, r *http.Request) { input := new(handlers.ExecCreateConfig) if err := json.NewDecoder(r.Body).Decode(&input); err != nil { - utils.InternalServerError(w, fmt.Errorf("error decoding request body as JSON: %w", err)) + utils.InternalServerError(w, fmt.Errorf("decoding request body as JSON: %w", err)) return } @@ -114,7 +114,7 @@ func ExecInspectHandler(w http.ResponseWriter, r *http.Request) { session, err := sessionCtr.ExecSession(sessionID) if err != nil { - utils.InternalServerError(w, fmt.Errorf("error retrieving exec session %s from container %s: %w", sessionID, sessionCtr.ID(), err)) + utils.InternalServerError(w, fmt.Errorf("retrieving exec session %s from container %s: %w", sessionID, sessionCtr.ID(), err)) return } @@ -174,7 +174,7 @@ func ExecStartHandler(w http.ResponseWriter, r *http.Request) { } logErr := func(e error) { - logrus.Error(fmt.Errorf("error attaching to container %s exec session %s: %w", sessionCtr.ID(), sessionID, e)) + logrus.Error(fmt.Errorf("attaching to container %s exec session %s: %w", sessionCtr.ID(), sessionID, e)) } var size *resize.TerminalSize diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go index 39bd165d6..0493c6ffb 100644 --- a/pkg/api/handlers/compat/images.go +++ b/pkg/api/handlers/compat/images.go @@ -59,7 +59,7 @@ func ExportImage(w http.ResponseWriter, r *http.Request) { name := utils.GetName(r) possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, name) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } @@ -155,7 +155,7 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) { destImage = fmt.Sprintf("%s:%s", query.Repo, query.Tag) possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, destImage) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } destImage = possiblyNormalizedName @@ -209,7 +209,7 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) { if query.Repo != "" { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, reference) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } reference = possiblyNormalizedName @@ -272,7 +272,7 @@ func CreateImageFromImage(w http.ResponseWriter, r *http.Request) { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, mergeNameAndTagOrDigest(query.FromImage, query.Tag)) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } @@ -390,7 +390,7 @@ func GetImage(w http.ResponseWriter, r *http.Request) { name := utils.GetName(r) possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, name) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } @@ -541,7 +541,7 @@ func ExportImages(w http.ResponseWriter, r *http.Request) { for i, img := range query.Names { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, img) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } images[i] = possiblyNormalizedName diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 7ba1029a7..4035b4315 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -343,7 +343,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { if len(tags) > 0 { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, tags[0]) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } output = possiblyNormalizedName @@ -376,7 +376,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { for i := 1; i < len(tags); i++ { possiblyNormalizedTag, err := utils.NormalizeToDockerHub(r, tags[i]) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } additionalTags = append(additionalTags, possiblyNormalizedTag) @@ -578,7 +578,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { if fromImage != "" { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, fromImage) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } fromImage = possiblyNormalizedName diff --git a/pkg/api/handlers/compat/images_history.go b/pkg/api/handlers/compat/images_history.go index ebb5acdd9..1b83d274a 100644 --- a/pkg/api/handlers/compat/images_history.go +++ b/pkg/api/handlers/compat/images_history.go @@ -16,7 +16,7 @@ func HistoryImage(w http.ResponseWriter, r *http.Request) { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, name) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } diff --git a/pkg/api/handlers/compat/images_push.go b/pkg/api/handlers/compat/images_push.go index f29808124..a1173de0b 100644 --- a/pkg/api/handlers/compat/images_push.go +++ b/pkg/api/handlers/compat/images_push.go @@ -69,7 +69,7 @@ func PushImage(w http.ResponseWriter, r *http.Request) { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, imageName) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } imageName = possiblyNormalizedName diff --git a/pkg/api/handlers/compat/images_remove.go b/pkg/api/handlers/compat/images_remove.go index b59bfd0b1..71d6a644f 100644 --- a/pkg/api/handlers/compat/images_remove.go +++ b/pkg/api/handlers/compat/images_remove.go @@ -37,7 +37,7 @@ func RemoveImage(w http.ResponseWriter, r *http.Request) { name := utils.GetName(r) possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, name) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } diff --git a/pkg/api/handlers/compat/images_tag.go b/pkg/api/handlers/compat/images_tag.go index a1da7a4b9..e9f6dedd0 100644 --- a/pkg/api/handlers/compat/images_tag.go +++ b/pkg/api/handlers/compat/images_tag.go @@ -17,7 +17,7 @@ func TagImage(w http.ResponseWriter, r *http.Request) { name := utils.GetName(r) possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, name) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } @@ -42,7 +42,7 @@ func TagImage(w http.ResponseWriter, r *http.Request) { possiblyNormalizedTag, err := utils.NormalizeToDockerHub(r, tagName) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } diff --git a/pkg/api/handlers/libpod/generate.go b/pkg/api/handlers/libpod/generate.go index 431927ac5..9b38829ad 100644 --- a/pkg/api/handlers/libpod/generate.go +++ b/pkg/api/handlers/libpod/generate.go @@ -78,7 +78,7 @@ func GenerateSystemd(w http.ResponseWriter, r *http.Request) { report, err := containerEngine.GenerateSystemd(r.Context(), utils.GetName(r), options) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error generating systemd units: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("generating systemd units: %w", err)) return } @@ -104,7 +104,7 @@ func GenerateKube(w http.ResponseWriter, r *http.Request) { options := entities.GenerateKubeOptions{Service: query.Service} report, err := containerEngine.GenerateKube(r.Context(), query.Names, options) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error generating YAML: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("generating YAML: %w", err)) return } diff --git a/pkg/api/handlers/libpod/images_push.go b/pkg/api/handlers/libpod/images_push.go index be6f5b131..4102f23de 100644 --- a/pkg/api/handlers/libpod/images_push.go +++ b/pkg/api/handlers/libpod/images_push.go @@ -91,7 +91,7 @@ func PushImage(w http.ResponseWriter, r *http.Request) { // Let's keep thing simple when running in quiet mode and push directly. if query.Quiet { if err := imageEngine.Push(r.Context(), source, destination, options); err != nil { - utils.Error(w, http.StatusBadRequest, fmt.Errorf("error pushing image %q: %w", destination, err)) + utils.Error(w, http.StatusBadRequest, fmt.Errorf("pushing image %q: %w", destination, err)) return } utils.WriteResponse(w, http.StatusOK, "") diff --git a/pkg/api/handlers/libpod/kube.go b/pkg/api/handlers/libpod/kube.go index 5c891b707..2a61d1723 100644 --- a/pkg/api/handlers/libpod/kube.go +++ b/pkg/api/handlers/libpod/kube.go @@ -103,7 +103,7 @@ func KubePlay(w http.ResponseWriter, r *http.Request) { report, err := containerEngine.PlayKube(r.Context(), r.Body, options) _ = r.Body.Close() if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error playing YAML file: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("playing YAML file: %w", err)) return } utils.WriteResponse(w, http.StatusOK, report) @@ -116,7 +116,7 @@ func KubePlayDown(w http.ResponseWriter, r *http.Request) { report, err := containerEngine.PlayKubeDown(r.Context(), r.Body, *options) _ = r.Body.Close() if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error tearing down YAML file: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("tearing down YAML file: %w", err)) return } utils.WriteResponse(w, http.StatusOK, report) diff --git a/pkg/api/handlers/libpod/manifests.go b/pkg/api/handlers/libpod/manifests.go index 8391def5c..d5af72a61 100644 --- a/pkg/api/handlers/libpod/manifests.go +++ b/pkg/api/handlers/libpod/manifests.go @@ -295,7 +295,7 @@ func ManifestPushV3(w http.ResponseWriter, r *http.Request) { imageEngine := abi.ImageEngine{Libpod: runtime} digest, err := imageEngine.ManifestPush(r.Context(), source, query.Destination, options) if err != nil { - utils.Error(w, http.StatusBadRequest, fmt.Errorf("error pushing image %q: %w", query.Destination, err)) + utils.Error(w, http.StatusBadRequest, fmt.Errorf("pushing image %q: %w", query.Destination, err)) return } utils.WriteResponse(w, http.StatusOK, entities.IDResponse{ID: digest}) @@ -369,7 +369,7 @@ func ManifestPush(w http.ResponseWriter, r *http.Request) { if query.Quiet { digest, err := imageEngine.ManifestPush(r.Context(), source, destination, options) if err != nil { - utils.Error(w, http.StatusBadRequest, fmt.Errorf("error pushing image %q: %w", destination, err)) + utils.Error(w, http.StatusBadRequest, fmt.Errorf("pushing image %q: %w", destination, err)) return } utils.WriteResponse(w, http.StatusOK, entities.ManifestPushReport{ID: digest}) diff --git a/pkg/api/handlers/libpod/pods.go b/pkg/api/handlers/libpod/pods.go index 8b1d456ec..c39b9ee2f 100644 --- a/pkg/api/handlers/libpod/pods.go +++ b/pkg/api/handlers/libpod/pods.go @@ -51,7 +51,7 @@ func PodCreate(w http.ResponseWriter, r *http.Request) { } err = specgenutil.FillOutSpecGen(psg.InfraContainerSpec, &infraOptions, []string{}) // necessary for default values in many cases (userns, idmappings) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error filling out specgen: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("filling out specgen: %w", err)) return } out, err := json.Marshal(psg) // marshal our spec so the matching options can be unmarshaled into infra @@ -178,7 +178,7 @@ func PodStop(w http.ResponseWriter, r *http.Request) { report := entities.PodStopReport{Id: pod.ID()} for id, err := range responses { - report.Errs = append(report.Errs, fmt.Errorf("error stopping container %s: %w", id, err)) + report.Errs = append(report.Errs, fmt.Errorf("stopping container %s: %w", id, err)) } code := http.StatusOK @@ -214,7 +214,7 @@ func PodStart(w http.ResponseWriter, r *http.Request) { report := entities.PodStartReport{Id: pod.ID()} for id, err := range responses { - report.Errs = append(report.Errs, fmt.Errorf("%v: %w", "error starting container "+id, err)) + report.Errs = append(report.Errs, fmt.Errorf("%v: %w", "starting container "+id, err)) } code := http.StatusOK @@ -270,7 +270,7 @@ func PodRestart(w http.ResponseWriter, r *http.Request) { report := entities.PodRestartReport{Id: pod.ID()} for id, err := range responses { - report.Errs = append(report.Errs, fmt.Errorf("error restarting container %s: %w", id, err)) + report.Errs = append(report.Errs, fmt.Errorf("restarting container %s: %w", id, err)) } code := http.StatusOK @@ -321,7 +321,7 @@ func PodPause(w http.ResponseWriter, r *http.Request) { report := entities.PodPauseReport{Id: pod.ID()} for id, v := range responses { - report.Errs = append(report.Errs, fmt.Errorf("error pausing container %s: %w", id, v)) + report.Errs = append(report.Errs, fmt.Errorf("pausing container %s: %w", id, v)) } code := http.StatusOK @@ -347,7 +347,7 @@ func PodUnpause(w http.ResponseWriter, r *http.Request) { report := entities.PodUnpauseReport{Id: pod.ID()} for id, v := range responses { - report.Errs = append(report.Errs, fmt.Errorf("error unpausing container %s: %w", id, v)) + report.Errs = append(report.Errs, fmt.Errorf("unpausing container %s: %w", id, v)) } code := http.StatusOK diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index dd934fabd..270cd4207 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -238,10 +238,10 @@ func authConfigsToAuthFile(authConfigs map[string]types.DockerAuthConfig) (strin return "", err } if _, err := tmpFile.Write([]byte{'{', '}'}); err != nil { - return "", fmt.Errorf("error initializing temporary auth file: %w", err) + return "", fmt.Errorf("initializing temporary auth file: %w", err) } if err := tmpFile.Close(); err != nil { - return "", fmt.Errorf("error closing temporary auth file: %w", err) + return "", fmt.Errorf("closing temporary auth file: %w", err) } authFilePath := tmpFile.Name() @@ -255,7 +255,7 @@ func authConfigsToAuthFile(authConfigs map[string]types.DockerAuthConfig) (strin // that all credentials are valid. They'll be used on demand // later. if err := imageAuth.SetAuthentication(&sys, key, config.Username, config.Password); err != nil { - return "", fmt.Errorf("error storing credentials in temporary auth file (key: %q / %q, user: %q): %w", authFileKey, key, config.Username, err) + return "", fmt.Errorf("storing credentials in temporary auth file (key: %q / %q, user: %q): %w", authFileKey, key, config.Username, err) } } diff --git a/pkg/bindings/containers/exec.go b/pkg/bindings/containers/exec.go index 3d19fb812..c5c8760ed 100644 --- a/pkg/bindings/containers/exec.go +++ b/pkg/bindings/containers/exec.go @@ -33,7 +33,7 @@ func ExecCreate(ctx context.Context, nameOrID string, config *handlers.ExecCreat requestJSON, err := json.Marshal(config) if err != nil { - return "", fmt.Errorf("error marshalling exec config to JSON: %w", err) + return "", fmt.Errorf("marshalling exec config to JSON: %w", err) } jsonReader := strings.NewReader(string(requestJSON)) diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go index 8348ac54b..ef875c9eb 100644 --- a/pkg/bindings/images/build.go +++ b/pkg/bindings/images/build.go @@ -590,7 +590,7 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO func nTar(excludes []string, sources ...string) (io.ReadCloser, error) { pm, err := fileutils.NewPatternMatcher(excludes) if err != nil { - return nil, fmt.Errorf("error processing excludes list %v: %w", excludes, err) + return nil, fmt.Errorf("processing excludes list %v: %w", excludes, err) } if len(sources) == 0 { @@ -639,7 +639,7 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) { excluded, err := pm.Matches(name) //nolint:staticcheck if err != nil { - return fmt.Errorf("error checking if %q is excluded: %w", name, err) + return fmt.Errorf("checking if %q is excluded: %w", name, err) } if excluded { // Note: filepath.SkipDir is not possible to use given .dockerignore semantics. @@ -742,7 +742,7 @@ func parseDockerignore(root string) ([]string, error) { var dockerIgnoreErr error ignore, dockerIgnoreErr = ioutil.ReadFile(filepath.Join(root, ".dockerignore")) if dockerIgnoreErr != nil && !os.IsNotExist(dockerIgnoreErr) { - return nil, fmt.Errorf("error reading .containerignore: '%s': %w", root, err) + return nil, err } } rawexcludes := strings.Split(string(ignore), "\n") diff --git a/pkg/checkpoint/crutils/checkpoint_restore_utils.go b/pkg/checkpoint/crutils/checkpoint_restore_utils.go index 1437a09df..132632322 100644 --- a/pkg/checkpoint/crutils/checkpoint_restore_utils.go +++ b/pkg/checkpoint/crutils/checkpoint_restore_utils.go @@ -159,11 +159,11 @@ func CRCreateRootFsDiffTar(changes *[]archive.Change, mountPoint, destination st IncludeFiles: rootfsIncludeFiles, }) if err != nil { - return includeFiles, fmt.Errorf("error exporting root file-system diff to %q: %w", rootfsDiffPath, err) + return includeFiles, fmt.Errorf("exporting root file-system diff to %q: %w", rootfsDiffPath, err) } rootfsDiffFile, err := os.Create(rootfsDiffPath) if err != nil { - return includeFiles, fmt.Errorf("error creating root file-system diff file %q: %w", rootfsDiffPath, err) + return includeFiles, fmt.Errorf("creating root file-system diff file %q: %w", rootfsDiffPath, err) } defer rootfsDiffFile.Close() if _, err = io.Copy(rootfsDiffFile, rootfsTar); err != nil { diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index 569fe8133..535c4a613 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -821,7 +821,7 @@ func (ic *ContainerEngine) ContainerAttach(ctx context.Context, nameOrID string, // If the container is in a pod, also set to recursively start dependencies err = terminal.StartAttachCtr(ctx, ctr, options.Stdout, options.Stderr, options.Stdin, options.DetachKeys, options.SigProxy, false) if err != nil && !errors.Is(err, define.ErrDetach) { - return fmt.Errorf("error attaching to container %s: %w", ctr.ID(), err) + return fmt.Errorf("attaching to container %s: %w", ctr.ID(), err) } os.Stdout.WriteString("\n") return nil @@ -843,12 +843,12 @@ func makeExecConfig(options entities.ExecOptions, rt *libpod.Runtime) (*libpod.E storageConfig := rt.StorageConfig() runtimeConfig, err := rt.GetConfig() if err != nil { - return nil, fmt.Errorf("error retrieving Libpod configuration to build exec exit command: %w", err) + return nil, fmt.Errorf("retrieving Libpod configuration to build exec exit command: %w", err) } // TODO: Add some ability to toggle syslog exitCommandArgs, err := specgenutil.CreateExitCommandArgs(storageConfig, runtimeConfig, logrus.IsLevelEnabled(logrus.DebugLevel), false, true) if err != nil { - return nil, fmt.Errorf("error constructing exit command for exec session: %w", err) + return nil, fmt.Errorf("constructing exit command for exec session: %w", err) } execConfig.ExitCommand = exitCommandArgs @@ -1448,7 +1448,7 @@ func (ic *ContainerEngine) ContainerUnmount(ctx context.Context, nameOrIDs []str logrus.Debugf("Error umounting container %s, storage.ErrLayerNotMounted", ctr.ID()) continue } - report.Err = fmt.Errorf("error unmounting container %s: %w", ctr.ID(), err) + report.Err = fmt.Errorf("unmounting container %s: %w", ctr.ID(), err) } reports = append(reports, &report) } diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go index 3030bac20..6934de60e 100644 --- a/pkg/domain/infra/abi/images.go +++ b/pkg/domain/infra/abi/images.go @@ -597,7 +597,7 @@ func (ir *ImageEngine) Shutdown(_ context.Context) { func (ir *ImageEngine) Sign(ctx context.Context, names []string, options entities.SignOptions) (*entities.SignReport, error) { mech, err := signature.NewGPGSigningMechanism() if err != nil { - return nil, fmt.Errorf("error initializing GPG: %w", err) + return nil, fmt.Errorf("initializing GPG: %w", err) } defer mech.Close() if err := mech.SupportsSigning(); err != nil { @@ -611,11 +611,11 @@ func (ir *ImageEngine) Sign(ctx context.Context, names []string, options entitie err = func() error { srcRef, err := alltransports.ParseImageName(signimage) if err != nil { - return fmt.Errorf("error parsing image name: %w", err) + return fmt.Errorf("parsing image name: %w", err) } rawSource, err := srcRef.NewImageSource(ctx, sc) if err != nil { - return fmt.Errorf("error getting image source: %w", err) + return fmt.Errorf("getting image source: %w", err) } defer func() { if err = rawSource.Close(); err != nil { @@ -624,7 +624,7 @@ func (ir *ImageEngine) Sign(ctx context.Context, names []string, options entitie }() topManifestBlob, manifestType, err := rawSource.GetManifest(ctx, nil) if err != nil { - return fmt.Errorf("error getting manifest blob: %w", err) + return fmt.Errorf("getting manifest blob: %w", err) } dockerReference := rawSource.Reference().DockerReference() if dockerReference == nil { @@ -658,7 +658,7 @@ func (ir *ImageEngine) Sign(ctx context.Context, names []string, options entitie } list, err := manifest.ListFromBlob(topManifestBlob, manifestType) if err != nil { - return fmt.Errorf("error parsing manifest list %q: %w", string(topManifestBlob), err) + return fmt.Errorf("parsing manifest list %q: %w", string(topManifestBlob), err) } instanceDigests := list.Instances() for _, instanceDigest := range instanceDigests { @@ -668,13 +668,13 @@ func (ir *ImageEngine) Sign(ctx context.Context, names []string, options entitie return err } if err = putSignature(man, mech, sigStoreDir, instanceDigest, dockerReference, options); err != nil { - return fmt.Errorf("error storing signature for %s, %v: %w", dockerReference.String(), instanceDigest, err) + return fmt.Errorf("storing signature for %s, %v: %w", dockerReference.String(), instanceDigest, err) } } return nil } if err = putSignature(topManifestBlob, mech, sigStoreDir, manifestDigest, dockerReference, options); err != nil { - return fmt.Errorf("error storing signature for %s, %v: %w", dockerReference.String(), manifestDigest, err) + return fmt.Errorf("storing signature for %s, %v: %w", dockerReference.String(), manifestDigest, err) } return nil }() diff --git a/pkg/domain/infra/abi/images_list.go b/pkg/domain/infra/abi/images_list.go index 96e99fbf0..4788ecef9 100644 --- a/pkg/domain/infra/abi/images_list.go +++ b/pkg/domain/infra/abi/images_list.go @@ -32,7 +32,7 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions) } isDangling, err := img.IsDangling(ctx) if err != nil { - return nil, fmt.Errorf("error checking if image %q is dangling: %w", img.ID(), err) + return nil, fmt.Errorf("checking if image %q is dangling: %w", img.ID(), err) } e := entities.ImageSummary{ @@ -49,18 +49,18 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions) } e.Labels, err = img.Labels(ctx) if err != nil { - return nil, fmt.Errorf("error retrieving label for image %q: you may need to remove the image to resolve the error: %w", img.ID(), err) + return nil, fmt.Errorf("retrieving label for image %q: you may need to remove the image to resolve the error: %w", img.ID(), err) } ctnrs, err := img.Containers() if err != nil { - return nil, fmt.Errorf("error retrieving containers for image %q: you may need to remove the image to resolve the error: %w", img.ID(), err) + return nil, fmt.Errorf("retrieving containers for image %q: you may need to remove the image to resolve the error: %w", img.ID(), err) } e.Containers = len(ctnrs) sz, err := img.Size() if err != nil { - return nil, fmt.Errorf("error retrieving size of image %q: you may need to remove the image to resolve the error: %w", img.ID(), err) + return nil, fmt.Errorf("retrieving size of image %q: you may need to remove the image to resolve the error: %w", img.ID(), err) } e.Size = sz // This is good enough for now, but has to be @@ -69,7 +69,7 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions) parent, err := img.Parent(ctx) if err != nil { - return nil, fmt.Errorf("error retrieving parent of image %q: you may need to remove the image to resolve the error: %w", img.ID(), err) + return nil, fmt.Errorf("retrieving parent of image %q: you may need to remove the image to resolve the error: %w", img.ID(), err) } if parent != nil { e.ParentId = parent.ID() diff --git a/pkg/domain/infra/abi/manifest.go b/pkg/domain/infra/abi/manifest.go index 7e8c86526..ac3eedbe8 100644 --- a/pkg/domain/infra/abi/manifest.go +++ b/pkg/domain/infra/abi/manifest.go @@ -95,7 +95,7 @@ func (ir *ImageEngine) ManifestInspect(ctx context.Context, name string) ([]byte var b bytes.Buffer if err := json.Indent(&b, rawSchema2List, "", " "); err != nil { - return nil, fmt.Errorf("error rendering manifest %s for display: %w", name, err) + return nil, fmt.Errorf("rendering manifest %s for display: %w", name, err) } return b.Bytes(), nil } @@ -158,7 +158,7 @@ func (ir *ImageEngine) remoteManifestInspect(ctx context.Context, name string) ( logrus.Warnf("The manifest type %s is not a manifest list but a single image.", manType) schema2Manifest, err := manifest.Schema2FromManifest(result) if err != nil { - return nil, fmt.Errorf("error parsing manifest blob %q as a %q: %w", string(result), manType, err) + return nil, fmt.Errorf("parsing manifest blob %q as a %q: %w", string(result), manType, err) } if result, err = schema2Manifest.Serialize(); err != nil { return nil, err @@ -166,7 +166,7 @@ func (ir *ImageEngine) remoteManifestInspect(ctx context.Context, name string) ( default: listBlob, err := manifest.ListFromBlob(result, manType) if err != nil { - return nil, fmt.Errorf("error parsing manifest blob %q as a %q: %w", string(result), manType, err) + return nil, fmt.Errorf("parsing manifest blob %q as a %q: %w", string(result), manType, err) } list, err := listBlob.ConvertToMIMEType(manifest.DockerV2ListMediaType) if err != nil { @@ -178,7 +178,7 @@ func (ir *ImageEngine) remoteManifestInspect(ctx context.Context, name string) ( } if err = json.Indent(&b, result, "", " "); err != nil { - return nil, fmt.Errorf("error rendering manifest %s for display: %w", name, err) + return nil, fmt.Errorf("rendering manifest %s for display: %w", name, err) } return b.Bytes(), nil } @@ -301,7 +301,7 @@ func (ir *ImageEngine) ManifestRm(ctx context.Context, names []string) (report * func (ir *ImageEngine) ManifestPush(ctx context.Context, name, destination string, opts entities.ImagePushOptions) (string, error) { manifestList, err := ir.Libpod.LibimageRuntime().LookupManifestList(name) if err != nil { - return "", fmt.Errorf("error retrieving local image from image name %s: %w", name, err) + return "", fmt.Errorf("retrieving local image from image name %s: %w", name, err) } var manifestType string @@ -362,7 +362,7 @@ func (ir *ImageEngine) ManifestPush(ctx context.Context, name, destination strin if opts.Rm { rmOpts := &libimage.RemoveImagesOptions{LookupManifest: true} if _, rmErrors := ir.Libpod.LibimageRuntime().RemoveImages(ctx, []string{manifestList.ID()}, rmOpts); len(rmErrors) > 0 { - return "", fmt.Errorf("error removing manifest after push: %w", rmErrors[0]) + return "", fmt.Errorf("removing manifest after push: %w", rmErrors[0]) } } diff --git a/pkg/domain/infra/abi/network.go b/pkg/domain/infra/abi/network.go index 2428abfe9..a29b6818f 100644 --- a/pkg/domain/infra/abi/network.go +++ b/pkg/domain/infra/abi/network.go @@ -61,7 +61,7 @@ func (ic *ContainerEngine) NetworkInspect(ctx context.Context, namesOrIds []stri errs = append(errs, fmt.Errorf("network %s: %w", name, err)) continue } else { - return nil, nil, fmt.Errorf("error inspecting network %s: %w", name, err) + return nil, nil, fmt.Errorf("inspecting network %s: %w", name, err) } } networks = append(networks, net) diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go index 57d795682..db72bb355 100644 --- a/pkg/domain/infra/abi/play.go +++ b/pkg/domain/infra/abi/play.go @@ -298,7 +298,7 @@ func (ic *ContainerEngine) playKubeDeployment(ctx context.Context, deploymentYAM podName := fmt.Sprintf("%s-pod-%d", deploymentName, i) podReport, err := ic.playKubePod(ctx, podName, &podSpec, options, ipIndex, deploymentYAML.Annotations, configMaps, serviceContainer) if err != nil { - return nil, fmt.Errorf("error encountered while bringing up pod %s: %w", podName, err) + return nil, fmt.Errorf("encountered while bringing up pod %s: %w", podName, err) } report.Pods = append(report.Pods, podReport.Pods...) } @@ -694,7 +694,7 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY return nil, err } for id, err := range podStartErrors { - playKubePod.ContainerErrors = append(playKubePod.ContainerErrors, fmt.Errorf("error starting container %s: %w", id, err).Error()) + playKubePod.ContainerErrors = append(playKubePod.ContainerErrors, fmt.Errorf("starting container %s: %w", id, err).Error()) fmt.Println(playKubePod.ContainerErrors) } diff --git a/pkg/domain/infra/abi/pods.go b/pkg/domain/infra/abi/pods.go index 68f2fa125..45a47b46e 100644 --- a/pkg/domain/infra/abi/pods.go +++ b/pkg/domain/infra/abi/pods.go @@ -77,7 +77,7 @@ func (ic *ContainerEngine) PodKill(ctx context.Context, namesOrIds []string, opt } if len(conErrs) > 0 { for id, err := range conErrs { - report.Errs = append(report.Errs, fmt.Errorf("error killing container %s: %w", id, err)) + report.Errs = append(report.Errs, fmt.Errorf("killing container %s: %w", id, err)) } reports = append(reports, &report) continue @@ -143,7 +143,7 @@ func (ic *ContainerEngine) PodPause(ctx context.Context, namesOrIds []string, op } if len(errs) > 0 { for id, v := range errs { - report.Errs = append(report.Errs, fmt.Errorf("error pausing container %s: %w", id, v)) + report.Errs = append(report.Errs, fmt.Errorf("pausing container %s: %w", id, v)) } reports = append(reports, &report) continue @@ -177,7 +177,7 @@ func (ic *ContainerEngine) PodUnpause(ctx context.Context, namesOrIds []string, } if len(errs) > 0 { for id, v := range errs { - report.Errs = append(report.Errs, fmt.Errorf("error unpausing container %s: %w", id, v)) + report.Errs = append(report.Errs, fmt.Errorf("unpausing container %s: %w", id, v)) } reports = append(reports, &report) continue @@ -203,7 +203,7 @@ func (ic *ContainerEngine) PodStop(ctx context.Context, namesOrIds []string, opt } if len(errs) > 0 { for id, v := range errs { - report.Errs = append(report.Errs, fmt.Errorf("error stopping container %s: %w", id, v)) + report.Errs = append(report.Errs, fmt.Errorf("stopping container %s: %w", id, v)) } reports = append(reports, &report) continue @@ -229,7 +229,7 @@ func (ic *ContainerEngine) PodRestart(ctx context.Context, namesOrIds []string, } if len(errs) > 0 { for id, v := range errs { - report.Errs = append(report.Errs, fmt.Errorf("error restarting container %s: %w", id, v)) + report.Errs = append(report.Errs, fmt.Errorf("restarting container %s: %w", id, v)) } reports = append(reports, &report) continue @@ -256,7 +256,7 @@ func (ic *ContainerEngine) PodStart(ctx context.Context, namesOrIds []string, op } if len(errs) > 0 { for id, v := range errs { - report.Errs = append(report.Errs, fmt.Errorf("error starting container %s: %w", id, v)) + report.Errs = append(report.Errs, fmt.Errorf("starting container %s: %w", id, v)) } reports = append(reports, &report) continue diff --git a/pkg/domain/infra/abi/secrets.go b/pkg/domain/infra/abi/secrets.go index e82fa4fdd..e17de5a8c 100644 --- a/pkg/domain/infra/abi/secrets.go +++ b/pkg/domain/infra/abi/secrets.go @@ -65,7 +65,7 @@ func (ic *ContainerEngine) SecretInspect(ctx context.Context, nameOrIDs []string errs = append(errs, err) continue } else { - return nil, nil, fmt.Errorf("error inspecting secret %s: %w", nameOrID, err) + return nil, nil, fmt.Errorf("inspecting secret %s: %w", nameOrID, err) } } report := &entities.SecretInfoReport{ diff --git a/pkg/domain/infra/abi/terminal/terminal_common.go b/pkg/domain/infra/abi/terminal/terminal_common.go index afae2c085..d00595908 100644 --- a/pkg/domain/infra/abi/terminal/terminal_common.go +++ b/pkg/domain/infra/abi/terminal/terminal_common.go @@ -106,7 +106,7 @@ func StartAttachCtr(ctx context.Context, ctr *libpod.Container, stdout, stderr, err = <-attachChan if err != nil { - return fmt.Errorf("error attaching to container %s: %w", ctr.ID(), err) + return fmt.Errorf("attaching to container %s: %w", ctr.ID(), err) } return nil diff --git a/pkg/domain/infra/abi/volumes.go b/pkg/domain/infra/abi/volumes.go index 5e95a0551..bdfd4d5aa 100644 --- a/pkg/domain/infra/abi/volumes.go +++ b/pkg/domain/infra/abi/volumes.go @@ -96,7 +96,7 @@ func (ic *ContainerEngine) VolumeInspect(ctx context.Context, namesOrIds []strin errs = append(errs, fmt.Errorf("no such volume %s", v)) continue } else { - return nil, nil, fmt.Errorf("error inspecting volume %s: %w", v, err) + return nil, nil, fmt.Errorf("inspecting volume %s: %w", v, err) } } vols = append(vols, vol) diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go index 68ca788b8..324802a1f 100644 --- a/pkg/domain/infra/tunnel/containers.go +++ b/pkg/domain/infra/tunnel/containers.go @@ -331,7 +331,7 @@ func (ic *ContainerEngine) ContainerCommit(ctx context.Context, nameOrID string, if len(opts.ImageName) > 0 { ref, err := reference.Parse(opts.ImageName) if err != nil { - return nil, fmt.Errorf("error parsing reference %q: %w", opts.ImageName, err) + return nil, fmt.Errorf("parsing reference %q: %w", opts.ImageName, err) } if t, ok := ref.(reference.Tagged); ok { tag = t.Tag() diff --git a/pkg/domain/infra/tunnel/images.go b/pkg/domain/infra/tunnel/images.go index 2716aaf2a..cc99b1b3a 100644 --- a/pkg/domain/infra/tunnel/images.go +++ b/pkg/domain/infra/tunnel/images.go @@ -133,7 +133,7 @@ func (ir *ImageEngine) Tag(ctx context.Context, nameOrID string, tags []string, ) ref, err := reference.Parse(newTag) if err != nil { - return fmt.Errorf("error parsing reference %q: %w", newTag, err) + return fmt.Errorf("parsing reference %q: %w", newTag, err) } if t, ok := ref.(reference.Tagged); ok { tag = t.Tag() @@ -163,7 +163,7 @@ func (ir *ImageEngine) Untag(ctx context.Context, nameOrID string, tags []string ) ref, err := reference.Parse(newTag) if err != nil { - return fmt.Errorf("error parsing reference %q: %w", newTag, err) + return fmt.Errorf("parsing reference %q: %w", newTag, err) } if t, ok := ref.(reference.Tagged); ok { tag = t.Tag() diff --git a/pkg/domain/infra/tunnel/manifest.go b/pkg/domain/infra/tunnel/manifest.go index 2e6134051..696d0a963 100644 --- a/pkg/domain/infra/tunnel/manifest.go +++ b/pkg/domain/infra/tunnel/manifest.go @@ -18,7 +18,7 @@ func (ir *ImageEngine) ManifestCreate(ctx context.Context, name string, images [ options := new(manifests.CreateOptions).WithAll(opts.All).WithAmend(opts.Amend) imageID, err := manifests.Create(ir.ClientCtx, name, images, options) if err != nil { - return imageID, fmt.Errorf("error creating manifest: %w", err) + return imageID, fmt.Errorf("creating manifest: %w", err) } return imageID, err } @@ -36,12 +36,12 @@ func (ir *ImageEngine) ManifestExists(ctx context.Context, name string) (*entiti func (ir *ImageEngine) ManifestInspect(_ context.Context, name string) ([]byte, error) { list, err := manifests.Inspect(ir.ClientCtx, name, nil) if err != nil { - return nil, fmt.Errorf("error getting content of manifest list or image %s: %w", name, err) + return nil, fmt.Errorf("getting content of manifest list or image %s: %w", name, err) } buf, err := json.MarshalIndent(list, "", " ") if err != nil { - return buf, fmt.Errorf("error rendering manifest for display: %w", err) + return buf, fmt.Errorf("rendering manifest for display: %w", err) } return buf, err } @@ -72,7 +72,7 @@ func (ir *ImageEngine) ManifestAdd(_ context.Context, name string, imageNames [] id, err := manifests.Add(ir.ClientCtx, name, options) if err != nil { - return id, fmt.Errorf("error adding to manifest list %s: %w", name, err) + return id, fmt.Errorf("adding to manifest list %s: %w", name, err) } return id, nil } @@ -86,7 +86,7 @@ func (ir *ImageEngine) ManifestAnnotate(ctx context.Context, name, images string func (ir *ImageEngine) ManifestRemoveDigest(ctx context.Context, name string, image string) (string, error) { updatedListID, err := manifests.Remove(ir.ClientCtx, name, image, nil) if err != nil { - return updatedListID, fmt.Errorf("error removing from manifest %s: %w", name, err) + return updatedListID, fmt.Errorf("removing from manifest %s: %w", name, err) } return fmt.Sprintf("%s :%s\n", updatedListID, image), nil } @@ -110,12 +110,12 @@ func (ir *ImageEngine) ManifestPush(ctx context.Context, name, destination strin } digest, err := manifests.Push(ir.ClientCtx, name, destination, options) if err != nil { - return "", fmt.Errorf("error adding to manifest list %s: %w", name, err) + return "", fmt.Errorf("adding to manifest list %s: %w", name, err) } if opts.Rm { if _, rmErrors := ir.Remove(ctx, []string{name}, entities.ImageRemoveOptions{LookupManifest: true}); len(rmErrors) > 0 { - return "", fmt.Errorf("error removing manifest after push: %w", rmErrors[0]) + return "", fmt.Errorf("removing manifest after push: %w", rmErrors[0]) } } diff --git a/pkg/env/env.go b/pkg/env/env.go index fb7949ad8..202f55267 100644 --- a/pkg/env/env.go +++ b/pkg/env/env.go @@ -70,7 +70,7 @@ func ParseFile(path string) (_ map[string]string, err error) { env := make(map[string]string) defer func() { if err != nil { - err = fmt.Errorf("error parsing env file %q: %w", path, err) + err = fmt.Errorf("parsing env file %q: %w", path, err) } }() diff --git a/pkg/machine/ignition.go b/pkg/machine/ignition.go index f4602cc95..366d10499 100644 --- a/pkg/machine/ignition.go +++ b/pkg/machine/ignition.go @@ -561,7 +561,7 @@ func getCerts(certsDir string, isDir bool) []File { func prepareCertFile(path string, name string) (File, error) { b, err := ioutil.ReadFile(path) if err != nil { - logrus.Warnf("Unable to read cert file %s", err.Error()) + logrus.Warnf("Unable to read cert file %v", err) return File{}, err } diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go index b59f07876..738cd74be 100644 --- a/pkg/machine/qemu/machine.go +++ b/pkg/machine/qemu/machine.go @@ -1187,7 +1187,7 @@ func (p *Provider) IsValidVMName(name string) (bool, error) { func (p *Provider) CheckExclusiveActiveVM() (bool, string, error) { vms, err := getVMInfos() if err != nil { - return false, "", fmt.Errorf("error checking VM active: %w", err) + return false, "", fmt.Errorf("checking VM active: %w", err) } for _, vm := range vms { if vm.Running || vm.Starting { diff --git a/pkg/machine/wsl/machine.go b/pkg/machine/wsl/machine.go index 7e453823f..44b82b823 100644 --- a/pkg/machine/wsl/machine.go +++ b/pkg/machine/wsl/machine.go @@ -939,7 +939,7 @@ func (v *MachineVM) Set(_ string, opts machine.SetOptions) ([]error, error) { if opts.Rootful != nil && v.Rootful != *opts.Rootful { err := v.setRootful(*opts.Rootful) if err != nil { - setErrors = append(setErrors, fmt.Errorf("error setting rootful option: %w", err)) + setErrors = append(setErrors, fmt.Errorf("setting rootful option: %w", err)) } else { v.Rootful = *opts.Rootful } diff --git a/pkg/machine/wsl/util_windows.go b/pkg/machine/wsl/util_windows.go index 6613bde1f..67d1bfc5c 100644 --- a/pkg/machine/wsl/util_windows.go +++ b/pkg/machine/wsl/util_windows.go @@ -263,19 +263,19 @@ func obtainShutdownPrivilege() error { var hToken uintptr if ret, _, err := OpenProcessToken.Call(uintptr(proc), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, uintptr(unsafe.Pointer(&hToken))); ret != 1 { - return fmt.Errorf("error opening process token: %w", err) + return fmt.Errorf("opening process token: %w", err) } var privs TokenPrivileges if ret, _, err := LookupPrivilegeValue.Call(uintptr(0), uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(SeShutdownName))), uintptr(unsafe.Pointer(&(privs.privileges[0].luid)))); ret != 1 { - return fmt.Errorf("error looking up shutdown privilege: %w", err) + return fmt.Errorf("looking up shutdown privilege: %w", err) } privs.privilegeCount = 1 privs.privileges[0].attributes = SE_PRIVILEGE_ENABLED if ret, _, err := AdjustTokenPrivileges.Call(hToken, 0, uintptr(unsafe.Pointer(&privs)), 0, uintptr(0), 0); ret != 1 { - return fmt.Errorf("error enabling shutdown privilege on token: %w", err) + return fmt.Errorf("enabling shutdown privilege on token: %w", err) } return nil diff --git a/pkg/parallel/parallel.go b/pkg/parallel/parallel.go index 7209f8aca..990c365cc 100644 --- a/pkg/parallel/parallel.go +++ b/pkg/parallel/parallel.go @@ -60,7 +60,7 @@ func Enqueue(ctx context.Context, fn func() error) <-chan error { defer close(retChan) if err := jobControl.Acquire(ctx, 1); err != nil { - retChan <- fmt.Errorf("error acquiring job control semaphore: %w", err) + retChan <- fmt.Errorf("acquiring job control semaphore: %w", err) return } diff --git a/pkg/ps/ps.go b/pkg/ps/ps.go index 7fc01de31..37da0b110 100644 --- a/pkg/ps/ps.go +++ b/pkg/ps/ps.go @@ -283,7 +283,7 @@ func ListStorageContainer(rt *libpod.Runtime, ctr storage.Container) (entities.L buildahCtr, err := rt.IsBuildahContainer(ctr.ID) if err != nil { - return ps, fmt.Errorf("error determining buildah container for container %s: %w", ctr.ID, err) + return ps, fmt.Errorf("determining buildah container for container %s: %w", ctr.ID, err) } if buildahCtr { @@ -312,7 +312,7 @@ func ListStorageContainer(rt *libpod.Runtime, ctr storage.Container) (entities.L func getNamespaceInfo(path string) (string, error) { val, err := os.Readlink(path) if err != nil { - return "", fmt.Errorf("error getting info from %q: %w", path, err) + return "", fmt.Errorf("getting info from %q: %w", path, err) } return getStrFromSquareBrackets(val), nil } diff --git a/pkg/rootless/rootless_linux.go b/pkg/rootless/rootless_linux.go index 8c4316dbb..f3453320f 100644 --- a/pkg/rootless/rootless_linux.go +++ b/pkg/rootless/rootless_linux.go @@ -401,12 +401,13 @@ func becomeRootInUserNS(pausePid, fileToRead string, fileOutput *os.File) (_ boo // Try to join it. data, err := ioutil.ReadFile(pausePid) if err == nil { - pid, err := strconv.ParseUint(string(data), 10, 0) + var pid uint64 + pid, err = strconv.ParseUint(string(data), 10, 0) if err == nil { return joinUserAndMountNS(uint(pid), "") } } - return false, -1, errors.New("setting up the process") + return false, -1, fmt.Errorf("setting up the process: %w", err) } if b[0] != '0' { diff --git a/pkg/specgen/generate/container.go b/pkg/specgen/generate/container.go index c4fbda9e5..c18b5654a 100644 --- a/pkg/specgen/generate/container.go +++ b/pkg/specgen/generate/container.go @@ -115,7 +115,7 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat // Get Default Environment from containers.conf defaultEnvs, err := envLib.ParseSlice(rtc.GetDefaultEnvEx(s.EnvHost, s.HTTPProxy)) if err != nil { - return nil, fmt.Errorf("error parsing fields in containers.conf: %w", err) + return nil, fmt.Errorf("parsing fields in containers.conf: %w", err) } var envs map[string]string diff --git a/pkg/specgen/generate/container_create.go b/pkg/specgen/generate/container_create.go index 8900d2e5d..6ef5ca79c 100644 --- a/pkg/specgen/generate/container_create.go +++ b/pkg/specgen/generate/container_create.go @@ -36,7 +36,7 @@ func MakeContainer(ctx context.Context, rt *libpod.Runtime, s *specgen.SpecGener if s.Pod != "" { pod, err = rt.LookupPod(s.Pod) if err != nil { - return nil, nil, nil, fmt.Errorf("error retrieving pod %s: %w", s.Pod, err) + return nil, nil, nil, fmt.Errorf("retrieving pod %s: %w", s.Pod, err) } if pod.HasInfraContainer() { infra, err = pod.InfraContainer() @@ -344,7 +344,7 @@ func createContainerOptions(rt *libpod.Runtime, s *specgen.SpecGenerator, pod *l if s.StopSignal == nil { stopSignal, err := util.ParseSignal("RTMIN+3") if err != nil { - return nil, fmt.Errorf("error parsing systemd signal: %w", err) + return nil, fmt.Errorf("parsing systemd signal: %w", err) } s.StopSignal = &stopSignal } diff --git a/pkg/specgen/generate/kube/volume.go b/pkg/specgen/generate/kube/volume.go index 230521ec6..2d8085020 100644 --- a/pkg/specgen/generate/kube/volume.go +++ b/pkg/specgen/generate/kube/volume.go @@ -63,13 +63,13 @@ func VolumeFromHostPath(hostPath *v1.HostPathVolumeSource) (*KubeVolume, error) } // Label a newly created volume if err := libpod.LabelVolumePath(hostPath.Path); err != nil { - return nil, fmt.Errorf("error giving %s a label: %w", hostPath.Path, err) + return nil, fmt.Errorf("giving %s a label: %w", hostPath.Path, err) } case v1.HostPathFileOrCreate: if _, err := os.Stat(hostPath.Path); os.IsNotExist(err) { f, err := os.OpenFile(hostPath.Path, os.O_RDONLY|os.O_CREATE, kubeFilePermission) if err != nil { - return nil, fmt.Errorf("error creating HostPath: %w", err) + return nil, fmt.Errorf("creating HostPath: %w", err) } if err := f.Close(); err != nil { logrus.Warnf("Error in closing newly created HostPath file: %v", err) @@ -77,12 +77,12 @@ func VolumeFromHostPath(hostPath *v1.HostPathVolumeSource) (*KubeVolume, error) } // unconditionally label a newly created volume if err := libpod.LabelVolumePath(hostPath.Path); err != nil { - return nil, fmt.Errorf("error giving %s a label: %w", hostPath.Path, err) + return nil, fmt.Errorf("giving %s a label: %w", hostPath.Path, err) } case v1.HostPathSocket: st, err := os.Stat(hostPath.Path) if err != nil { - return nil, fmt.Errorf("error checking HostPathSocket: %w", err) + return nil, fmt.Errorf("checking HostPathSocket: %w", err) } if st.Mode()&os.ModeSocket != os.ModeSocket { return nil, fmt.Errorf("checking HostPathSocket: path %s is not a socket", hostPath.Path) @@ -90,7 +90,7 @@ func VolumeFromHostPath(hostPath *v1.HostPathVolumeSource) (*KubeVolume, error) case v1.HostPathBlockDev: dev, err := os.Stat(hostPath.Path) if err != nil { - return nil, fmt.Errorf("error checking HostPathBlockDevice: %w", err) + return nil, fmt.Errorf("checking HostPathBlockDevice: %w", err) } if dev.Mode()&os.ModeCharDevice == os.ModeCharDevice { return nil, fmt.Errorf("checking HostPathDevice: path %s is not a block device", hostPath.Path) @@ -102,7 +102,7 @@ func VolumeFromHostPath(hostPath *v1.HostPathVolumeSource) (*KubeVolume, error) case v1.HostPathCharDev: dev, err := os.Stat(hostPath.Path) if err != nil { - return nil, fmt.Errorf("error checking HostPathCharDevice: %w", err) + return nil, fmt.Errorf("checking HostPathCharDevice: %w", err) } if dev.Mode()&os.ModeCharDevice != os.ModeCharDevice { return nil, fmt.Errorf("checking HostPathCharDevice: path %s is not a character device", hostPath.Path) @@ -122,7 +122,7 @@ func VolumeFromHostPath(hostPath *v1.HostPathVolumeSource) (*KubeVolume, error) } if err := parse.ValidateVolumeHostDir(hostPath.Path); err != nil { - return nil, fmt.Errorf("error in parsing HostPath in YAML: %w", err) + return nil, fmt.Errorf("in parsing HostPath in YAML: %w", err) } return &KubeVolume{ diff --git a/pkg/specgen/generate/namespaces.go b/pkg/specgen/generate/namespaces.go index f57b6c23c..9497894f3 100644 --- a/pkg/specgen/generate/namespaces.go +++ b/pkg/specgen/generate/namespaces.go @@ -112,12 +112,12 @@ func namespaceOptions(s *specgen.SpecGenerator, rt *libpod.Runtime, pod *libpod. if err != nil { // This is likely to be of the fatal kind (pod was // removed) so hard fail - return nil, fmt.Errorf("error looking up pod %s infra container: %w", pod.ID(), err) + return nil, fmt.Errorf("looking up pod %s infra container: %w", pod.ID(), err) } if infraID != "" { ctr, err := rt.GetContainer(infraID) if err != nil { - return nil, fmt.Errorf("error retrieving pod %s infra container %s: %w", pod.ID(), infraID, err) + return nil, fmt.Errorf("retrieving pod %s infra container %s: %w", pod.ID(), infraID, err) } infraCtr = ctr } @@ -135,7 +135,7 @@ func namespaceOptions(s *specgen.SpecGenerator, rt *libpod.Runtime, pod *libpod. case specgen.FromContainer: pidCtr, err := rt.LookupContainer(s.PidNS.Value) if err != nil { - return nil, fmt.Errorf("error looking up container to share pid namespace with: %w", err) + return nil, fmt.Errorf("looking up container to share pid namespace with: %w", err) } toReturn = append(toReturn, libpod.WithPIDNSFrom(pidCtr)) } @@ -154,7 +154,7 @@ func namespaceOptions(s *specgen.SpecGenerator, rt *libpod.Runtime, pod *libpod. case specgen.FromContainer: ipcCtr, err := rt.LookupContainer(s.IpcNS.Value) if err != nil { - return nil, fmt.Errorf("error looking up container to share ipc namespace with: %w", err) + return nil, fmt.Errorf("looking up container to share ipc namespace with: %w", err) } if ipcCtr.ConfigNoCopy().NoShmShare { return nil, fmt.Errorf("joining IPC of container %s is not allowed: non-shareable IPC (hint: use IpcMode:shareable for the donor container)", ipcCtr.ID()) @@ -186,7 +186,7 @@ func namespaceOptions(s *specgen.SpecGenerator, rt *libpod.Runtime, pod *libpod. case specgen.FromContainer: utsCtr, err := rt.LookupContainer(s.UtsNS.Value) if err != nil { - return nil, fmt.Errorf("error looking up container to share uts namespace with: %w", err) + return nil, fmt.Errorf("looking up container to share uts namespace with: %w", err) } toReturn = append(toReturn, libpod.WithUTSNSFrom(utsCtr)) } @@ -227,7 +227,7 @@ func namespaceOptions(s *specgen.SpecGenerator, rt *libpod.Runtime, pod *libpod. case specgen.FromContainer: userCtr, err := rt.LookupContainer(s.UserNS.Value) if err != nil { - return nil, fmt.Errorf("error looking up container to share user namespace with: %w", err) + return nil, fmt.Errorf("looking up container to share user namespace with: %w", err) } toReturn = append(toReturn, libpod.WithUserNSFrom(userCtr)) } @@ -259,7 +259,7 @@ func namespaceOptions(s *specgen.SpecGenerator, rt *libpod.Runtime, pod *libpod. case specgen.FromContainer: cgroupCtr, err := rt.LookupContainer(s.CgroupNS.Value) if err != nil { - return nil, fmt.Errorf("error looking up container to share cgroup namespace with: %w", err) + return nil, fmt.Errorf("looking up container to share cgroup namespace with: %w", err) } toReturn = append(toReturn, libpod.WithCgroupNSFrom(cgroupCtr)) } @@ -287,7 +287,7 @@ func namespaceOptions(s *specgen.SpecGenerator, rt *libpod.Runtime, pod *libpod. case specgen.FromContainer: netCtr, err := rt.LookupContainer(s.NetNS.Value) if err != nil { - return nil, fmt.Errorf("error looking up container to share net namespace with: %w", err) + return nil, fmt.Errorf("looking up container to share net namespace with: %w", err) } toReturn = append(toReturn, libpod.WithNetNSFrom(netCtr)) case specgen.Slirp: diff --git a/pkg/specgen/generate/namespaces_freebsd.go b/pkg/specgen/generate/namespaces_freebsd.go index d821d9daa..f4246de34 100644 --- a/pkg/specgen/generate/namespaces_freebsd.go +++ b/pkg/specgen/generate/namespaces_freebsd.go @@ -21,7 +21,7 @@ func specConfigureNamespaces(s *specgen.SpecGenerator, g *generate.Generator, rt case s.UtsNS.NSMode == specgen.FromContainer: utsCtr, err := rt.LookupContainer(s.UtsNS.Value) if err != nil { - return fmt.Errorf("error looking up container to share uts namespace with: %w", err) + return fmt.Errorf("looking up container to share uts namespace with: %w", err) } hostname = utsCtr.Hostname() case (s.NetNS.NSMode == specgen.Host && hostname == "") || s.UtsNS.NSMode == specgen.Host: diff --git a/pkg/specgen/generate/namespaces_linux.go b/pkg/specgen/generate/namespaces_linux.go index 5c056e52c..9fda000f9 100644 --- a/pkg/specgen/generate/namespaces_linux.go +++ b/pkg/specgen/generate/namespaces_linux.go @@ -78,7 +78,7 @@ func specConfigureNamespaces(s *specgen.SpecGenerator, g *generate.Generator, rt case s.UtsNS.NSMode == specgen.FromContainer: utsCtr, err := rt.LookupContainer(s.UtsNS.Value) if err != nil { - return fmt.Errorf("error looking up container to share uts namespace with: %w", err) + return fmt.Errorf("looking up container to share uts namespace with: %w", err) } hostname = utsCtr.Hostname() case (s.NetNS.NSMode == specgen.Host && hostname == "") || s.UtsNS.NSMode == specgen.Host: diff --git a/pkg/specgen/generate/ports.go b/pkg/specgen/generate/ports.go index 572f256c1..8ad249409 100644 --- a/pkg/specgen/generate/ports.go +++ b/pkg/specgen/generate/ports.go @@ -354,7 +354,7 @@ func createPortMappings(s *specgen.SpecGenerator, imageData *libimage.ImageData) } protocols, err := checkProtocol(proto, false) if err != nil { - return nil, nil, fmt.Errorf("error validating protocols for exposed port %d: %w", port, err) + return nil, nil, fmt.Errorf("validating protocols for exposed port %d: %w", port, err) } toExpose[port] = appendProtocolsNoDuplicates(toExpose[port], protocols) } diff --git a/pkg/specgen/generate/storage.go b/pkg/specgen/generate/storage.go index 867bb4b79..c3cd61b36 100644 --- a/pkg/specgen/generate/storage.go +++ b/pkg/specgen/generate/storage.go @@ -175,7 +175,7 @@ func finalizeMounts(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Ru if mount.Type == define.TypeBind { absSrc, err := filepath.Abs(mount.Source) if err != nil { - return nil, nil, nil, fmt.Errorf("error getting absolute path of %s: %w", mount.Source, err) + return nil, nil, nil, fmt.Errorf("getting absolute path of %s: %w", mount.Source, err) } mount.Source = absSrc } @@ -208,7 +208,7 @@ func getImageVolumes(ctx context.Context, img *libimage.Image, s *specgen.SpecGe inspect, err := img.Inspect(ctx, nil) if err != nil { - return nil, nil, fmt.Errorf("error inspecting image to get image volumes: %w", err) + return nil, nil, fmt.Errorf("inspecting image to get image volumes: %w", err) } for volume := range inspect.Config.Volumes { logrus.Debugf("Image has volume at %q", volume) @@ -269,7 +269,7 @@ func getVolumesFrom(volumesFrom []string, runtime *libpod.Runtime) (map[string]s ctr, err := runtime.LookupContainer(splitVol[0]) if err != nil { - return nil, nil, fmt.Errorf("error looking up container %q for volumes-from: %w", splitVol[0], err) + return nil, nil, fmt.Errorf("looking up container %q for volumes-from: %w", splitVol[0], err) } logrus.Debugf("Adding volumes from container %s", ctr.ID()) diff --git a/pkg/specgenutil/specgen.go b/pkg/specgenutil/specgen.go index 3189926b2..2695d8873 100644 --- a/pkg/specgenutil/specgen.go +++ b/pkg/specgenutil/specgen.go @@ -762,7 +762,7 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions } retries, err := strconv.Atoi(splitRestart[1]) if err != nil { - return fmt.Errorf("error parsing restart policy retry count: %w", err) + return fmt.Errorf("parsing restart policy retry count: %w", err) } if retries < 0 { return errors.New("must specify restart policy retry count as a number greater than 0") diff --git a/pkg/specgenutil/util.go b/pkg/specgenutil/util.go index 66d148672..b14e2a032 100644 --- a/pkg/specgenutil/util.go +++ b/pkg/specgenutil/util.go @@ -20,7 +20,7 @@ import ( func ReadPodIDFile(path string) (string, error) { content, err := ioutil.ReadFile(path) if err != nil { - return "", fmt.Errorf("error reading pod ID file: %w", err) + return "", fmt.Errorf("reading pod ID file: %w", err) } return strings.Split(string(content), "\n")[0], nil } @@ -165,7 +165,7 @@ func parseSplitPort(hostIP, hostPort *string, ctrPort string, protocol *string) } ctrStart, ctrLen, err := parseAndValidateRange(ctrPort) if err != nil { - return newPort, fmt.Errorf("error parsing container port: %w", err) + return newPort, fmt.Errorf("parsing container port: %w", err) } newPort.ContainerPort = ctrStart newPort.Range = ctrLen @@ -197,7 +197,7 @@ func parseSplitPort(hostIP, hostPort *string, ctrPort string, protocol *string) } else { hostStart, hostLen, err := parseAndValidateRange(*hostPort) if err != nil { - return newPort, fmt.Errorf("error parsing host port: %w", err) + return newPort, fmt.Errorf("parsing host port: %w", err) } if hostLen != ctrLen { return newPort, fmt.Errorf("host and container port ranges have different lengths: %d vs %d", hostLen, ctrLen) diff --git a/pkg/specgenutil/volumes.go b/pkg/specgenutil/volumes.go index e9fffdca9..e6c5d8b97 100644 --- a/pkg/specgenutil/volumes.go +++ b/pkg/specgenutil/volumes.go @@ -125,7 +125,7 @@ func parseVolumes(volumeFlag, mountFlag, tmpfsFlag []string, addReadOnlyTmpfs bo if mount.Type == define.TypeBind { absSrc, err := specgen.ConvertWinMountPath(mount.Source) if err != nil { - return nil, nil, nil, nil, fmt.Errorf("error getting absolute path of %s: %w", mount.Source, err) + return nil, nil, nil, nil, fmt.Errorf("getting absolute path of %s: %w", mount.Source, err) } mount.Source = absSrc } diff --git a/pkg/systemd/generate/containers.go b/pkg/systemd/generate/containers.go index 6f546b0ab..0274dd7b7 100644 --- a/pkg/systemd/generate/containers.go +++ b/pkg/systemd/generate/containers.go @@ -491,7 +491,7 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst // template execution. templ, err := template.New("container_template").Delims("{{{{", "}}}}").Parse(containerTemplate) if err != nil { - return "", fmt.Errorf("error parsing systemd service template: %w", err) + return "", fmt.Errorf("parsing systemd service template: %w", err) } var buf bytes.Buffer @@ -502,7 +502,7 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst // Now parse the generated template (i.e., buf) and execute it. templ, err = template.New("container_template").Delims("{{{{", "}}}}").Parse(buf.String()) if err != nil { - return "", fmt.Errorf("error parsing systemd service template: %w", err) + return "", fmt.Errorf("parsing systemd service template: %w", err) } buf = bytes.Buffer{} diff --git a/pkg/systemd/generate/pods.go b/pkg/systemd/generate/pods.go index 8640418a7..22f568220 100644 --- a/pkg/systemd/generate/pods.go +++ b/pkg/systemd/generate/pods.go @@ -402,7 +402,7 @@ func executePodTemplate(info *podInfo, options entities.GenerateSystemdOptions) // template execution. templ, err := template.New("pod_template").Delims("{{{{", "}}}}").Parse(podTemplate) if err != nil { - return "", fmt.Errorf("error parsing systemd service template: %w", err) + return "", fmt.Errorf("parsing systemd service template: %w", err) } var buf bytes.Buffer @@ -413,7 +413,7 @@ func executePodTemplate(info *podInfo, options entities.GenerateSystemdOptions) // Now parse the generated template (i.e., buf) and execute it. templ, err = template.New("pod_template").Delims("{{{{", "}}}}").Parse(buf.String()) if err != nil { - return "", fmt.Errorf("error parsing systemd service template: %w", err) + return "", fmt.Errorf("parsing systemd service template: %w", err) } buf = bytes.Buffer{} diff --git a/pkg/trust/policy.go b/pkg/trust/policy.go index 326fe17af..d746e78cf 100644 --- a/pkg/trust/policy.go +++ b/pkg/trust/policy.go @@ -242,7 +242,7 @@ func AddPolicyEntries(policyPath string, input AddPolicyEntriesInput) error { data, err := json.MarshalIndent(policyContentStruct, "", " ") if err != nil { - return fmt.Errorf("error setting trust policy: %w", err) + return fmt.Errorf("setting trust policy: %w", err) } return ioutil.WriteFile(policyPath, data, 0644) } diff --git a/pkg/trust/registries.go b/pkg/trust/registries.go index 0adc38232..86d580059 100644 --- a/pkg/trust/registries.go +++ b/pkg/trust/registries.go @@ -79,7 +79,7 @@ func loadAndMergeConfig(dirPath string) (*registryConfiguration, error) { var config registryConfiguration err = yaml.Unmarshal(configBytes, &config) if err != nil { - return nil, fmt.Errorf("error parsing %s: %w", configPath, err) + return nil, fmt.Errorf("parsing %s: %w", configPath, err) } if config.DefaultDocker != nil { if mergedConfig.DefaultDocker != nil { diff --git a/test/system/030-run.bats b/test/system/030-run.bats index a3bfe5780..b1ce91d14 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -423,7 +423,7 @@ json-file | f # Invalid log-driver argument run_podman 125 run --log-driver=InvalidDriver $IMAGE true - is "$output" "Error: error running container create option: invalid log driver: invalid argument" \ + is "$output" "Error: running container create option: invalid log driver: invalid argument" \ "--log-driver InvalidDriver" } diff --git a/test/system/200-pod.bats b/test/system/200-pod.bats index e3a9ec4c3..9bbd56fef 100644 --- a/test/system/200-pod.bats +++ b/test/system/200-pod.bats @@ -435,7 +435,7 @@ EOF run_podman pod rm $podID run_podman 125 pod create --exit-policy invalid - is "$output" "Error: .*error running pod create option: invalid pod exit policy: \"invalid\"" "invalid exit policy" + is "$output" "Error: .*running pod create option: invalid pod exit policy: \"invalid\"" "invalid exit policy" # Test exit-policy behaviour run_podman pod create --exit-policy continue diff --git a/test/system/330-corrupt-images.bats b/test/system/330-corrupt-images.bats index 7f2b81835..2f0fd753c 100644 --- a/test/system/330-corrupt-images.bats +++ b/test/system/330-corrupt-images.bats @@ -74,7 +74,7 @@ function _corrupt_image_test() { # Corruptify, and confirm that 'podman images' throws an error rm -v ${PODMAN_CORRUPT_TEST_WORKDIR}/root/*-images/$id/${rm_path} run_podman 125 images - is "$output" "Error: error retrieving label for image \"$id\": you may need to remove the image to resolve the error.*" + is "$output" "Error: retrieving label for image \"$id\": you may need to remove the image to resolve the error.*" # Run the requested command. Confirm it succeeds, with suitable warnings run_podman $* diff --git a/test/system/710-kube.bats b/test/system/710-kube.bats index c446ff65f..97a640e3f 100644 --- a/test/system/710-kube.bats +++ b/test/system/710-kube.bats @@ -91,7 +91,7 @@ status | = | null # Needs at least one container. Error is slightly different between # regular and remote podman: # regular: Error: pod ... only has... - # remote: Error: error generating YAML: pod ... only has... + # remote: Error: generating YAML: pod ... only has... run_podman 125 kube generate $pname assert "$output" =~ "Error: .* only has an infra container" diff --git a/test/testvol/main.go b/test/testvol/main.go index dd4ba642d..ab26e2df0 100644 --- a/test/testvol/main.go +++ b/test/testvol/main.go @@ -80,7 +80,7 @@ func startServer(socketPath string) error { if config.path == "" { path, err := ioutil.TempDir("", "test_volume_plugin") if err != nil { - return fmt.Errorf("error getting directory for plugin: %w", err) + return fmt.Errorf("getting directory for plugin: %w", err) } config.path = path } else { @@ -98,7 +98,7 @@ func startServer(socketPath string) error { server := volume.NewHandler(handle) if err := server.ServeUnix(socketPath, 0); err != nil { - return fmt.Errorf("error starting server: %w", err) + return fmt.Errorf("starting server: %w", err) } return nil } @@ -161,7 +161,7 @@ func (d *DirDriver) Create(opts *volume.CreateRequest) error { volPath := filepath.Join(d.volumesPath, opts.Name) if err := os.Mkdir(volPath, 0755); err != nil { - return fmt.Errorf("error making volume directory: %w", err) + return fmt.Errorf("making volume directory: %w", err) } newVol.path = volPath @@ -240,7 +240,7 @@ func (d *DirDriver) Remove(req *volume.RemoveRequest) error { delete(d.volumes, req.Name) if err := os.RemoveAll(vol.path); err != nil { - return fmt.Errorf("error removing mountpoint of volume %s: %w", req.Name, err) + return fmt.Errorf("removing mountpoint of volume %s: %w", req.Name, err) } logrus.Debugf("Removed volume %s", req.Name) diff --git a/troubleshooting.md b/troubleshooting.md index 0e767926b..d1b19b293 100644 --- a/troubleshooting.md +++ b/troubleshooting.md @@ -409,7 +409,7 @@ Copying blob f7277927d38a done Copying config 5e13f8dd4c done Writing manifest to image destination Storing signatures -Error: error creating build container: Error committing the finished image: error adding layer with blob "sha256:8d3eac894db4dc4154377ad28643dfe6625ff0e54bcfa63e0d04921f1a8ef7f8": Error processing tar file(exit status 1): operation not permitted +Error: creating build container: Error committing the finished image: error adding layer with blob "sha256:8d3eac894db4dc4154377ad28643dfe6625ff0e54bcfa63e0d04921f1a8ef7f8": Error processing tar file(exit status 1): operation not permitted $ podman build . ERRO[0014] Error while applying layer: ApplyLayer exit status 1 stdout: stderr: open /root/.bash_logout: permission denied error creating build container: Error committing the finished image: error adding layer with blob "sha256:a02a4930cb5d36f3290eb84f4bfa30668ef2e9fe3a1fb73ec015fc58b9958b17": ApplyLayer exit status 1 stdout: stderr: open /root/.bash_logout: permission denied @@ -923,7 +923,7 @@ if __name__ == "__main__": signal_listener() ``` -### 31) Podman run fails with `ERRO[0000] XDG_RUNTIME_DIR directory "/run/user/0" is not owned by the current user` or `Error: error creating tmpdir: mkdir /run/user/1000: permission denied`. +### 31) Podman run fails with `ERRO[0000] XDG_RUNTIME_DIR directory "/run/user/0" is not owned by the current user` or `Error: creating tmpdir: mkdir /run/user/1000: permission denied`. A failure is encountered when performing `podman run` with a warning `XDG_RUNTIME_DIR is pointing to a path which is not writable. Most likely podman will fail.` @@ -938,7 +938,7 @@ ERRO[0000] XDG_RUNTIME_DIR directory "/run/user/0" is not owned by the current u ``` ```console # su - user1 -c 'podman images' -Error: error creating tmpdir: mkdir /run/user/1000: permission denied +Error: creating tmpdir: mkdir /run/user/1000: permission denied ``` #### Solution diff --git a/utils/utils.go b/utils/utils.go index aa1c6a958..4d41ce5f8 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -128,7 +128,7 @@ func moveProcessPIDFileToScope(pidPath, slice, scope string) error { if os.IsNotExist(err) { return nil } - return fmt.Errorf("cannot read pid file %s: %w", pidPath, err) + return fmt.Errorf("cannot read pid file: %w", err) } pid, err := strconv.ParseUint(string(data), 10, 0) if err != nil { |