Skip to content

Commit 1543860

Browse files
Kraken: allow installing extension if pull fails but image is available offline
1 parent 08c3e04 commit 1543860

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

core/services/kraken/extension/extension.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,16 @@ def _prepare_docker_auth(self) -> Optional[str]:
177177
docker_auth = f"{self.source.auth.username}:{self.source.auth.password}"
178178
return base64.b64encode(docker_auth.encode("utf-8")).decode("utf-8")
179179

180+
async def _image_is_available_locally(self) -> bool:
181+
"""Check if the Docker image is available locally."""
182+
try:
183+
image_ref = f"{self.source.docker}:{self.tag}" + (f"@{self.digest}" if self.digest else "")
184+
async with DockerCtx() as client:
185+
await client.images.inspect(image_ref)
186+
return True
187+
except Exception:
188+
return False
189+
180190
async def _pull_docker_image(self, docker_auth: Optional[str]) -> AsyncGenerator[bytes, None]:
181191
"""Pull Docker image and yield progress updates."""
182192
tag = f"{self.source.docker}:{self.tag}" + (f"@{self.digest}" if self.digest else "")
@@ -214,12 +224,14 @@ async def install(self, clear_remaining_tags: bool = True, atomic: bool = False)
214224
# In case of some external installs kraken shouldn't try to install it again so we remove from settings
215225
if atomic:
216226
should_raise = False
217-
if not running_ext or self.unique_entry != running_ext.unique_entry:
218-
should_raise = True
219-
await self.uninstall()
220-
221-
if running_ext:
222-
await running_ext.enable()
227+
if await self._image_is_available_locally():
228+
logger.info(f"Pull failed but image {self.identifier}:{self.tag} is already available locally")
229+
else:
230+
if not running_ext or self.unique_entry != running_ext.unique_entry:
231+
should_raise = True
232+
await self.uninstall()
233+
if running_ext:
234+
await running_ext.enable()
223235

224236
if should_raise:
225237
raise ExtensionPullFailed(f"Failed to pull extension {self.identifier}:{self.tag}") from error

0 commit comments

Comments
 (0)