Skip to content

Commit 6e66a35

Browse files
committed
reset err in resolveServingLocation() when the req can be served by local apiserver
1 parent 06fb818 commit 6e66a35

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

staging/src/k8s.io/apiserver/pkg/util/peerproxy/peerproxy_handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ func (h *peerProxyHandler) resolveServingLocation(apiservers *sync.Map) (bool, [
199199
apiserverKey := key.(string)
200200
if apiserverKey == h.serverId {
201201
locallyServiceable = true
202-
// stop iteration
202+
// stop iteration and reset any errors encountered so far.
203+
respErr = nil
203204
return false
204205
}
205206

staging/src/k8s.io/apiserver/pkg/util/peerproxy/peerproxy_handler_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,10 @@ func TestPeerProxy(t *testing.T) {
285285
}
286286
req.Header.Set(PeerProxiedHeader, tt.peerproxiedHeader)
287287

288-
resp, _ := requestGetter(req)
288+
resp, err := requestGetter(req)
289+
if err != nil {
290+
t.Fatalf("unexpected error trying to get the request: %v", err)
291+
}
289292

290293
// compare response
291294
assert.Equal(t, tt.expectedStatus, resp.StatusCode)

0 commit comments

Comments
 (0)