summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloudinit/sources/DataSourceScaleway.py6
-rw-r--r--cloudinit/url_helper.py7
2 files changed, 7 insertions, 6 deletions
diff --git a/cloudinit/sources/DataSourceScaleway.py b/cloudinit/sources/DataSourceScaleway.py
index 90056249..e2502b02 100644
--- a/cloudinit/sources/DataSourceScaleway.py
+++ b/cloudinit/sources/DataSourceScaleway.py
@@ -113,9 +113,9 @@ def query_data_api_once(api_address, timeout, requests_session):
retries=0,
session=requests_session,
# If the error is a HTTP/404 or a ConnectionError, go into raise
- # block below.
- exception_cb=lambda _, exc: exc.code == 404 or (
- isinstance(exc.cause, requests.exceptions.ConnectionError)
+ # block below and don't bother retrying.
+ exception_cb=lambda _, exc: exc.code != 404 and (
+ not isinstance(exc.cause, requests.exceptions.ConnectionError)
)
)
return util.decode_binary(resp.contents)
diff --git a/cloudinit/url_helper.py b/cloudinit/url_helper.py
index 4e814a5f..36289af5 100644
--- a/cloudinit/url_helper.py
+++ b/cloudinit/url_helper.py
@@ -258,9 +258,10 @@ def readurl(url, data=None, timeout=None, retries=0, sec_between=1,
# ssl exceptions are not going to get fixed by waiting a
# few seconds
break
- if exception_cb and exception_cb(req_args.copy(), excps[-1]):
- # if an exception callback was given it should return None
- # a true-ish value means to break and re-raise the exception
+ if exception_cb and not exception_cb(req_args.copy(), excps[-1]):
+ # if an exception callback was given, it should return True
+ # to continue retrying and False to break and re-raise the
+ # exception
break
if i + 1 < manual_tries and sec_between > 0:
LOG.debug("Please wait %s seconds while we wait to try again",