fix: test fail on venv python3.12 due to 200MB being too small and la…#20
Conversation
|
Thanks for digging in here — the Python 3.12 baseline-overhead issue is real, and the I want to flag one concern with the production default bump (200 → 512 MB) before we merge, and propose a small additional change. Concern: cgroup vs. RLIMIT_AS inversionThe default chart sets the pod memory limit to 256Mi (
This weakens the layered defense story: layer 3 (subprocess memory bound) becomes a no-op for the minimal profile in the default chart. Proposed changeI measured the FastAPI parent RSS locally (Python 3.11/macOS, profile loaded, idle and during a typical
Optionally, splitting into "test-runner fix" and "raise minimal profile memory ceiling" commits would make the production behavior change easier to spot in the log, but not required. Adjacent finding (not on you)
Follow-up (also not on you)I'll open a second issue to track a Python-version-stable approach (measuring interpreter baseline VM at app startup and applying RLIMIT_AS as |
|
All four changes done:
|
|
just testing in openshift as well .. make sure looks good |
|
● That confirms the fix works:
Let me verify the pod didn't restart. ● Bash(oc get pods -n code-sandbox -l app.kubernetes.io/name=code-sandbox 2>&1) ● All green — 0 restarts. Here's what was validated:
The cgroup vs RLIMIT_AS inversion is fixed. Added new test for this as well: test_default_rlimit_fires_before_cgroup |
|
Almost there — the OpenShift validation and the new The test asserts that the allocation should fail ( That's correct behavior under the new defaults. Linux Python interpreter VM at startup is ~30–50 MB, plus a 400 MB bytearray = ~430–450 MB total VM, which is comfortably under the new 512 MB RLIMIT_AS. The allocation should succeed; the test asserting otherwise is the bug. Two ways to fix: Option A — bump the allocation above the limit so the test does its intended job: async def test_memory_exhaustion(self):
"""Attempt to allocate 600MB in a memory-limited sandbox."""
code = textwrap.dedent("""\
x = bytearray(600 * 1024 * 1024)
print('ALLOCATED:', len(x))
""")You already proved 600 MB triggers Option B — delete Either works. I'd lean toward B since you've already replaced it with something better, but if you'd rather keep both as belt-and-suspenders that's fine too. |
|
● All 60 passed. Deleted test_memory_exhaustion — the new test_default_rlimit_fires_before_cgroup covers it with a stronger assertion. |
rdwj
left a comment
There was a problem hiding this comment.
All feedback addressed — Option B was the right call. 60/60 tests green, upstream merged, RLIMIT_AS inversion fixed and validated on OpenShift. Merging.
Summary
following the local development readme immediately fails