Filter preload images to include only locally available images
Lint Checks / Run linter (push) Failing after 0s Details

pull/751/head
pranav 2026-05-04 19:14:06 +05:30
parent e933f112c6
commit e1515e6918
2 changed files with 18 additions and 3 deletions

View File

@ -30,6 +30,7 @@ from stack_orchestrator.deploy.k8s.helpers import (
create_cluster, create_cluster,
destroy_cluster, destroy_cluster,
get_kind_cluster, get_kind_cluster,
is_image_available_locally,
load_images_into_kind, load_images_into_kind,
) )
from stack_orchestrator.deploy.k8s.helpers import ( from stack_orchestrator.deploy.k8s.helpers import (
@ -833,9 +834,15 @@ class K8sDeployer(Deployer):
actual_cluster = create_cluster(self.kind_cluster_name, kind_config) actual_cluster = create_cluster(self.kind_cluster_name, kind_config)
if actual_cluster != self.kind_cluster_name: if actual_cluster != self.kind_cluster_name:
self.kind_cluster_name = actual_cluster self.kind_cluster_name = actual_cluster
# Pre-load images into kind so pods can use them with local_containers = self.deployment_context.stack.obj.get("containers", [])
# imagePullPolicy: IfNotPresent before the registry is consulted. images_to_preload = set((self.image_overrides or {}).values()) | {
images_to_preload = set((self.image_overrides or {}).values()) img
for img in self.cluster_info.image_set
if any(c in img for c in local_containers)
}
images_to_preload = {
img for img in images_to_preload if is_image_available_locally(img)
}
if images_to_preload: if images_to_preload:
load_images_into_kind(self.kind_cluster_name, images_to_preload) load_images_into_kind(self.kind_cluster_name, images_to_preload)
elif self.is_kind(): elif self.is_kind():

View File

@ -607,6 +607,14 @@ def update_caddy_ingress_image(caddy_image: str) -> bool:
return True return True
def is_image_available_locally(image: str) -> bool:
result = subprocess.run(
["docker", "image", "inspect", image],
capture_output=True,
)
return result.returncode == 0
def load_images_into_kind(kind_cluster_name: str, image_set: Set[str]): def load_images_into_kind(kind_cluster_name: str, image_set: Set[str]):
for image in image_set: for image in image_set:
result = _run_command( result = _run_command(