summaryrefslogtreecommitdiff
path: root/utils/utils.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-10-28 12:16:24 +0000
committerGitHub <noreply@github.com>2021-10-28 12:16:24 +0000
commit3bc449371c97486620fd368deb906c68cdaf220d (patch)
treef02e5b99fdba93bb81a001ec3ea9fbbfc26ac91c /utils/utils.go
parentf16b13366424468246a2c78414e2c92142393f6e (diff)
parent960831f9c8ff83f427c296adcef0ed114c434fca (diff)
downloadpodman-3bc449371c97486620fd368deb906c68cdaf220d.tar.gz
podman-3bc449371c97486620fd368deb906c68cdaf220d.tar.bz2
podman-3bc449371c97486620fd368deb906c68cdaf220d.zip
Merge pull request #12126 from giuseppe/fix-race-warning-message
runtime: change PID existence check
Diffstat (limited to 'utils/utils.go')
-rw-r--r--utils/utils.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/utils/utils.go b/utils/utils.go
index 55af41bb3..109ae088b 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -14,6 +14,7 @@ import (
"github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/cgroups"
"github.com/containers/storage/pkg/archive"
+ "github.com/godbus/dbus/v5"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -177,13 +178,26 @@ func RunsOnSystemd() bool {
func moveProcessToScope(pidPath, slice, scope string) error {
data, err := ioutil.ReadFile(pidPath)
if err != nil {
+ // do not raise an error if the file doesn't exist
+ if os.IsNotExist(err) {
+ return nil
+ }
return errors.Wrapf(err, "cannot read pid file %s", pidPath)
}
pid, err := strconv.ParseUint(string(data), 10, 0)
if err != nil {
return errors.Wrapf(err, "cannot parse pid file %s", pidPath)
}
- return RunUnderSystemdScope(int(pid), slice, scope)
+ err = RunUnderSystemdScope(int(pid), slice, scope)
+
+ // If the PID is not valid anymore, do not return an error.
+ if dbusErr, ok := err.(dbus.Error); ok {
+ if dbusErr.Name == "org.freedesktop.DBus.Error.UnixProcessIdUnknown" {
+ return nil
+ }
+ }
+
+ return err
}
// MovePauseProcessToScope moves the pause process used for rootless mode to keep the namespaces alive to