From 83be006e288c58a46f5b76c29b6886c1f417d88c Mon Sep 17 00:00:00 2001 From: Ɓukasz 'sil2100' Zemczak Date: Wed, 15 Mar 2017 10:19:34 +0100 Subject: Import patches-unapplied version 2.2.6-0ubuntu1 to ubuntu/zesty-proposed Imported using git-ubuntu import. Changelog parent: d064ab0bffd429382ea4fafeb144784d403848bd New changelog entries: * New upstream release (LP: #1661750). * debian/control: - Change the maintainer to Ubuntu Developers (LP: #1657528). - Add the dependency of isc-dhcp-client as our maintainer scripts assume it's installed. - Add trailing commas to dependencies, add whitespaces. * Rename ephemeral-disk-warning.sh to ephemeral-disk-warning (lintian error). * debian/docs: - Remove LICENSE.txt as it's redundant. * debian/postinst: - Stop checking for update-initramfs existence using the absolute path, use the 'command' command instead to make lintian happy. * Remove debian/patches/disable-auto-update.patch: - We now ship with auto-updates enabled (LP: #1650522). * debian/maintscript: - Add a maintscript to rename the old logrotate file on upgrade from an ancient version of walinuxagent (LP: #1673152). --- azurelinuxagent/common/utils/restutil.py | 34 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'azurelinuxagent/common/utils/restutil.py') diff --git a/azurelinuxagent/common/utils/restutil.py b/azurelinuxagent/common/utils/restutil.py index 7c9ee17..7197370 100644 --- a/azurelinuxagent/common/utils/restutil.py +++ b/azurelinuxagent/common/utils/restutil.py @@ -29,6 +29,7 @@ REST api util functions """ RETRY_WAITING_INTERVAL = 10 +secure_warning = True def _parse_url(url): @@ -85,7 +86,7 @@ def _http_request(method, host, rel_uri, port=None, data=None, secure=False, timeout=10) url = rel_uri - logger.verbose("HTTPConnection [{0}] [{1}] [{2}] [{3}]", + logger.verbose("HTTP connection [{0}] [{1}] [{2}] [{3}]", method, url, data, @@ -104,6 +105,7 @@ def http_request(method, url, data, headers=None, max_retry=3, On error, sleep 10 and retry max_retry times. """ host, port, secure, rel_uri = _parse_url(url) + global secure_warning # Check proxy proxy_host, proxy_port = (None, None) @@ -112,24 +114,22 @@ def http_request(method, url, data, headers=None, max_retry=3, # If httplib module is not built with ssl support. Fallback to http if secure and not hasattr(httpclient, "HTTPSConnection"): - logger.warn("httplib is not built with ssl support") secure = False + if secure_warning: + logger.warn("httplib is not built with ssl support") + secure_warning = False # If httplib module doesn't support https tunnelling. Fallback to http if secure and proxy_host is not None and proxy_port is not None \ and not hasattr(httpclient.HTTPSConnection, "set_tunnel"): - logger.warn("httplib does not support https tunnelling " - "(new in python 2.7)") secure = False + if secure_warning: + logger.warn("httplib does not support https tunnelling " + "(new in python 2.7)") + secure_warning = False - logger.verbose("HTTP method: [{0}]", method) - logger.verbose("HTTP host: [{0}]", host) - logger.verbose("HTTP uri: [{0}]", rel_uri) - logger.verbose("HTTP port: [{0}]", port) - logger.verbose("HTTP data: [{0}]", data) - logger.verbose("HTTP secure: [{0}]", secure) - logger.verbose("HTTP headers: [{0}]", headers) - logger.verbose("HTTP proxy: [{0}:{1}]", proxy_host, proxy_port) + if proxy_host or proxy_port: + logger.verbose("HTTP proxy: [{0}:{1}]", proxy_host, proxy_port) retry_msg = '' log_msg = "HTTP {0}".format(method) @@ -152,8 +152,14 @@ def http_request(method, url, data, headers=None, max_retry=3, retry_interval = 5 except IOError as e: retry_msg = 'IO error: {0} {1}'.format(log_msg, e) - retry_interval = 0 - max_retry = 0 + # error 101: network unreachable; when the adapter resets we may + # see this transient error for a short time, retry once. + if e.errno == 101: + retry_interval = RETRY_WAITING_INTERVAL + max_retry = 1 + else: + retry_interval = 0 + max_retry = 0 if retry < max_retry: logger.info("Retry [{0}/{1} - {3}]", -- cgit v1.2.3