Commit 4245fd7b authored by Erik Wilson's avatar Erik Wilson

Return http.StatusOK instead of 0

parent 2fb411fc
...@@ -140,9 +140,9 @@ func servingKubeletCert(server *config.Control, keyFile string, auth nodePassBoo ...@@ -140,9 +140,9 @@ func servingKubeletCert(server *config.Control, keyFile string, auth nodePassBoo
return return
} }
nodeName, code, err := auth(req) nodeName, errCode, err := auth(req)
if err != nil || code != 0 { if err != nil {
sendError(err, resp, code) sendError(err, resp, errCode)
return return
} }
...@@ -188,9 +188,9 @@ func clientKubeletCert(server *config.Control, keyFile string, auth nodePassBoot ...@@ -188,9 +188,9 @@ func clientKubeletCert(server *config.Control, keyFile string, auth nodePassBoot
return return
} }
nodeName, code, err := auth(req) nodeName, errCode, err := auth(req)
if err != nil || code != 0 { if err != nil {
sendError(err, resp, code) sendError(err, resp, errCode)
return return
} }
...@@ -271,19 +271,19 @@ func serveStatic(urlPrefix, staticDir string) http.Handler { ...@@ -271,19 +271,19 @@ func serveStatic(urlPrefix, staticDir string) http.Handler {
} }
func sendError(err error, resp http.ResponseWriter, status ...int) { func sendError(err error, resp http.ResponseWriter, status ...int) {
code := http.StatusInternalServerError var code int
if len(status) == 1 && status[0] != 0 { if len(status) == 1 {
code = status[0] code = status[0]
} }
if err == nil { if code == 0 || code == http.StatusOK {
err = errors.New("unknown") code = http.StatusInternalServerError
} }
logrus.Error(err) logrus.Error(err)
resp.WriteHeader(code) resp.WriteHeader(code)
resp.Write([]byte(err.Error())) resp.Write([]byte(err.Error()))
} }
// nodePassBootstrapper returns a node name, http code, and error // nodePassBootstrapper returns a node name, or http error code and error
type nodePassBootstrapper func(req *http.Request) (string, int, error) type nodePassBootstrapper func(req *http.Request) (string, int, error)
func passwordBootstrap(ctx context.Context, config *Config) nodePassBootstrapper { func passwordBootstrap(ctx context.Context, config *Config) nodePassBootstrapper {
...@@ -314,7 +314,7 @@ func passwordBootstrap(ctx context.Context, config *Config) nodePassBootstrapper ...@@ -314,7 +314,7 @@ func passwordBootstrap(ctx context.Context, config *Config) nodePassBootstrapper
return "", http.StatusForbidden, err return "", http.StatusForbidden, err
} }
return nodeName, 0, nil return nodeName, http.StatusOK, nil
}) })
} }
...@@ -361,5 +361,5 @@ func verifyLocalPassword(ctx context.Context, config *Config, once *sync.Once, n ...@@ -361,5 +361,5 @@ func verifyLocalPassword(ctx context.Context, config *Config, once *sync.Once, n
logrus.Debugf("password verified locally for node '%s'", nodeName) logrus.Debugf("password verified locally for node '%s'", nodeName)
return nodeName, 0, nil return nodeName, http.StatusOK, nil
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment