Diff comments:
> diff --git a/cloudinit/sources/DataSourceAzure.py
> b/cloudinit/sources/DataSourceAzure.py
> index d0358e9..aaa705c 100644
> --- a/cloudinit/sources/DataSourceAzure.py
> +++ b/cloudinit/sources/DataSourceAzure.py
> @@ -514,7 +515,10 @@ class DataSourceAzure(sources.DataSource):
>
> def exc_cb(msg, exception):
> if isinstance(exception, UrlError) and exception.code == 404:
> - return True
> + return True # Continue retries
> + cause = exception.cause
Would it be reasonable to join the (case and isinstance(case, requests.Timeout)
to the above if clause
so we have just one return True # continue retries?
> + if cause and isinstance(cause, requests.Timeout):
> + return True # Continue retries
> # If we get an exception while trying to call IMDS, we
> # call DHCP and setup the ephemeral network to acquire the new
> IP.
> return False
> @@ -1170,8 +1174,12 @@ def get_metadata_from_imds(fallback_nic, retries):
> def _get_metadata_from_imds(retries):
>
> def retry_on_url_error(msg, exception):
> - if isinstance(exception, UrlError) and exception.code == 404:
> - return True # Continue retries
> + if isinstance(exception, UrlError):
> + if exception.code == 404:
> + return True # Continue retries
> + cause = exception.cause
> + if cause and isinstance(cause, requests.Timeout):
> + return True # Continue retries
Hrm, this is a repeat as well; could we wrap this in a function passing in the
exception ?
def should_continue(exception):
if should_continue(exception):
return True # continue retries
?
> return False # Stop retries on all other exceptions
>
> url = IMDS_URL + "instance?api-version=2017-12-01"
--
https://code.launchpad.net/~chad.smith/cloud-init/+git/cloud-init/+merge/358112
Your team cloud-init commiters is requested to review the proposed merge of
~chad.smith/cloud-init:bug/1800223-retry-imds-on-timeout into cloud-init:master.
_______________________________________________
Mailing list: https://launchpad.net/~cloud-init-dev
Post to : [email protected]
Unsubscribe : https://launchpad.net/~cloud-init-dev
More help : https://help.launchpad.net/ListHelp