fix: resolve named targetPort for port-forwarding#3
Merged
Conversation
Port-forwarding was using the service port (e.g. 9090) instead of the actual container port. When a service defines targetPort as a named port (e.g. "http"), the old code fell back to the service port because IntValue() returned 0 for string ports. Replace FindPodForService + StartPortForward with a single PortForwardToService that: 1. Fetches the service to get the full ServicePort spec 2. Finds a running pod via the service selector 3. Resolves targetPort: int → use directly, named string → look up in pod container ports, unset → default to service port 4. Opens the SPDY tunnel to the resolved container port
Verify credentials at provider creation instead of failing on the first API call with a cryptic IMDS timeout. The error message now tells the user exactly what to do: set AWS_PROFILE, run aws sso login, or configure ~/.aws/credentials.
96756f3 to
f1a7fb3
Compare
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.
Summary
targetPortis a named port like"http",IntValue()returns 0 and we fell back to the service port — but the pod doesn't listen thereFindPodForService+StartPortForwardwith a singlePortForwardToServicethat resolves named ports by looking at the pod's container specRoot cause
Test plan
TestResolveTargetPortInt— numeric targetPortTestResolveTargetPortNamed— string targetPort resolved from podTestResolveTargetPortNamedNotFound— fallback to service portTestResolveTargetPortUnset— defaults to service port./bin/clusterfit recommend --discover --verbose— 884 workloads collected successfully