instead of retrying deletions, sleep longer
retrying deletions can cause 500 error: reference does not exist,
which may make things worse
@@ -124,7 +124,6 @@ def main():
# no name, use id
name = image.id
gb = image.attrs['Size'] / (2**30)
- while True:
logging.info(f'Removing {name} (size={gb:.2f}GB)')
try:
client.images.remove(image=image.id)
@@ -143,11 +142,8 @@ def main():
raise
except requests.exceptions.ReadTimeout:
logging.warning(f'Timeout removing {name}')
- # Retry after timeout rather than proceeding to the next image
- time.sleep(delay)
- continue
- # if we got here, move on to the next image
- break
+ # Delay longer after a timeout, which indicates that Docker is overworked
+ time.sleep(max(delay, 30))
if node:
logging.info(f"Uncordoning node {node}")
