Skip to content

test: keep ht-notify and torchelastic leftovers out of the shared /tmp (#19) - #23

Merged
Mathis (echobt) merged 2 commits into
mainfrom
ci/test-tmp-leak
Oct 20, 2026
Merged

Mathis (echobt) merged 2 commits into
mainfrom
ci/test-tmp-leak

Conversation

@echobt

Copy link
Copy Markdown
Contributor

Why

Issue #19: the test suite filled the shared /tmp tmpfs (1 048 576 inodes) on the CI/dev host: ~15.7k empty ht-notify-* directories (one per ChallengeStore, created for the v2 IPC socket) and ~14.2k torchelastic_* directories (torchrun logs), hitting 100 % inode use.

What (tests only, no src/ change)

  • tests/conftest.py: session autouse fixture _tmp_leak_guard. It sets PET_LOG_DIR under pytest's basetemp (torchrun logs follow) and, at session end, rmdirs only the empty ht-notify-* directories of the same uid that appeared during the session (a non-empty one may be a live peer's, so it is left).
  • tests/challenge/test_store_notify_dir.py: cleanup removes a directory left by a closed store; keeps a directory holding a live socket; keeps a directory that predates the snapshot; 8 threads x start/close on one shared state_dir never fail.

Why not fix it in src/

A first version removed the shared directory on close_v2_notifications() with a retry in _start_notifications_v2. Independent review (Lens) reproduced the race it introduces: 30 failures / 3 200 starts with 8 threads. The directory is shared per state_dir, so production keeps the empty directory; the leak is a test-suite concern and is fixed in the test session.

Evidence

pytest tests/challenge/test_store_notify_dir.py tests/test_systemd_probe_classify.py: 12 passed. ls -d /tmp/ht-notify-* | wc -l identical before and after the targeted run (978 / 978).

Risk / rollback

Tests only. Revert the merge commit.

🤖 Generated with Claude Code

Every ChallengeStore opened by a test leaves an empty ht-notify-<hash>
directory (the directory is shared per state_dir, so production keeps
closing without rmdir to avoid racing a starting peer), and torchrun
leaves torchelastic_* directories: ~30k inodes on the shared host filled
/tmp. A session fixture points PET_LOG_DIR under basetemp and, at session
end, rmdirs only the empty ht-notify-* directories of this uid that
appeared during the session. Tests cover the cleanup, a live peer socket,
a pre-existing directory and 8 threads x start/close on a shared state_dir.
No src/ change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9246b805-11c6-4dd5-ae61-7cb0e9ae0487
📥 Commits

Reviewing files that changed from the base of the PR and between dc16319 and 7be6624.

📒 Files selected for processing: 3
  • tests/challenge/test_store_notify_dir.py
  • tests/conftest.py
  • tests/notify_cleanup.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

'from conftest import' resolves to whichever conftest.py pytest registered
first; in a shard collecting tests/trainer first it picked
tests/trainer/conftest.py and failed at collection (same defect as the
systemd probe classifier). Move remove_new_empty_notify_dirs to
tests/notify_cleanup.py, used by tests/conftest.py and the unit test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@echobt
Mathis (echobt) merged commit a46ed65 into main Oct 20, 2026
13 checks passed
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