Skip to content

fix(bench): Remove bench image after archival (backport #508)#530

Merged
tanmoysrt merged 1 commit into
masterfrom
mergify/bp/master/pr-508
Jun 2, 2026
Merged

fix(bench): Remove bench image after archival (backport #508)#530
tanmoysrt merged 1 commit into
masterfrom
mergify/bp/master/pr-508

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify Bot commented Jun 2, 2026

Check if the image is there on registry.
If it's available, remove from local.


This is an automatic backport of pull request #508 done by Mergify.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Jun 2, 2026

Greptile Summary

This backport adds a registry-presence check before removing a bench's Docker image from local storage during archival: if the image exists in the remote registry it is safe to remove locally, otherwise it is left in place.

  • docker_inspect_manifest wraps docker manifest inspect and raises a typed exception when the image is absent from the registry, otherwise returns the manifest JSON.
  • remove_docker_image calls the inspector and conditionally invokes docker rmi --force, with the entire block wrapped in contextlib.suppress(Exception).
  • The if not manifest: return guard inside remove_docker_image is unreachable in practice because docker_inspect_manifest never returns a falsy value on success.

Confidence Score: 4/5

Safe to merge; the new image-removal path is best-effort and failures leave the system in the conservative state (image kept locally).

The core flow is correct — the image is only deleted locally once confirmed present in the registry. The two concerns (overly broad exception suppression with no logging, and an unreachable early-return guard) are quality issues that could make future failures hard to diagnose, but neither causes incorrect behavior on the happy path or risks data loss.

agent/server.py — specifically the remove_docker_image method, which silently swallows all exceptions including unexpected Docker daemon or network errors.

Important Files Changed

Filename Overview
agent/server.py Adds registry manifest check before local image removal on bench archival; logic is sound but exceptions are fully suppressed with no logging, and one guard check is unreachable.

Sequence Diagram

sequenceDiagram
    participant AB as archive_bench()
    participant RDI as remove_docker_image()
    participant DIM as docker_inspect_manifest()
    participant Docker as Docker CLI

    AB->>AB: resolve image_tag from Bench
    AB->>RDI: remove_docker_image(image_tag)
    note over RDI: contextlib.suppress(Exception)
    RDI->>DIM: docker_inspect_manifest(image_tag)
    DIM->>Docker: docker manifest inspect tag
    alt Image found in registry
        Docker-->>DIM: manifest JSON
        DIM-->>RDI: manifest (truthy)
        RDI->>Docker: docker rmi tag --force
        Docker-->>RDI: success
    else no such manifest
        Docker-->>DIM: error output
        DIM--xRDI: raise Exception(not found)
        note over RDI: suppressed silently
    else Other error (network, auth)
        Docker-->>DIM: error
        DIM--xRDI: re-raise AgentException
        note over RDI: also suppressed silently
    end
Loading

Reviews (1): Last reviewed commit: "fix(bench): Remove bench image after arc..." | Re-trigger Greptile

Comment thread agent/server.py
Comment on lines +417 to +421
with contextlib.suppress(Exception):
manifest = self.docker_inspect_manifest(image_tag)
if not manifest:
return
self.execute(f"docker rmi {image_tag} --force")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Silent exception swallows both "not in registry" and real errors

contextlib.suppress(Exception) catches every exception thrown inside the block — including transient network failures, Docker daemon errors, and authentication problems. When docker_inspect_manifest raises because the registry is temporarily unreachable (the AgentException re-raise path), the image is silently left on disk with no log entry and no way to tell the difference from the intentional "image not in registry, skip removal" case. Adding at least a logger.warning before suppressing would make failures observable without changing the best-effort semantics.

Comment thread agent/server.py
Comment on lines +418 to +420
manifest = self.docker_inspect_manifest(image_tag)
if not manifest:
return
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 if not manifest: return is unreachable dead code

docker_inspect_manifest never returns a falsy value on success — if docker manifest inspect exits cleanly it emits a non-empty JSON blob; if the image is absent it raises Exception("Image ... not found in registry"); for all other failures it re-raises AgentException. None of those paths produce a falsy return, so the early-return guard will never fire. The guard can be removed to avoid confusion about why the subsequent docker rmi might be skipped.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@tanmoysrt tanmoysrt merged commit 88e8099 into master Jun 2, 2026
4 of 5 checks passed
@tanmoysrt tanmoysrt deleted the mergify/bp/master/pr-508 branch June 2, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant