Repository: Azure/WALinuxAgent
Pull request #866 (2017-08-31 22:09:43)

[#865] -- The agent should retry ETIMEDOUT (110) IOErrors
[#865] -- The agent should retry ETIMEDOUT (110) IOErrors

Signed-off-by: Brendan Dixon <brendandixon@me.com>


Patch:
diff --git a/azurelinuxagent/common/utils/restutil.py b/azurelinuxagent/common/utils/restutil.py
index 6ad2479a..f5b40f3a 100644
--- a/azurelinuxagent/common/utils/restutil.py
+++ b/azurelinuxagent/common/utils/restutil.py
@@ -73,24 +73,6 @@ RETRY_EXCEPTIONS = [
     httpclient.BadStatusLine
 ]
 
-# Note:
-# - The Python library does not define constants for all possible
-#   errno values; these come from the standard C/C++ header
-RETRY_IOERRORS = [
-    64,     # ENONET -- Machine is not on the network 
-    67,     # ENOLINK -- Link has been severed 
-    70,     # ECOMM -- Communication error on send 
-    78,     # EREMCHG -- Remote address changed 
-    85,     # ERESTART -- Interrupted system call should be restarted 
-    100,    # ENETDOWN -- Network is down 
-    101,    # ENETUNREACH -- Network is unreachable 
-    102,    # ENETRESET -- Network dropped connection because of reset 
-    103,    # ECONNABORTED -- Software caused connection abort 
-    104,    # ECONNRESET -- Connection reset by peer 
-    111,    # ECONNREFUSED -- Connection refused 
-    112     # EHOSTDOWN -- Host is down 
-]
-
 HTTP_PROXY_ENV = "http_proxy"
 HTTPS_PROXY_ENV = "https_proxy"
 
@@ -98,9 +80,6 @@ HTTPS_PROXY_ENV = "https_proxy"
 def _is_retry_status(status, retry_codes=RETRY_CODES):
     return status in retry_codes
 
-def _is_retry_errno(errno):
-    return errno in RETRY_IOERRORS
-
 def _is_retry_exception(e):
     return len([x for x in RETRY_EXCEPTIONS if isinstance(e, x)]) > 0
 
@@ -277,10 +256,7 @@ def http_request(method,
             break
 
         except IOError as e:
-            msg = '[HTTP Failed] HTTP {0} IOError {1}'.format(method, e)
-            if _is_retry_errno(e.errno):
-                continue
-            break
+            continue
 
     raise HttpError(msg)
 
diff --git a/azurelinuxagent/common/version.py b/azurelinuxagent/common/version.py
index 8de3da89..ab836a5c 100644
--- a/azurelinuxagent/common/version.py
+++ b/azurelinuxagent/common/version.py
@@ -113,7 +113,7 @@ def get_distro():
 
 AGENT_NAME = "WALinuxAgent"
 AGENT_LONG_NAME = "Azure Linux Agent"
-AGENT_VERSION = '2.2.15'
+AGENT_VERSION = '2.2.15.1'
 AGENT_LONG_VERSION = "{0}-{1}".format(AGENT_NAME, AGENT_VERSION)
 AGENT_DESCRIPTION = """
 The Azure Linux Agent supports the provisioning and running of Linux


Test patch:
diff --git a/tests/utils/test_rest_util.py b/tests/utils/test_rest_util.py
index 6dfeea21..52674da8 100644
--- a/tests/utils/test_rest_util.py
+++ b/tests/utils/test_rest_util.py
@@ -312,21 +312,16 @@ class TestHttpOperations(AgentTestCase):
     @patch("azurelinuxagent.common.utils.restutil._http_request")
     def test_http_request_retries_ioerrors(self, _http_request, _sleep):
         ioerror = IOError()
-        
-        for errno in restutil.RETRY_IOERRORS:
-            _http_request.reset_mock()
-            _sleep.reset_mock()
+        ioerror.errno = 42
 
-            ioerror.errno = errno
-
-            _http_request.side_effect = [
-                ioerror,
-                Mock(status=httpclient.OK)
-            ]
+        _http_request.side_effect = [
+            ioerror,
+            Mock(status=httpclient.OK)
+        ]
 
-            restutil.http_get("https://foo.bar")
-            self.assertEqual(2, _http_request.call_count)
-            self.assertEqual(1, _sleep.call_count)
+        restutil.http_get("https://foo.bar")
+        self.assertEqual(2, _http_request.call_count)
+        self.assertEqual(1, _sleep.call_count)
 
     def test_request_failed(self):
         self.assertTrue(restutil.request_failed(None))