From 97336cd7cb659169e0e1b472f79ff1b561ee774b Mon Sep 17 00:00:00 2001 From: Euan Kemp Date: Wed, 2 Nov 2016 16:15:24 -0700 Subject: [PATCH] kubelet: don't print httplogs for redirects The new CRI exec implementation relies on this status code. Without this change, kubelet logs a scary stacktrace during normal execution. --- pkg/httplog/log_test.go | 14 ++++++++++++++ pkg/kubelet/server/server.go | 1 + 2 files changed, 15 insertions(+) diff --git a/pkg/httplog/log_test.go b/pkg/httplog/log_test.go index 57829299e7c..906ec367366 100644 --- a/pkg/httplog/log_test.go +++ b/pkg/httplog/log_test.go @@ -24,6 +24,20 @@ import ( "testing" ) +func TestDefaultStacktracePred(t *testing.T) { + for _, x := range []int{101, 200, 204, 302, 400, 404} { + if DefaultStacktracePred(x) { + t.Fatalf("should not log on %v by default", x) + } + } + + for _, x := range []int{500, 100} { + if !DefaultStacktracePred(x) { + t.Fatalf("should log on %v by default", x) + } + } +} + func TestHandler(t *testing.T) { want := &httptest.ResponseRecorder{ HeaderMap: make(http.Header), diff --git a/pkg/kubelet/server/server.go b/pkg/kubelet/server/server.go index ec609c0d050..ee95a223d78 100644 --- a/pkg/kubelet/server/server.go +++ b/pkg/kubelet/server/server.go @@ -675,6 +675,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) { defer httplog.NewLogged(req, &w).StacktraceWhen( httplog.StatusIsNot( http.StatusOK, + http.StatusFound, http.StatusMovedPermanently, http.StatusTemporaryRedirect, http.StatusBadRequest,