From 138ff96c005f4d0e67a3218fbfe0aa757c058e68 Mon Sep 17 00:00:00 2001
From: Eric Chiang <eric.chiang@coreos.com>
Date: Sun, 23 Oct 2016 07:42:42 -0700
Subject: [PATCH] storage/kubernetes: don't automatically print errors on bad
 HTTP status codes

These status codes spam the error logs for events like key rotation
and third party resource creation. In these cases "bad" status codes
are expected and shouldn't be automatically printed.
---
 storage/kubernetes/client.go | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/storage/kubernetes/client.go b/storage/kubernetes/client.go
index bfdc9151..9b5dd577 100644
--- a/storage/kubernetes/client.go
+++ b/storage/kubernetes/client.go
@@ -10,7 +10,6 @@ import (
 	"fmt"
 	"io"
 	"io/ioutil"
-	"log"
 	"net"
 	"net/http"
 	"os"
@@ -95,18 +94,17 @@ func checkHTTPErr(r *http.Response, validStatusCodes ...int) error {
 		return fmt.Errorf("read response body: %v", err)
 	}
 
+	// Check this case after we read the body so the connection can be reused.
+	if r.StatusCode == http.StatusNotFound {
+		return storage.ErrNotFound
+	}
+
 	var url, method string
 	if r.Request != nil {
 		method = r.Request.Method
 		url = r.Request.URL.String()
 	}
-	err = &httpErr{method, url, r.StatusCode, body}
-	log.Printf("%s", err)
-
-	if r.StatusCode == http.StatusNotFound {
-		return storage.ErrNotFound
-	}
-	return err
+	return &httpErr{method, url, r.StatusCode, body}
 }
 
 // Close the response body. The initial request is drained so the connection can
-- 
GitLab