Skip to content

Commit

Permalink
oidc_config, retry also '"safe" GET
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Cinkelj <[email protected]>
  • Loading branch information
justinc1 committed Aug 29, 2024
1 parent ed4c238 commit 816f16b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion plugins/modules/oidc_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def ensure_present(
oidc_obj_ansible = Oidc.from_ansible(module.params)
# If we get "502 bad gateway" during reconfiguration, we need to retry.
max_retries = 10

for ii in range(max_retries):
try:
oidc_obj = Oidc.get(rest_client)
Expand All @@ -123,7 +124,23 @@ def ensure_present(
continue
else:
raise
updated_oidc = Oidc.get(rest_client)
# module.warn(f"API during reconfiguration ii={ii}")

for ii in range(max_retries):
try:
updated_oidc = Oidc.get(rest_client)
break
except UnexpectedAPIResponse as ex:
if ex.response_status in [500, 502]:
module.warn(
f"API misbehaving after reconfiguration, retry {ii + 1}/{max_retries}"
)
sleep(1)
continue
else:
raise
# module.warn(f"API after reconfiguration ii={ii}")

after = updated_oidc.to_ansible() if updated_oidc else None
# We always sent POST or PATCH, so it is always changed=True
return True, after, dict(before=before, after=after)
Expand Down

0 comments on commit 816f16b

Please sign in to comment.