From 00810a7232b2bec48ae1fd277e94673c6cae1a63 Mon Sep 17 00:00:00 2001 From: "e.zhydzetski" Date: Tue, 3 Mar 2020 21:46:00 +0300 Subject: [PATCH 1/3] chore: ignore .idea --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 1f6716688b..0a584d1c6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ debug.test vendor + +.idea/ From a930d9b60fcaacf2a56f391c3ec79cbab31b3993 Mon Sep 17 00:00:00 2001 From: "e.zhydzetski" Date: Tue, 3 Mar 2020 23:27:26 +0300 Subject: [PATCH 2/3] fix: improve error check in the ForListeningPort waiting strategy, fix dep versions use platform-dependent connection refused error type and improve ctx.Err checks in the ForListeningPort waiting strategy use github.com/Microsoft/hcsshim v0.8.7 instead of v0.8.6, as not compatible with github.com/docker/docker go mod tidy --- wait/errors.go | 9 +++++++++ wait/errors_windows.go | 9 +++++++++ wait/host_port.go | 6 ++++-- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 wait/errors.go create mode 100644 wait/errors_windows.go diff --git a/wait/errors.go b/wait/errors.go new file mode 100644 index 0000000000..59e9ad0313 --- /dev/null +++ b/wait/errors.go @@ -0,0 +1,9 @@ +// +build !windows + +package wait + +import "syscall" + +func isConnRefusedErr(err error) bool { + return err == syscall.ECONNREFUSED +} diff --git a/wait/errors_windows.go b/wait/errors_windows.go new file mode 100644 index 0000000000..3ae346d8ad --- /dev/null +++ b/wait/errors_windows.go @@ -0,0 +1,9 @@ +package wait + +import ( + "golang.org/x/sys/windows" +) + +func isConnRefusedErr(err error) bool { + return err == windows.WSAECONNREFUSED +} diff --git a/wait/host_port.go b/wait/host_port.go index dd67503366..f295cee0e0 100644 --- a/wait/host_port.go +++ b/wait/host_port.go @@ -6,7 +6,6 @@ import ( "net" "os" "strconv" - "syscall" "time" "github.com/pkg/errors" @@ -74,7 +73,7 @@ func (hp *HostPortStrategy) WaitUntilReady(ctx context.Context, target StrategyT if err != nil { if v, ok := err.(*net.OpError); ok { if v2, ok := (v.Err).(*os.SyscallError); ok { - if v2.Err == syscall.ECONNREFUSED && ctx.Err() == nil { + if isConnRefusedErr(v2.Err) { time.Sleep(100 * time.Millisecond) continue } @@ -90,6 +89,9 @@ func (hp *HostPortStrategy) WaitUntilReady(ctx context.Context, target StrategyT //internal check command := buildInternalCheckCommand(hp.Port.Int()) for { + if ctx.Err() != nil { + return ctx.Err() + } exitCode, err := target.Exec(ctx, []string{"/bin/sh", "-c", command}) if err != nil { return errors.Wrapf(err, "host port waiting failed") From adb8f34edb97bfa8e211781edf5a28fc29b56a9a Mon Sep 17 00:00:00 2001 From: "e.zhydzetski" Date: Wed, 4 Mar 2020 11:31:57 +0300 Subject: [PATCH 3/3] Revert "chore: ignore .idea" This reverts commit b9f7d35ac6f5bce1fb56d09478f8b06e15e5f1e7. --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0a584d1c6a..1f6716688b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ debug.test vendor - -.idea/