Skip to content

Commit 99dcded

Browse files
committed
fix(cli): add retries for image pull command
Signed-off-by: Radek Ježek <[email protected]>
1 parent d862f72 commit 99dcded

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

apps/beeai-cli/src/beeai_cli/commands/platform/base_driver.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import anyio
1111
import pydantic
1212
import yaml
13+
from tenacity import AsyncRetrying, stop_after_attempt
1314

1415
import beeai_cli.commands.platform.istio
1516
from beeai_cli.configuration import Configuration
@@ -104,16 +105,19 @@ async def deploy(self, set_values_list: list[str], import_images: list[str] | No
104105
for image in {typing.cast(str, yaml.safe_load(line)) for line in images_str.splitlines()} - set(
105106
import_images or []
106107
):
107-
await self.run_in_vm(
108-
[
109-
"k3s",
110-
"ctr",
111-
"image",
112-
"pull",
113-
image if "." in image.split("/")[0] else f"docker.io/{image}",
114-
],
115-
f"Pulling image {image}",
116-
)
108+
async for attempt in AsyncRetrying(stop=stop_after_attempt(5)):
109+
with attempt:
110+
attempt_num = attempt.retry_state.attempt_number
111+
await self.run_in_vm(
112+
[
113+
"k3s",
114+
"ctr",
115+
"image",
116+
"pull",
117+
image if "." in image.split("/")[0] else f"docker.io/{image}",
118+
],
119+
f"Pulling image {image}" + (f" (attempt {attempt_num})" if attempt_num > 1 else ""),
120+
)
117121

118122
if any("oidc.enabled=true" in value.lower() for value in set_values_list):
119123
await beeai_cli.commands.platform.istio.install(driver=self)

0 commit comments

Comments
 (0)