Skip to content

faults/network: add network partition fault - #8

Open
alexmchughdev wants to merge 1 commit into
mainfrom
phase2/network-partition
Open

alexmchughdev wants to merge 1 commit into
mainfrom
phase2/network-partition

Conversation

@alexmchughdev

Copy link
Copy Markdown
Owner

Summary

Stage 2 of Phase 2 (v0.2.0). Third network fault, first iptables-based
one. Introduces:

  • ADR-0003 documenting the iptables backend choice and the
    chain-per-fault isolation pattern. Per-fault chain
    (SCORPIUS_PART_<8hex>) holds all DROP rules; jumps are inserted
    into the default chains. Revert never touches user rules.
  • internal/faults/network/iptables.go — IPTables interface and
    execIPTables impl, parallel in shape to the existing TC
    abstraction. Every invocation passes -w 5 so we wait politely
    for the xtables lock.
  • internal/faults/network/partition.go — Partition fault. Apply
    is fully transactional: any failure mid-build rolls back the
    partial chain and any jumps already installed.
  • Unit tests with a fake IPTables that records every call, covering
    validation, rollback paths, idempotent revert, leftover-chain
    detection, and the watchdog heartbeat.
  • Integration tests gated on //go:build integration that exercise
    a real iptables against TEST-NET-1 (192.0.2.0/24, RFC 5737) so
    the rules cannot affect anything real even if they leak.

CLI: scorpius inject network-partition --address <ipv4-or-cidr> [--protocol tcp|udp|icmp] [--port N] [--direction in|out|both].

IPv4 only in v0.2.0; ip6tables parity is a v1.0 hardening item.

Test plan

  • go vet ./...
  • go build -tags integration ./...
  • go test -race -count=1 ./... (unit suite, all green)
  • sudo go test -race -count=1 -tags integration ./internal/faults/network/ on a host with iptables (uses 192.0.2.x targets so safe to run anywhere; expected post-merge before tagging v0.2.0)
  • End-to-end CLI dry-run smoke test against the built binary, both with port/protocol and with bare CIDR

Third network fault for Phase 2. iptables-based, not netem-based, so
this introduces an IPTables abstraction (parallel to TC) and a per-fault
chain isolation pattern documented in ADR-0003.

Each partition Apply creates a dedicated SCORPIUS_PART_<8hex> chain,
populates DROP rules, and inserts jumps from OUTPUT and/or INPUT.
Revert deletes the jumps, flushes, and deletes the chain. The agent
never reads or modifies user-installed rules, so revert is
unconditional and Verify is meaningful.

Address takes an IPv4 host or CIDR (IPv6 is a Phase 6 item). Optional
parameters: direction (in/out/both, default both), protocol (tcp/udp/
icmp), and port. Port requires tcp or udp protocol.

CLI: scorpius inject network-partition --address ... [--protocol ...]
[--port ...] [--direction ...] plus the shared duration/audit/
watchdog flags. iptables invocations all pass -w 5 to wait on the
xtables lock instead of failing fast under contention.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant