summaryrefslogtreecommitdiff
path: root/cloudinit/sources/helpers
diff options
context:
space:
mode:
authorJohnson Shi <Johnson.Shi@microsoft.com>2021-03-25 07:20:10 -0700
committerGitHub <noreply@github.com>2021-03-25 09:20:10 -0500
commit6ae1145f5e980a47ac2b1ff3afa228a5da3f6e70 (patch)
tree486ac9f4d906f9a14dec06f14e7f1f109f279006 /cloudinit/sources/helpers
parentd4acc0920cdc19e5be3e1054a9a5fbc20e954492 (diff)
downloadvyos-cloud-init-6ae1145f5e980a47ac2b1ff3afa228a5da3f6e70.tar.gz
vyos-cloud-init-6ae1145f5e980a47ac2b1ff3afa228a5da3f6e70.zip
Azure helper: Ensure Azure http handler sleeps between retries (#842)
Ensure that the Azure helper's http handler sleeps a fixed duration between retry failure attempts. The http handler will sleep a fixed duration between failed attempts regardless of whether the attempt failed due to (1) request timing out or (2) instant failure (no timeout). Due to certain platform issues, the http request to the Azure endpoint may instantly fail without reaching the http timeout duration. Without sleeping a fixed duration in between retry attempts, the http handler will loop through the max retry attempts quickly. This causes the communication between cloud-init and the Azure platform to be less resilient due to the short total duration if there is no sleep in between retries.
Diffstat (limited to 'cloudinit/sources/helpers')
-rwxr-xr-xcloudinit/sources/helpers/azure.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/cloudinit/sources/helpers/azure.py b/cloudinit/sources/helpers/azure.py
index d3055d08..03e7156b 100755
--- a/cloudinit/sources/helpers/azure.py
+++ b/cloudinit/sources/helpers/azure.py
@@ -303,6 +303,7 @@ def http_with_retries(url, **kwargs) -> str:
max_readurl_attempts = 240
default_readurl_timeout = 5
+ sleep_duration_between_retries = 5
periodic_logging_attempts = 12
if 'timeout' not in kwargs:
@@ -338,6 +339,7 @@ def http_with_retries(url, **kwargs) -> str:
'attempt %d with exception: %s' %
(url, attempt, e),
logger_func=LOG.debug)
+ time.sleep(sleep_duration_between_retries)
raise exc