From e9253273094b78e9a342abd0adbd3299b752287a Mon Sep 17 00:00:00 2001 From: Tobias Henkel Date: Tue, 9 Oct 2018 10:17:16 +0200 Subject: [PATCH] Reduce socket connect timeout in nodescan During nodescan we currently set a socket timeout which is equal to the timeout we wait for the entire boot. In case we have unfortunate timing of the network interface setup of the node (especially Windows does this very late in the boot process) we get longer wait times than necessary. This happens because uninitialized network interfaces on the node lead to unanswered syn packets instead of connection refused errors. Linux typically does around 6 syn retries with an exponential backof starting with 3s. This means the delay between syn retries is 3, 6, 12 seconds and thus in absolute time a single socket connect can return after 0, 3, 6, 12, 45, 93 or 189 seconds. This can be solved by setting a fixed lower timeout on the socket to force it to return with timeout after 10s so we can avoid the exponential syn retry backoff and thus don't waste too much time on slower starting nodes. Change-Id: Ibabdff1966d49752e86e15a1c2a24dd2c86d33f6 --- nodepool/nodeutils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodepool/nodeutils.py b/nodepool/nodeutils.py index 2add107fe..d85cdcea4 100755 --- a/nodepool/nodeutils.py +++ b/nodepool/nodeutils.py @@ -82,7 +82,7 @@ def nodescan(ip, port=22, timeout=60, gather_hostkeys=True): t = None try: sock = socket.socket(family, socket.SOCK_STREAM) - sock.settimeout(timeout) + sock.settimeout(10) sock.connect(sockaddr) if gather_hostkeys: t = paramiko.transport.Transport(sock)