Harden CI test network cleanup; sweep orphaned iptables rules#285
Merged
Conversation
The Linux integration tests create per-bridge iptables FORWARD/NAT rules. On the shared self-hosted runner these leak: the test-harness cleanup called iptables without the -w lock-wait flag and ignored all errors, so under xtables-lock contention from concurrent CI jobs cleanup failed silently. Rules whose bridge interface no longer exists then accumulated indefinitely (cleanupStaleLinkDownRoutes only handles still-present linkdown routes), inflating every iptables operation over time and contributing to flaky "instance did not reach Running within 45s" timeouts. - Add -w 5 to all harness iptables calls (matches lib/network convention) - Surface cleanup errors to stderr instead of swallowing them; retry deletes on transient lock contention; treat already-gone routes/links as benign - Sweep orphaned test iptables rules (interface gone) once per test binary under the existing subnet lock, scoped to the "hm" test prefix so a non-test hypeman process's "ha" rules are never touched - Remove dead HYPEMAN_TEST_NETWORK_TMPDIR plumbing from test.yml (its Go reader was reverted in #268; re-wiring it would reintroduce per-run lock/lease isolation and break cross-run subnet coordination) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
hiroTamada
approved these changes
Jun 10, 2026
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.
Problem
Random flaky failures in the Linux
Testjob on the self-hosted runner (dev-deft) —instance did not reach Running within 45s,image should be ready after 60 seconds— across multiple unrelated branches simultaneously, i.e. environmental, not code.Root cause: the integration tests create per-bridge iptables FORWARD/NAT rules. The test-harness cleanup called
iptableswithout-wand ignored all errors, so under xtables-lock contention from concurrent CI jobs (11 runners on one host) cleanup failed silently. Rules for deleted bridges then leaked permanently (cleanupStaleLinkDownRoutesonly handles still-presentlinkdownroutes) — ~880 dead-bridge rules had accumulated over 7 days of host uptime, inflating every iptables op ~10x and worsening the-w 5lock-wait timeouts that trigger the boot failures.Note: the iptables leak is a slow-burn aggravator; the primary acute driver is burst concurrency on the shared host. Capping
Test-job concurrency is a separate follow-up.Changes
-w 5to all harness iptables calls (matcheslib/network/bridge_linux.go).hmtest prefix only, so a separate non-testhypemanprocess'sharules are never touched.HYPEMAN_TEST_NETWORK_TMPDIRplumbing fromtest.yml(its Go reader was reverted in Remove mailbox for now #268; re-wiring would reintroduce per-run lock/lease isolation and break cross-run subnet coordination).Testing
gofmt/vet/build pass. The integration tests require root+linux+network, so validating via CI on this branch (with a couple of re-runs to confirm the flakes subside). Host's accumulated orphans were already cleaned out-of-band.
🤖 Generated with Claude Code
Note
Medium Risk
Changes run privileged
iptables/ipcleanup on shared CI hosts; scope is limited tohmtest rules and error handling, but mistakes could affect host networking during tests.Overview
Hardens Linux integration test network teardown so leaked iptables rules stop piling up on the shared self-hosted runner and slowing every job under xtables lock contention.
The test harness now runs
iptableswith-w 5(same as productionbridge_linux.go), logs real cleanup failures to stderr instead of ignoring them, retries deletes on lock contention, and treats already-removed routes/links as benign. On first subnet allocation per test binary, it sweeps orphanedhm*test-harness rules inFORWARDandnat/POSTROUTINGwhen the referenced bridge no longer exists—without touchingha*production rules.CI drops the unused
HYPEMAN_TEST_NETWORK_TMPDIRsetup, env var, and/tmp/hm-net-*cleanup from.github/workflows/test.yml.Reviewed by Cursor Bugbot for commit 8989bc9. Bugbot is set up for automated code reviews on this repo. Configure here.