Repository navigation
Conversation
|
/ok to test 40e6725 |
40e6725 to
e74a054
Compare
|
Label |
|
/ok to test e74a054 |
Recover the managed-children registry from a poisoned lock in unregister, like its sibling accessors already do, so a PID whose waiter panicked while holding the lock cannot stay registered forever and be skipped by the orphan reaper after the PID is reused. Classify a missing /proc/self/task/<tid>/children file instead of treating every NotFound as a vanished task. When no task in a scan exposes the file (kernel built without CONFIG_PROC_CHILDREN, or restricted procfs), log a warning and emit an OCSF detection finding once per process instead of silently leaving the orphan reaper inert while zombies accumulate. Contain a panicking job on the workload launcher thread, the way the network broker contains handler panics: the panic is reported, the thread leaves its job loop, and the health flag turns false so every later spawn fails fast instead of hanging on a launcher that still reports healthy. Closes ai-openshell#5186 Signed-off-by: Emilien Macchi <emacchi@redhat.com>
e74a054 to
6c769e8
Compare
FrostGod
left a comment
There was a problem hiding this comment.
Looks good overall, small and well tested. A few comments inline, plus:
workload_launcher.rsL53–57 (nit): "dropped the spawn result" hides that the job panicked. Can the error say so?- Jobs are just
cmd.spawn()(process.rs:445–456), so is the panic containment purely defensive? - This overlaps #5233 in
managed_children.rs. Let's agree which merges first.
| let task = task?; | ||
| let path = task.path().join("children"); | ||
| let contents = match std::fs::read_to_string(path) { | ||
| Ok(contents) => contents, | ||
| Err(error) if error.kind() == io::ErrorKind::NotFound => continue, | ||
| Err(error) => return Err(error), | ||
| }; | ||
| children.extend( | ||
| match read_task_children(&task.path())? { |
There was a problem hiding this comment.
One unreadable task aborts the whole scan, and the error only reaches the debug! at L158, so the reaper can still stop silently. Skip the bad task, and warn once on repeated scan errors?
| openshell_ocsf::ocsf_emit!( | ||
| openshell_ocsf::DetectionFindingBuilder::new(openshell_ocsf::ctx::ctx()) | ||
| .activity(openshell_ocsf::ActivityId::Open) | ||
| .severity(openshell_ocsf::SeverityId::Medium) | ||
| .confidence(openshell_ocsf::ConfidenceId::High) | ||
| .is_alert(true) | ||
| .finding_info( | ||
| openshell_ocsf::FindingInfo::new( | ||
| "proc-children-unavailable", | ||
| "Sandbox Orphan Reaper Unavailable", | ||
| ) | ||
| .with_desc( | ||
| "No task under /proc/self/task exposes a children file, so \ | ||
| the sandbox orphan reaper cannot discover unmanaged \ | ||
| children, and exited descendants accumulate as zombies \ | ||
| until the process limit. The likely causes are a kernel \ | ||
| built without CONFIG_PROC_CHILDREN or restricted procfs \ | ||
| (for example gVisor or a subset=pid mount).", | ||
| ) | ||
| ) | ||
| .message("orphan reaper unavailable: no /proc/self/task/*/children") | ||
| .build() | ||
| ); |
There was a problem hiding this comment.
AGENTS.md says to dual-emit findings with a domain event. Is standalone intended here?
| let _ = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { | ||
| let _registry = lock(); | ||
| panic!("poison the managed-children registry"); | ||
| })); |
There was a problem hiding this comment.
nit: this leaves the global lock poisoned for later tests. Add MANAGED_CHILDREN.clear_poison() at the end?
| if let Err(panic) = std::panic::catch_unwind(std::panic::AssertUnwindSafe(job)) { | ||
| tracing::error!("workload launcher job panicked: {}", panic_message(&*panic)); | ||
| break; |
There was a problem hiding this comment.
A dead launcher means no new processes can start in this sandbox. Emit an OCSF event here, not just tracing::error!?
Summary
Three silent-failure paths in the sandbox, all found by reading the code: a managed-children registration leaks after a poisoned registry lock, the orphan reaper goes inert on kernels without
CONFIG_PROC_CHILDRENbecause every missingchildrenfile reads as a vanished task, and a panicking job kills the workload launcher thread whileis_alive()keeps reporting healthy.Related Issue
Closes #5186
Changes
managed_children::unregisterrecovers from a poisoned registry lock like its sibling accessors, so a registration can no longer leak after a waiter panics while holding the lockdirect_child_pidsclassifies a missingchildrenfile per task (vanished task vs missing support), only concludes missing support when no task in the scan listed one, and reports it once per process with a warning and an OCSF detection findingcatch_unwind, like the network broker's handler panics: the panic is logged, the thread leaves its job loop, andis_alive()turns false so later spawns fail fastRelease Notes
When no task under
/proc/self/taskexposes achildrenfile (kernel built withoutCONFIG_PROC_CHILDREN, or restricted procfs), the sandbox now reports the inert orphan reaper once instead of failing silently. A panicking workload-launcher job now stops the launcher with a clear error instead of leaving it reporting healthy.Testing
Checks appropriate to the affected code and behavior pass
Unit tests added/updated (if applicable)
E2E tests added/updated (if applicable)
cargo test -p openshell-sandbox --lib: 293 passed, including regression tests for each path (poisoned-lockunregister, children-file classification and reporting, panicking launcher job; the suite also passes withRUST_BACKTRACE=1)cargo clippy --workspace --all-targets -- -D warnings, theperf-harnessvariant, andcargo fmt --all -- --checkpassNo local e2e run: this host has no docker daemon and the k8s lane needs a full image build. The changed paths are failure paths not reachable on healthy kernels, and the launcher's normal spawn path is covered by tests that spawn real children through the filtered thread. CI lanes cover the rest.
uv-based checks (python format, license headers) skipped locally due to a host uv config break (2026-11-03 RPM update); this diff touches no manifests or Python files
Checklist