mirror of
https://github.com/containers/podman.git
synced 2025-11-02 23:39:52 +08:00
Extract waitForGvProxy into shared utility function
Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
@ -94,3 +95,18 @@ func DialSocketWithBackoffsAndProcCheck(
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// WaitForSocketWithBackoffs attempts to discover listening socket in maxBackoffs attempts
|
||||
func WaitForSocketWithBackoffs(maxBackoffs int, backoff time.Duration, socketPath string, name string) error {
|
||||
backoffWait := backoff
|
||||
logrus.Debugf("checking that %q socket is ready", name)
|
||||
for i := 0; i < maxBackoffs; i++ {
|
||||
_, err := os.Stat(socketPath)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
time.Sleep(backoffWait)
|
||||
backoffWait *= 2
|
||||
}
|
||||
return fmt.Errorf("unable to connect to %q socket at %q", name, socketPath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user