Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions operator/anarchysubject.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,8 @@ async def remove_run_from_status(self, anarchy_run) -> None:
# Suspicious if AnarchyRun is not in status, refresh object from API to be sure.
if not self.has_run_in_status(anarchy_run):
await self.refresh()
# Loop until consistent
while True:
max_retries = 10
for attempt in range(max_retries):
patch = []
removed_active_run = False
# Loop over status runs entries building patch to remove run.
Expand All @@ -676,16 +676,20 @@ async def remove_run_from_status(self, anarchy_run) -> None:
return
try:
await self.json_patch_status(patch)
break
except kubernetes_asyncio.client.rest.ApiException as e:
# 404 indicates run was being removed because subject was also being deleted.
if e.status == 404:
return
if e.status == 422:
# Patch failed test condition, must be out of sync
# Refresh AnarchySubject state and retry
await self.refresh()
else:
raise
break
else:
raise kopf.TemporaryError(
f"Failed to remove {anarchy_run} from {self} status after {max_retries} retries",
)

if removed_active_run:
logging.info("Removed active %s from %s status", anarchy_run, self)
Expand Down