summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceScaleway.py
diff options
context:
space:
mode:
authorKurt Garloff <kurt@garloff.de>2018-03-23 12:31:20 -0400
committerScott Moser <smoser@brickies.net>2018-03-23 12:31:20 -0400
commit097a2967abd6c78edfbdc035e7141f2d142f17ae (patch)
treedad2304c3a97b2a43eab83871bacad2de930f1ef /cloudinit/sources/DataSourceScaleway.py
parent0d51e912146b3031c458ce415b7d4cd6eb17d06e (diff)
downloadvyos-cloud-init-097a2967abd6c78edfbdc035e7141f2d142f17ae.tar.gz
vyos-cloud-init-097a2967abd6c78edfbdc035e7141f2d142f17ae.zip
Revert the logic of exception_cb in read_url.
In commit e9e8616, there was an inversion of the logic of the exception_cb return value meaning, breaking the (network) OpenStack DataSource, which implemented exception_cb as should_retry_cb, returning True when a retry should be done and False when the retry loop should be broken and the exception reraised again immediately. The OpenStack DS was the only user of this callback at the time and not touched by the commit (nor did the commit message mention an intended change), so this almost certainly happened by mistake. These days, we have a second user of the callback in DataSourceScaleway. It uses the new logic, so it needs change if we fix the meaning of the return value. This patch reverts the meaning of url_helper.read_url() execption_cb to the old semantics. It updates the comment and adjusts the Scaleway datasource. The patch has been tested on Open Telekom Cloud (which uses the OpenStack network Datasource) where previously a missing user_data and network_data.json would be retried 6 times each despite them not being present (they are optional!) and the server repsonding with a correct 404. After the patch, boot times are 10s faster, as we no longer pointlessly retry these files. LP: #1702160 LP: #1298921
Diffstat (limited to 'cloudinit/sources/DataSourceScaleway.py')
-rw-r--r--cloudinit/sources/DataSourceScaleway.py6
1 files changed, 3 insertions, 3 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)