Fix PodRemoved events missing LocalPort field#322
Merged
Conversation
The TUI state store uses a key of `ServiceKey.PodName.LocalPort` for both adding and removing entries. However, PodRemoved events were not setting the LocalPort field, causing the removal key to be different from the add key (e.g., "svc.ns.ctx.pod." instead of "svc.ns.ctx.pod.80"). This caused duplicate entries to accumulate in the TUI because old entries were never being removed. Fixed by setting event.LocalPort = pfo.LocalPort on all PodRemoved events. Added test assertion to verify LocalPort is set. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #322 +/- ##
==========================================
+ Coverage 59.36% 59.42% +0.05%
==========================================
Files 38 38
Lines 4312 4318 +6
==========================================
+ Hits 2560 2566 +6
- Misses 1619 1620 +1
+ Partials 133 132 -1
🚀 New features to boost your workflow:
|
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.
Description
The TUI state store uses a key of
ServiceKey.PodName.LocalPortfor both adding and removing entries. However, PodRemoved events were not setting the LocalPort field, causing the removal key to be different from the add key (e.g., "svc.ns.ctx.pod." instead of "svc.ns.ctx.pod.80").This caused duplicate entries to accumulate in the TUI because old entries were never being removed.
Fixed by setting
event.LocalPort = pfo.LocalPorton all PodRemoved events. Added test assertion to verify LocalPort is set.Type of Change
Related Issues
Fixes duplicate TUI entries when pods are killed/recreated with auto-reconnect enabled.
Testing
go test ./...locallyManual test:
sudo -E ./kubefwd svc -n kft1,kft2 -a --tuikubectl delete pod <pod-name> -n kft1Checklist
go fmt,go vet)Screenshots/Logs (if applicable)
Before fix: Old entries accumulated because removal key didn't match:
After fix: Old entry removed, only new entry remains.