Skip to content

fix: remove_dir now correctly removes symlinks (CEFS nightly cleanup)#2027

Merged
mattgodbolt merged 1 commit intomainfrom
molty/fix-remove-dir-symlink
Mar 12, 2026
Merged

fix: remove_dir now correctly removes symlinks (CEFS nightly cleanup)#2027
mattgodbolt merged 1 commit intomainfrom
molty/fix-remove-dir-symlink

Conversation

@mattgodbolt-molty
Copy link
Copy Markdown
Contributor

Problem

On CEFS, nightly compiler paths (e.g. gcc-trunk-20250910) are symlinks pointing to /cefs/<hash>_gcc-trunk-YYYYMMDD squashfs mounts rather than real directories.

NightlyInstallable.install() calls remove_dir() to clean up old versions (keeping only num_to_keep). But remove_dir() was using shutil.rmtree(..., ignore_errors=True). In Python 3.12+, shutil.rmtree raises NotADirectoryError when given a symlink — and with ignore_errors=True this is silently swallowed. The old symlinks are never removed.

This has been accumulating since ~Sep 10 2025 (when CEFS was first enabled for gcc-trunk nightly installs on the admin node), leaving months of daily gcc-trunk symlinks still present. Because those symlinks remain, the CEFS GC cannot collect the underlying squashfs images — causing unbounded growth in CEFS storage.

Fix

In remove_dir(), check whether the path is a symlink first. If so, call unlink() instead of rmtree(). The underlying CEFS content is left intact (as expected — we only want to remove the /opt/compiler-explorer/gcc-trunk-YYYYMMDD symlink, not the squashfs image).

Tests

Three new tests added to bin/test/installation_test.py:

  • Removes a real directory (existing behaviour preserved)
  • Removes a symlink without touching the target (the CEFS fix)
  • Dry-run mode leaves everything alone

All 552 existing tests pass.


(I'm Molty, an AI assistant acting on behalf of @mattgodbolt)

On CEFS, nightly compiler paths (e.g. gcc-trunk-20250910) are symlinks
pointing to /cefs/hash_name squashfs mounts rather than real directories.
shutil.rmtree() on a symlink raises NotADirectoryError in Python 3.12+,
which was silently swallowed by ignore_errors=True, leaving old symlinks
to accumulate indefinitely (observed from Sep 10 2025 onwards).

This prevented the CEFS GC from collecting the underlying images since
they remained referenced, causing unbounded growth in CEFS storage.

Fix: check for symlinks first and use unlink() rather than rmtree().

🤖 Generated by LLM (Claude, via OpenClaw)
@mattgodbolt mattgodbolt merged commit f4ba753 into main Mar 12, 2026
1 check passed
@mattgodbolt mattgodbolt deleted the molty/fix-remove-dir-symlink branch March 12, 2026 20:12
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.

2 participants