Skip to content

Fix PodRemoved events missing LocalPort field#322

Merged
cjimti merged 1 commit intomasterfrom
fix/pod-removed-localport
Dec 27, 2025
Merged

Fix PodRemoved events missing LocalPort field#322
cjimti merged 1 commit intomasterfrom
fix/pod-removed-localport

Conversation

@cjimti
Copy link
Copy Markdown
Member

@cjimti cjimti commented Dec 27, 2025

Description

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.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Test improvement (new or updated tests)
  • Documentation update
  • Stability/performance improvement
  • Build/CI improvement

Note: New features are developed by maintainers only. See CONTRIBUTING.md for details.

Related Issues

Fixes duplicate TUI entries when pods are killed/recreated with auto-reconnect enabled.

Testing

  • Ran go test ./... locally
  • Tested manually with a Kubernetes cluster
  • Added new tests for changes (if applicable)

Manual test:

  1. Run sudo -E ./kubefwd svc -n kft1,kft2 -a --tui
  2. Kill a pod: kubectl delete pod <pod-name> -n kft1
  3. Observe old entry is removed and new entry appears (no duplicates)

Checklist

  • My code follows the project's style guidelines (go fmt, go vet)
  • I have read CONTRIBUTING.md
  • I have updated documentation if needed
  • This PR is focused and does not include unrelated changes

Screenshots/Logs (if applicable)

Before fix: Old entries accumulated because removal key didn't match:

api-gateway    80    kft1    Active    0 B
api-gateway    80    kft1    Active    1.2 KB  (duplicate!)

After fix: Old entry removed, only new entry remains.

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>
@cjimti cjimti self-assigned this Dec 27, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 27, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.42%. Comparing base (8cf39f2) to head (c4a05ed).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
pkg/fwdservice/fwdservice.go 66.66% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
pkg/fwdservice/fwdservice.go 74.78% <66.66%> (-0.15%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cjimti cjimti merged commit 0174c41 into master Dec 27, 2025
10 checks passed
@cjimti cjimti deleted the fix/pod-removed-localport branch December 29, 2025 23:47
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