Skip to content

Fix node/panel image uninstall: avoid brittle parsing#14

Open
TaraRostami wants to merge 2 commits intoPasarGuard:mainfrom
TaraRostami:main
Open

Fix node/panel image uninstall: avoid brittle parsing#14
TaraRostami wants to merge 2 commits intoPasarGuard:mainfrom
TaraRostami:main

Conversation

@TaraRostami
Copy link

@TaraRostami TaraRostami commented Feb 22, 2026

This PR fixes uninstall_node_docker_images() and uninstall_pasarguard_docker_images() by removing brittle parsing of docker images output.
The previous implementation relied on awk '{print $3}', which assumes a stable column layout and can extract the wrong field on newer Docker versions / different CLI formatting, causing docker rmi to fail silently.
The updated implementation uses docker images --format for stable extraction, filters only the intended repo (e.g. pasarguard/node), and skips removing images still used by any container.

Old docker:
Screenshot 2025-12-31 094610

New docker:
Screenshot 2025-12-31 094712

Summary by CodeRabbit

  • Bug Fixes
    • Improved Docker image removal safety: prevents removal of images currently in use by containers.
    • Enhanced error handling with better user messaging for missing images and removal failures.
    • Added pre-removal validation checks and per-image feedback during cleanup operations.

@coderabbitai
Copy link

coderabbitai bot commented Feb 22, 2026

No actionable comments were generated in the recent review. 🎉


Walkthrough

Both pasarguard.sh and pg-node.sh now implement safer Docker image removal by checking image existence, verifying container usage, and providing per-image feedback instead of bulk operations. Pre-removal guards prevent attempts on images currently in use.

Changes

Cohort / File(s) Summary
Docker Image Uninstall Safety
pasarguard.sh, pg-node.sh
Both functions now filter Docker images, guard against empty results, skip images in active use by containers, and report per-image success/failure instead of bulk removal.

Sequence Diagram

sequenceDiagram
    participant User
    participant Script
    participant Docker as Docker CLI
    participant Images as Docker Images
    participant Containers as Docker Containers

    User->>Script: Call uninstall function
    Script->>Docker: Query images with filter
    Docker-->>Script: Return image list
    alt No images found
        Script->>User: Print "images not found"
        Script-->>User: Return early
    else Images exist
        loop For each image
            Script->>Docker: Query containers using image
            Docker->>Containers: Check ancestry
            Containers-->>Docker: Return container list
            Docker-->>Script: Report containers
            alt Image in use
                Script->>User: Report containers blocking removal
            else Image not in use
                Script->>Docker: Remove image
                Docker->>Images: Delete image
                Images-->>Docker: Success/Failure
                Docker-->>Script: Report result
                Script->>User: Print removal status
            end
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hop hop, safer skies above,
No more rushing, checks with love,
Container bonds are now respected,
Each image's fate, carefully inspected,
Docker's dance, so wise and bright! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing the uninstall functions to avoid brittle Docker image output parsing by using stable field extraction instead of column-position awk commands.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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