diff options
author | Ćukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com> | 2017-03-15 10:19:34 +0100 |
---|---|---|
committer | usd-importer <ubuntu-server@lists.ubuntu.com> | 2017-03-17 13:08:24 +0000 |
commit | c6339c307f36f77a4198d6faf1275acdf371200b (patch) | |
tree | c774046e1e30617514c09e5a2b896568706a25a8 /azurelinuxagent/common/utils/restutil.py | |
parent | dd73af563850762aad64e7ed2a9897377830af10 (diff) | |
parent | 2bc77af05fe602a2ba92569428c6006d1aebd19f (diff) | |
download | vyos-walinuxagent-c6339c307f36f77a4198d6faf1275acdf371200b.tar.gz vyos-walinuxagent-c6339c307f36f77a4198d6faf1275acdf371200b.zip |
Import patches-applied version 2.2.6-0ubuntu1 to applied/ubuntu/zesty-proposed
Imported using git-ubuntu import.
Changelog parent: dd73af563850762aad64e7ed2a9897377830af10
Unapplied parent: 2bc77af05fe602a2ba92569428c6006d1aebd19f
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).
Diffstat (limited to 'azurelinuxagent/common/utils/restutil.py')
-rw-r--r-- | azurelinuxagent/common/utils/restutil.py | 34 |
1 files changed, 20 insertions, 14 deletions
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}]", |