Repository navigation
tentacle: cephadm/tests: pre-import tracemalloc to avoid pyfakefs setup race - #71189
Open
djgalloway wants to merge 1 commit into
Open
djgalloway wants to merge 1 commit into
djgalloway wants to merge 1 commit into
Conversation
Contributor
Author
|
/audit retest |
|
🔄 Audit Retest Triggered by @djgalloway. |
Since 2026-08-18 run_tox_cephadm has been failing in roughly a quarter of
arm64 make check runs (and ~8% of x86 runs) with
RuntimeError: dictionary changed size during iteration
pyfakefs/fake_filesystem_unittest.py:831 in Patcher._find_modules
during `fs` fixture setup, followed by 80+ cascading
AttributeError: 'NoneType' object has no attribute 'add_real_directory'
because pyfakefs' Patcher is a ref-counted singleton and a failed setUp()
never gets its tearDown().
There is no second thread involved. Several TestBootstrap tests run
command_bootstrap() to completion, which leaves NamedTemporaryFile objects
created on the fake filesystem to be garbage collected after the fake fs
has been torn down. Their __del__ raises, which makes pytest's (>= 8.4)
unraisable-exception hook run *inside the GC pass*, and the first time it
does so it lazily imports tracemalloc (tracemalloc_message()). If that GC
fires while pyfakefs 5.3.5 is doing `list(sys.modules.items())`, the
iteration blows up. Newer pyfakefs (>= 5.10) snapshots sys.modules with
dict.copy() and is immune, but 5.10.x is not a drop-in upgrade for this
test suite, so import tracemalloc up front instead so that nothing new
gets added to sys.modules from within a finalizer.
Signed-off-by: David Galloway <[email protected]>
Assisted-by: Claude Fable 5 (claude-fable-5)
(cherry picked from commit 7989817)
djgalloway
force-pushed
the
wip-cephadm-tox-tracemalloc-tentacle
branch
from
August 21, 2026 14:56
72d6c9b to
44eff9c
Compare
adk3798
approved these changes
Aug 21, 2026
Contributor
Author
|
jenkins test make check |
s0nea
added a commit
to cobaltcore-dev/ceph
that referenced
this pull request
Nov 3, 2026
…fakefs setup race (#43) Backport-Id: 01a177f4-63f1-7e3d-a389-f72fcfbb888d Backport-PR: #43 Upstream-PRs: ceph#71189, ceph#71163
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #71163 (clean cherry-pick).
run_tox_cephadmfails intermittently (~25% of arm64make checkruns, ~8% x86 on main; tentacle uses the same pyfakefs 5.3.5 pin and unpinned pytest, so it is equally exposed) withRuntimeError: dictionary changed size during iterationin pyfakefsPatcher._find_modulesfollowed by ~80 cascading'NoneType' object has no attribute 'add_real_directory'errors. pytest ≥8.4's unraisable-exception hook lazily importstracemallocfrom inside a GC pass triggered by leakedNamedTemporaryFilefinalizers; pre-importing it in conftest removes the sys.modules mutation.backport tracker: https://tracker.ceph.com/issues/79677