fix(backend): clean stale forward runtimes on entry updates (#307)

Entire-Checkpoint: 6a6b91fb5f0c
This commit is contained in:
sagit
2026-03-11 13:53:31 +08:00
committed by GitHub
parent e8bfe52104
commit 69faeaa9a6
5 changed files with 502 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
# 029 - Issue 281 Contract Repro
## Goal
Add a contract test that reproduces issue #281: after changing a tunnel's entry node, forward runtime cleanup does not remove the stale service from the old entry node.
## Checklist
- [x] Review existing contract test helpers for mock node command recording.
- [x] Add a contract test that updates a tunnel entry node while a forward is bound to the tunnel.
- [x] Assert the new entry node receives forward sync commands and the old entry node does not receive forward cleanup, reproducing the bug.
- [x] Run the focused contract test and capture the failure.
## Test Record
- Command: `cd go-backend && go test ./tests/contract/... -run TestTunnelUpdateChangesEntryNodeButLeavesOldForwardRuntimeContract`
- Result: failed as expected with `expected old entry node to receive forward DeleteService cleanup for 1_2_281, got none`.
@@ -0,0 +1,14 @@
# 030 - Fix Issue 281 Stale Forward Runtime Cleanup
## Goal
When a tunnel's entry nodes change, remove forward runtime services from entry nodes that are no longer part of the tunnel before syncing the forward to its new entry nodes.
## Checklist
- [x] Review the tunnel update flow and identify where old/new entry node sets are available.
- [x] Add backend cleanup for forward runtimes on removed entry nodes.
- [x] Keep existing forward port rebuild and forward resync behavior intact.
- [x] Run focused contract regression tests for the issue 281 repro.
## Test Record
- Command: `cd go-backend && go test ./tests/contract/... -run 'TestTunnelUpdateChangesEntryNodeButLeavesOldForwardRuntimeContract|TestTunnelUpdateRecoversFromAddressInUseContract'`
- Result: passed.
@@ -0,0 +1,14 @@
# 031 - Entry Transition Regression Coverage
## Goal
Expand issue #281 regression coverage to verify forward runtime cleanup and `forward_port` rebuilding across both single-entry to multi-entry and multi-entry to single-entry tunnel updates.
## Checklist
- [x] Review the current issue 281 contract repro and reuse its mock-node recording helpers.
- [x] Add a broader contract test that exercises both entry transition directions.
- [x] Assert removed entry nodes receive forward cleanup and retained/new entry nodes receive forward sync.
- [x] Run focused contract tests and record the result.
## Test Record
- Command: `cd go-backend && go test ./tests/contract/... -run 'TestTunnelUpdateChangesEntryNodeButLeavesOldForwardRuntimeContract|TestTunnelUpdateEntryTransitionsCleanupForwardRuntimeContract|TestTunnelUpdateRecoversFromAddressInUseContract'`
- Result: passed.