From 3788da93445dffda35a00366c90a9d8da6ef0702 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Tue, 21 May 2019 10:01:29 +0200 Subject: 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 --- libpod/container_internal.go | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'libpod/container_internal.go') diff --git a/libpod/container_internal.go b/libpod/container_internal.go index fc33a1bbc..5f8dd1c72 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -25,7 +25,6 @@ import ( opentracing "github.com/opentracing/opentracing-go" "github.com/pkg/errors" "github.com/sirupsen/logrus" - kwait "k8s.io/apimachinery/pkg/util/wait" ) const ( @@ -146,20 +145,10 @@ func (c *Container) exitFilePath() string { func (c *Container) waitForExitFileAndSync() error { exitFile := c.exitFilePath() - err := kwait.ExponentialBackoff( - kwait.Backoff{ - Duration: 500 * time.Millisecond, - Factor: 1.2, - Steps: 6, - }, - func() (bool, error) { - _, 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 { // Exit file did not appear // Reset our state -- cgit v1.2.3-54-g00ecf