Skip to content

Commit 0bee5c6

Browse files
authored
Add exponential backoff strategy to watchdog restart (#6262)
1 parent 9c0174f commit 0bee5c6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

supervisor/addons/addon.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,15 @@ async def _restart_after_problem(self, state: ContainerState):
15621562
)
15631563
break
15641564

1565-
await asyncio.sleep(WATCHDOG_RETRY_SECONDS)
1565+
# Exponential backoff to spread retries over the throttle window
1566+
delay = WATCHDOG_RETRY_SECONDS * (1 << max(attempts - 1, 0))
1567+
_LOGGER.debug(
1568+
"Watchdog will retry addon %s in %s seconds (attempt %s)",
1569+
self.name,
1570+
delay,
1571+
attempts + 1,
1572+
)
1573+
await asyncio.sleep(delay)
15661574

15671575
async def container_state_changed(self, event: DockerContainerStateEvent) -> None:
15681576
"""Set addon state from container state."""

0 commit comments

Comments
 (0)