diff --git a/test/images/agnhost/VERSION b/test/images/agnhost/VERSION index d920eceb60435..2a43146444b26 100644 --- a/test/images/agnhost/VERSION +++ b/test/images/agnhost/VERSION @@ -1 +1 @@ -2.41 +2.42 diff --git a/test/images/agnhost/no-snat-test-proxy/main.go b/test/images/agnhost/no-snat-test-proxy/main.go index c5b16718faf67..5d30116f4ca25 100644 --- a/test/images/agnhost/no-snat-test-proxy/main.go +++ b/test/images/agnhost/no-snat-test-proxy/main.go @@ -79,16 +79,18 @@ func checknosnat(w http.ResponseWriter, req *http.Request) { if err != nil { w.WriteHeader(500) fmt.Fprintf(w, "error querying %q, err: %v", url, err) - } else { - body, err := io.ReadAll(resp.Body) - if err != nil { - w.WriteHeader(500) - fmt.Fprintf(w, "error reading body of response from %q, err: %v", url, err) - } else { - // Respond the same status code and body as /checknosnat on the internal Pod - w.WriteHeader(resp.StatusCode) - w.Write(body) - } + return } - resp.Body.Close() + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + w.WriteHeader(500) + fmt.Fprintf(w, "error reading body of response from %q, err: %v", url, err) + return + } + + // Respond the same status code and body as /checknosnat on the internal Pod + w.WriteHeader(resp.StatusCode) + w.Write(body) }