6
6
import argparse
7
7
import os
8
8
import shutil
9
- import sys
10
- import time
11
9
from dataclasses import dataclass
12
10
from pathlib import Path
13
- from typing import Callable , List , Optional , TypeVar
11
+ from typing import List , Optional , TypeVar
14
12
15
13
import invoke
16
14
@@ -37,27 +35,6 @@ def __post_init__(self):
37
35
ReturnType = TypeVar ("ReturnType" ) # https://docs.python.org/3/library/typing.html#generics
38
36
39
37
40
- def retry (func : Callable [[], ReturnType ], num_retries : int = 3 ) -> ReturnType :
41
- """
42
- Call the given `func`. If an exception is raised, print, and retry `num_retries` times.
43
- Back off retries by sleeping for at least 5 secs + an exponential increase.
44
- Exception is not caught on the last try.
45
- """
46
- BASE_BACKOFF_WAIT_SECS = 5
47
- for i in range (num_retries ):
48
- try :
49
- return func ()
50
- except Exception as e :
51
- print (f"Exception occurred: { e } " , file = sys .stderr )
52
- print (f"Retries left: { num_retries - i } " , file = sys .stderr )
53
- wait_time_secs = BASE_BACKOFF_WAIT_SECS + i ** 2
54
- print (f"Waiting for next retry (secs): { wait_time_secs } " )
55
- time .sleep (wait_time_secs ) # 5, 6, 9, 14, 21, etc.
56
-
57
- # Let the final try actually throw
58
- return func ()
59
-
60
-
61
38
def load_base_image_tar_file (container_cmd : str , tar_file : Path ):
62
39
"""
63
40
Load the filesystem in the tar file into the podman repo.
@@ -117,10 +94,7 @@ def build_container(
117
94
cmd += f"{ context_dir } "
118
95
print (cmd )
119
96
120
- def build_func ():
121
- invoke .run (cmd ) # Throws on failure
122
-
123
- retry (build_func )
97
+ invoke .run (cmd ) # Throws on failure
124
98
return image_tag
125
99
126
100
0 commit comments