Fixes Controller Port Mapping Recovery#2503
Conversation
Fixes flaw in port mapping recovery that prevented recovery from functioning. Also handles recent changes to tcpListener naming conventions for config entity name prefixing and multikeylisteners. Signed-off-by: Christian Kruse <christian@c-kruse.com>
📝 WalkthroughWalkthroughAdds a ChangesPort mapping recovery fix and tests
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/qdr/port_mapping_test.go (1)
35-43: ⚡ Quick winAssert the recovered map without allocating on misses.
GetPortForKeymutates state by allocating a fresh port whenkeyis absent, so this helper can hide a failed recovery if the free-port allocator happens to return the expected port. Since this test is in packageqdr, checkmapping.mappingsdirectly.Proposed test helper change
func assertPortForKey(t *testing.T, mapping *PortMapping, key string, expected int) { t.Helper() - actual, err := mapping.GetPortForKey(key) - if err != nil { - t.Fatalf("GetPortForKey(%q) returned error: %v", key, err) + actual, ok := mapping.mappings[key] + if !ok { + t.Fatalf("RecoverPortMapping() did not recover key %q", key) } if actual != expected { - t.Fatalf("GetPortForKey(%q) = %d, want %d", key, actual, expected) + t.Fatalf("recovered port for key %q = %d, want %d", key, actual, expected) } }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 40a70e92-7d7b-4bef-8beb-3e5a6f5ee45e
📒 Files selected for processing (3)
internal/kube/site/bindings_test.gointernal/qdr/port_mapping.gointernal/qdr/port_mapping_test.go
nluaces
left a comment
There was a problem hiding this comment.
Tested in local:
- created listeners and checked their ports
- deleted one of them and restarted controller
- recreated the missing listener
- checked that the remaining listeners have the same ports
Fixes flaw in port mapping recovery that prevented recovery from functioning. Also handles recent changes to tcpListener naming conventions for config entity name prefixing and multikeylisteners.
Closes #2406
Summary by CodeRabbit
Tests
Refactor