Skip to content

Commit

Permalink
fix(runtime build): only check for image exist on exact hash tag (#4152)
Browse files Browse the repository at this point in the history
  • Loading branch information
xingyaoww authored Oct 1, 2024
1 parent 04643d6 commit 3cf794f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions openhands/runtime/builder/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def build(
target_image_tag = tags[1].split(':')[1] if len(tags) > 1 else None

# Check if the image exists and pull if necessary
self.image_exists(target_image_repo)
self.image_exists(target_image_hash_name)

buildx_cmd = [
'docker',
Expand Down Expand Up @@ -186,9 +186,7 @@ def image_exists(self, image_name: str, pull_from_repo: bool = True) -> bool:
return True
except docker.errors.ImageNotFound:
if not pull_from_repo:
logger.debug(
f'Image {image_name} not found locally'
)
logger.debug(f'Image {image_name} not found locally')
return False
try:
logger.debug(
Expand All @@ -197,8 +195,15 @@ def image_exists(self, image_name: str, pull_from_repo: bool = True) -> bool:

layers: dict[str, dict[str, str]] = {}
previous_layer_count = 0

if ':' in image_name:
image_repo, image_tag = image_name.split(':', 1)
else:
image_repo = image_name
image_tag = None

for line in self.docker_client.api.pull(
image_name, stream=True, decode=True
image_repo, tag=image_tag, stream=True, decode=True
):
self._output_build_progress(line, layers, previous_layer_count)
previous_layer_count = len(layers)
Expand Down

0 comments on commit 3cf794f

Please sign in to comment.