mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #313] [CLOSED] fix(setup): suppress ifupdown hotplug ifquery storm for aenv-* NICs #339
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#339
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/AgentENV/pull/313
Author: @helloC-A
Created: 9/22/2026
Status: ❌ Closed
Base:
main← Head:fix/suppress-ifquery-hotplug-storm📝 Commits (1)
f492af8fix(setup): suppress ifupdown hotplug ifquery storm for aenv-* NICs📊 Changes
6 files changed (+152 additions, -16 deletions)
View changed files
📝
docs/src/internals/networking.md(+8 -8)📝
src/sandbox/network/manager.rs(+6 -6)📝
src/sandbox/network/mod.rs(+1 -1)📝
src/sandbox/network/slot.rs(+1 -1)➕
src/setup/hotplug.rs(+129 -0)📝
src/setup/mod.rs(+7 -0)📄 Description
What
Suppress the
ifqueryprocess storm triggered by AENV NIC events on Debian hosts.veth-toaenv-so AENV NICs are uniquely identifiableaenv-*to the early-exit whitelists of/lib/udev/ifupdown-hotplug(both add and remove paths), applied via--setup-hostdpkg-divert(no--rename) so ifupdown package upgrades cannot overwrite itdocs/src/internals/networking.mdfor the renamed host-side interfaceWhy
On Debian-based hosts,
/lib/udev/rules.d/85-ifupdown.rulesinvokes/lib/udev/ifupdown-hotplugfor every net device add/remove event. Itsnet_ifup()unconditionally runsifquery --allow hotplugto decide whether the interface is hotplug-managed. AENV NICs are never listed in/etc/network/interfaces, so for them the answer is always "not managed" — yet each check pays a full process spawn (udevd worker + hotplug shell + ifquery, ~3 forks per event).Under large-scale sandbox churn this produces hundreds of concurrent ifquery processes (observed 110→342, monotonically growing, indicating arrival rate > service rate). The storm starves host CPUs and inflates sandbox pause/resume latency, which are short, host-CPU-mediated operations.
Load test results (n=22434 pause/resume cycles, same workload before/after):
exec/think being unchanged confirms the gain is host-noise removal rather than workload drift. After the fix, concurrent ifquery counts stay in single digits during sandbox churn.
Related issue
Closes #312
Scope and non-goals
Included:
veth-→aenv-) and the unit tests that reference itifupdown-hotplugpatching module wired intoensure_host()Non-goals:
services/codeveth-*NICs are explicitly unaffectedRejected alternatives (for context):
OPTIONS+="ignore_device"(removed in udev 148, silently ignored),GOTOskip rules (requires overriding system rule files, upgrade conflicts), disabling ifupdown hotplug globally (breaks other services), whitelistingveth-*(collides with Docker/K8s).Design and behavior changes
patch_ifupdown_hotplug()insrc/setup/hotplug.rsruns at the end ofensure_host():/lib/udev/ifupdown-hotplugor/usr/lib/udev/ifupdown-hotplug); skips silently if absent (non-Debian hosts)aenv-*<script>.aenv-backupdpkg-divert --add(deliberately without--rename:--renamemoves the file immediately and breaks the subsequent write; without it the original path stays under AENV control and package upgrades write to.aenv-orig)aenv-*to both existingcasewhitelists; bails loudly if the pattern is not matched (guards against ifupdown versions with a different script layout)udevadm control --reload-rules, no--triggerto avoid replaying events for all NICs)The whitelist is the mechanism's intended use: existing entries (
ppp*,lo,ipsec*, …) already mark NICs managed by other software. AENV configures its NICs itself (netlink for host-side address/route setup,ip=kernel boot arg for the guest), so ifupdown behavior foraenv-*is unchanged — it does nothing either way; only the wasteful fork is skipped.Compatibility and operations
[network.internal]config keys (incl.veth_cidr) are unchanged; only the host-side interface name prefix changes fromveth-{slot}toaenv-{slot}.--setup-host); original script preserved at<script>.aenv-backupfor manual rollback; the diversion is listed viadpkg-divert --list. Note for existing deployments: NICs created by older builds keep theveth-name until their slot is recycled.--setup-hostalready requires root; on Debian,dpkg-divertis used if present (falls back to direct write otherwise); non-Debian hosts are skipped with a log line.Validation
make fmtmake clippymake test-unitmake -C services test(required whenservices/changes)maketarget (N/A — no schema/generated-code changes)docs/src/internals/networking.md)Commands and results:
Skipped checks and reasons:
make fmt/make clippy/make test-unitwere not run locally (development machine is Windows without a Rust toolchain; the project builds only on Linux). Behavioral verification was performed on the Linux test host as documented above.Risks and reviewer notes
/lib/udev/ifupdown-hotplug); mitigated by dpkg-divert registration, a one-time backup, and idempotent re-runs.bail!) rather than silently mispatching; the content check guards double-patching.ip linkshowsaenv-*); docs updated accordingly.src/setup/hotplug.rs(new),src/setup/mod.rs(wiring),src/sandbox/network/mod.rs(prefix constant),src/sandbox/network/manager.rs(test updates).Checklist
Testing notes: the prefix rename is covered by the existing unit tests in
src/sandbox/network/manager.rs(slot_index_from_host_veth_name_*), updatedfor
aenv-*. The hotplug patch operates on the distro-owned/lib/udev/ifupdown-hotplugand requires root plus the host's actualudev/ifupdown installation, so unit testing is impractical; it is verified
behaviorally after
--setup-hostby grepping the patched script and observingifquery counts during sandbox churn (see Validation).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.