diff --git a/helm/gke-metadata-server/Chart.yaml b/helm/gke-metadata-server/Chart.yaml index 5f48cda..6f75db8 100644 --- a/helm/gke-metadata-server/Chart.yaml +++ b/helm/gke-metadata-server/Chart.yaml @@ -30,10 +30,10 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.5.1 +version: 0.5.2 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "0.5.1" +appVersion: "0.5.2" diff --git a/internal/pods/watch/provider.go b/internal/pods/watch/provider.go index ca923e7..b849146 100644 --- a/internal/pods/watch/provider.go +++ b/internal/pods/watch/provider.go @@ -157,16 +157,22 @@ func (p *Provider) getByIP(ctx context.Context, ipAddr string) (*corev1.Pod, err if err != nil { return nil, fmt.Errorf("error getting pod from cache by ip address %q: %w", ipAddr, err) } - if n := len(v); n != 1 { + var podsMatchingIP []*corev1.Pod + for _, p := range v { + pod := p.(*corev1.Pod) + if pod.Status.PodIP == ipAddr { + podsMatchingIP = append(podsMatchingIP, pod) + } + } + if n := len(podsMatchingIP); n != 1 { refs := make([]string, n) - for i, p := range v { - pod := p.(*corev1.Pod) + for i, pod := range podsMatchingIP { refs[i] = fmt.Sprintf("%s/%s", pod.Namespace, pod.Name) } return nil, fmt.Errorf("error getting pod from cache by ip address %q: %v pods found instead of 1 [%s]", ipAddr, n, strings.Join(refs, ", ")) } - return v[0].(*corev1.Pod), nil + return podsMatchingIP[0], nil } func (p *Provider) Start(ctx context.Context) {