From 8d48c1801aeedb143834a012390b55dabdcf52e3 Mon Sep 17 00:00:00 2001 From: Tyler Lloyd Date: Thu, 3 Apr 2025 18:52:37 -0400 Subject: [PATCH 1/2] fix: do not return a StripPrefix handler when building checker already doing the strip prefix https://github.com/tyler-lloyd/azure-container-networking/blob/40b6c443d62321ee61c134bf6573ed2de9813d50/cns/healthserver/server.go#L15 so doing it inside check builder is redunant and causes the /healthz endpoint to return a 404 --- cns/healthserver/healthz.go | 4 ++-- cns/healthserver/healthz_test.go | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cns/healthserver/healthz.go b/cns/healthserver/healthz.go index 45bc2f303c..d3336e5345 100644 --- a/cns/healthserver/healthz.go +++ b/cns/healthserver/healthz.go @@ -55,7 +55,7 @@ func NewHealthzHandlerWithChecks(cnsConfig *configuration.CNSConfig) (http.Handl // strip prefix so that it runs through all checks registered on the handler. // otherwise it will look for a check named "healthz" and return a 404 if not there. - return http.StripPrefix("/healthz", &healthz.Handler{ + return &healthz.Handler{ Checks: checks, - }), nil + }, nil } diff --git a/cns/healthserver/healthz_test.go b/cns/healthserver/healthz_test.go index 805509a1f4..fa943ed74f 100644 --- a/cns/healthserver/healthz_test.go +++ b/cns/healthserver/healthz_test.go @@ -198,6 +198,7 @@ func TestNewHealthzHandlerWithChecks(t *testing.T) { responseRecorder := httptest.NewRecorder() healthHandler, err := NewHealthzHandlerWithChecks(tt.cnsConfig) + healthHandler = http.StripPrefix("/healthz", healthHandler) require.NoError(t, err) healthHandler.ServeHTTP(responseRecorder, httptest.NewRequest("GET", "/healthz", http.NoBody)) From fe629448038cdef18f93ff12400d29bffa606009 Mon Sep 17 00:00:00 2001 From: Tyler Lloyd Date: Thu, 3 Apr 2025 18:54:34 -0400 Subject: [PATCH 2/2] chore: tabs --- cns/healthserver/healthz_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cns/healthserver/healthz_test.go b/cns/healthserver/healthz_test.go index fa943ed74f..8b6e55df3e 100644 --- a/cns/healthserver/healthz_test.go +++ b/cns/healthserver/healthz_test.go @@ -198,7 +198,7 @@ func TestNewHealthzHandlerWithChecks(t *testing.T) { responseRecorder := httptest.NewRecorder() healthHandler, err := NewHealthzHandlerWithChecks(tt.cnsConfig) - healthHandler = http.StripPrefix("/healthz", healthHandler) + healthHandler = http.StripPrefix("/healthz", healthHandler) require.NoError(t, err) healthHandler.ServeHTTP(responseRecorder, httptest.NewRequest("GET", "/healthz", http.NoBody))