From 29e668357a8e1ce28afdbeb9b080b7f13914710e Mon Sep 17 00:00:00 2001 From: Alex Leong Date: Thu, 26 Oct 2023 21:52:30 +0000 Subject: [PATCH 1/2] Return NotFound for unknown pod names Signed-off-by: Alex Leong --- controller/api/destination/watcher/pod_watcher.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/api/destination/watcher/pod_watcher.go b/controller/api/destination/watcher/pod_watcher.go index b4099b2920e31..dfcb289aa0fb7 100644 --- a/controller/api/destination/watcher/pod_watcher.go +++ b/controller/api/destination/watcher/pod_watcher.go @@ -399,7 +399,7 @@ func (pw *PodWatcher) getEndpointByHostname(hostname string, svcID *ServiceID) ( } } - return nil, fmt.Errorf("no pod found in Endpoints %s/%s for hostname %s", svcID.Namespace, svcID.Name, hostname) + return nil, status.Errorf(codes.NotFound, "no pod found in Endpoints %s/%s for hostname %s", svcID.Namespace, svcID.Name, hostname) } func (pp *podPublisher) subscribe(listener PodUpdateListener) { From b7d1e01cdf579b7c2cfdc744c00d7fe4edb6cfb5 Mon Sep 17 00:00:00 2001 From: Alex Leong Date: Fri, 27 Oct 2023 17:15:56 +0000 Subject: [PATCH 2/2] remove multiple layers of error formatting Signed-off-by: Alex Leong --- controller/api/destination/watcher/pod_watcher.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/api/destination/watcher/pod_watcher.go b/controller/api/destination/watcher/pod_watcher.go index dfcb289aa0fb7..b4b6894550c41 100644 --- a/controller/api/destination/watcher/pod_watcher.go +++ b/controller/api/destination/watcher/pod_watcher.go @@ -277,7 +277,7 @@ func (pw *PodWatcher) getOrNewPodPublisher(service *ServiceID, hostname, ip stri if hostname != "" { pod, err = pw.getEndpointByHostname(hostname, service) if err != nil { - return nil, fmt.Errorf("failed to get pod for hostname %s: %w", hostname, err) + return nil, err } ip = pod.Status.PodIP } else {