Skip to content

Add inspector auto-cleanup on interrupt - #3573

Merged
eleftherias merged 9 commits into
stacklok:mainfrom
carlos-gn:feat/inspector-auto-cleanup
Feb 4, 2026
Merged

eleftherias merged 9 commits into
stacklok:mainfrom
carlos-gn:feat/inspector-auto-cleanup

Conversation

@carlos-gn

@carlos-gn carlos-gn commented Feb 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add automatic cleanup of inspector container when process is interrupted with Ctrl+C
  • Handle SIGINT/SIGTERM signals gracefully in both ready and startup states
  • Add comprehensive E2E tests for auto-cleanup behavior

Closes: #995

Problem

Previously, interrupting the inspector command left orphaned containers that required manual cleanup with thv rm inspector.

Solution

The inspector now listens for interrupt signals and automatically removes its container before exiting. Cleanup is
performed whether the interrupt occurs during startup or after the inspector is fully ready.

Test plan

  • Run thv inspector and press Ctrl+C after UI is ready
  • Verify container is removed with thv list --all
  • Run task test-e2e to verify new auto-cleanup tests pass

  Handle SIGINT/SIGTERM signals in the inspector command to automatically
  remove the inspector container when interrupted. Previously, interrupting
  left orphaned containers requiring manual cleanup.

  - Add signal handling with cleanup on Ctrl+C
  - Clean up container in both ready and startup states
  - Add E2E tests for auto-cleanup scenarios
  - Update existing tests to verify cleanup behavior

  Affected components: cmd/thv/app/inspector.go, test/e2e/

Signed-off-by: carlos <21148423+carlos-gn@users.noreply.github.com>
@github-actions github-actions Bot added the size/M Medium PR: 300-599 lines changed label Feb 3, 2026
@codecov

codecov Bot commented Feb 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.52%. Comparing base (ac82979) to head (3431c56).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3573      +/-   ##
==========================================
+ Coverage   65.51%   65.52%   +0.01%     
==========================================
  Files         406      406              
  Lines       39996    39996              
==========================================
+ Hits        26202    26206       +4     
+ Misses      11762    11756       -6     
- Partials     2032     2034       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: carlos <21148423+carlos-gn@users.noreply.github.com>
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Feb 3, 2026
@carlos-gn
carlos-gn marked this pull request as ready for review February 3, 2026 16:10
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Feb 3, 2026
Signed-off-by: carlos <21148423+carlos-gn@users.noreply.github.com>
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Feb 3, 2026
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Feb 4, 2026

@eleftherias eleftherias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR @carlos-gn! The code looks good. There's one failing test and I've left a couple of suggestions inline.

Comment thread test/e2e/inspector_autocleanup_test.go Resolved
Comment thread test/e2e/inspector_autocleanup_test.go Resolved
Signed-off-by: carlos <21148423+carlos-gn@users.noreply.github.com>
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Feb 4, 2026
Signed-off-by: carlos <21148423+carlos-gn@users.noreply.github.com>
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Feb 4, 2026
@eleftherias
eleftherias merged commit cb5d2b1 into stacklok:main Feb 4, 2026
30 checks passed
@eleftherias

Copy link
Copy Markdown
Member

Thanks @carlos-gn!

@carlos-gn
carlos-gn deleted the feat/inspector-auto-cleanup branch February 4, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inspector container not always removed when inspector command is stopped.

2 participants