mirror of
https://github.com/rubenhensen/k8scd.git
synced 2026-11-16 14:29:09 +01:00
ci: retry when a registry rate-limits
This commit is contained in:
1 parent
67c21c30d8
commit
6d2bc379ba
1 file changed
+10
-1
+10
-1
@@ -22,6 +22,7 @@ import pathlib
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import time
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
@@ -38,7 +39,15 @@ failures = []
|
|||||||
|
|
||||||
|
|
||||||
def run(cmd, **kw):
|
def run(cmd, **kw):
|
||||||
return subprocess.run(cmd, check=True, capture_output=True, text=True, **kw).stdout
|
# Registries rate-limit now and then (ghcr.io answers 429); try again.
|
||||||
|
for attempt in range(3):
|
||||||
|
try:
|
||||||
|
return subprocess.run(cmd, check=True, capture_output=True, text=True, **kw).stdout
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
transient = any(s in (e.stderr or "") for s in ("429", "toomanyrequests", "timeout", "connection reset"))
|
||||||
|
if not transient or attempt == 2:
|
||||||
|
raise
|
||||||
|
time.sleep(10 * (attempt + 1))
|
||||||
|
|
||||||
|
|
||||||
class UniqueKeyLoader(yaml.SafeLoader):
|
class UniqueKeyLoader(yaml.SafeLoader):
|
||||||
|
|||||||
Reference in new issue
Block a user