Skip to content

Commit

Permalink
azure/imds: refactor max_connection_errors definition
Browse files Browse the repository at this point in the history
max_connection_errors is treated more like "retry_connection_errors"
where it will retry up to specified number of errors rather than
aborting when max_connection_errors is hit.

Update the max_connection_errors to abort once that number is seen.

Bump the max_connection_errors default by 1 so no behavior is changed.

Signed-off-by: Chris Patterson <[email protected]>
  • Loading branch information
cjp256 committed Sep 28, 2023
1 parent 506e70f commit fdf5289
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cloudinit/sources/azure/imds.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(
self,
*,
logging_backoff: float = 1.0,
max_connection_errors: int = 10,
max_connection_errors: int = 11,
retry_codes=(
404, # not found (yet)
410, # gone / unavailable (yet)
Expand Down Expand Up @@ -67,7 +67,7 @@ def exception_callback(self, req_args, exception) -> bool:
# primary NIC.
if isinstance(exception.cause, requests.ConnectionError):
self.max_connection_errors -= 1
if self.max_connection_errors < 0:
if self.max_connection_errors <= 0:
retry = False
elif (
exception.code is not None
Expand Down

0 comments on commit fdf5289

Please sign in to comment.