Skip to content

Commit b8945d3

Browse files
committed
Decrease shim timeout on pipe not found
On Windows because of the way the log pipe is forwarded to the shim there is a condition where the pipe listener may not yet be active when a client tries to connect. To handle this case we allow polling on the file and rety on pipe not found. This limits the pipe not found retry to 5 seconds but leaves the connect timeout alone as if there is a listener we want to connect to it normally. Signed-off-by: Justin Terry (VM) <[email protected]>
1 parent ddbeb3f commit b8945d3

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

runtime/v2/shim/util_windows.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ func SocketAddress(ctx context.Context, id string) (string, error) {
5151
func AnonDialer(address string, timeout time.Duration) (net.Conn, error) {
5252
var c net.Conn
5353
var lastError error
54+
timedOutError := errors.Errorf("timed out waiting for npipe %s", address)
5455
start := time.Now()
5556
for {
5657
remaining := timeout - time.Now().Sub(start)
5758
if remaining <= 0 {
58-
lastError = errors.Errorf("timed out waiting for npipe %s", address)
59+
lastError = timedOutError
5960
break
6061
}
6162
c, lastError = winio.DialPipe(address, &remaining)
@@ -65,6 +66,15 @@ func AnonDialer(address string, timeout time.Duration) (net.Conn, error) {
6566
if !os.IsNotExist(lastError) {
6667
break
6768
}
69+
// There is nobody serving the pipe. We limit the timeout for this case
70+
// to 5 seconds because any shim that would serve this endpoint should
71+
// serve it within 5 seconds. We use the passed in timeout for the
72+
// `DialPipe` timeout if the pipe exists however to give the pipe time
73+
// to `Accept` the connection.
74+
if time.Now().Sub(start) >= 5*time.Second {
75+
lastError = timedOutError
76+
break
77+
}
6878
time.Sleep(10 * time.Millisecond)
6979
}
7080
return c, lastError

0 commit comments

Comments
 (0)