summaryrefslogtreecommitdiff
path: root/libpod/oci.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2019-05-21 10:01:29 +0200
committerGiuseppe Scrivano <gscrivan@redhat.com>2019-05-21 10:07:31 +0200
commit3788da93445dffda35a00366c90a9d8da6ef0702 (patch)
tree97d34259794a142b93e046a32184158029211cf7 /libpod/oci.go
parente43a98e512603d8608144efbcd3e9dde5759823f (diff)
downloadpodman-3788da93445dffda35a00366c90a9d8da6ef0702.tar.gz
podman-3788da93445dffda35a00366c90a9d8da6ef0702.tar.bz2
podman-3788da93445dffda35a00366c90a9d8da6ef0702.zip
libpod: prefer WaitForFile to polling
replace two usage of kwait.ExponentialBackoff in favor of WaitForFile that uses inotify when possible. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod/oci.go')
-rw-r--r--libpod/oci.go23
1 files changed, 7 insertions, 16 deletions
diff --git a/libpod/oci.go b/libpod/oci.go
index 3dfde4f24..abc6214b9 100644
--- a/libpod/oci.go
+++ b/libpod/oci.go
@@ -17,7 +17,6 @@ import (
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
- kwait "k8s.io/apimachinery/pkg/util/wait"
// TODO import these functions into libpod and remove the import
// Trying to keep libpod from depending on CRI-O code
@@ -261,21 +260,13 @@ func (r *OCIRuntime) updateContainerStatus(ctr *Container, useRuntime bool) erro
// If we were, it should already be in the database
if ctr.state.State == ContainerStateStopped && oldState != ContainerStateStopped {
var fi os.FileInfo
- err = kwait.ExponentialBackoff(
- kwait.Backoff{
- Duration: 500 * time.Millisecond,
- Factor: 1.2,
- Steps: 6,
- },
- func() (bool, error) {
- var err error
- fi, err = os.Stat(exitFile)
- if err != nil {
- // wait longer
- return false, nil
- }
- return true, nil
- })
+ chWait := make(chan error)
+ defer close(chWait)
+
+ _, err := WaitForFile(exitFile, chWait, time.Second*5)
+ if err == nil {
+ fi, err = os.Stat(exitFile)
+ }
if err != nil {
ctr.state.ExitCode = -1
ctr.state.FinishedTime = time.Now()