diff --git a/pkg/nsx/endpoint.go b/pkg/nsx/endpoint.go index e5ad4895f..f33455842 100644 --- a/pkg/nsx/endpoint.go +++ b/pkg/nsx/endpoint.go @@ -141,6 +141,7 @@ func (ep *Endpoint) keepAlive() error { ep.setStatus(UP) return nil } + ep.setStatus(DOWN) log.Error(err, "failed to validate API cluster", "endpoint", ep.Host(), "healthy", a) return err } @@ -298,7 +299,7 @@ func (ep *Endpoint) createAuthSession(certProvider auth.ClientCertProvider, toke body, err := ioutil.ReadAll(resp.Body) defer resp.Body.Close() if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated { - err = fmt.Errorf("unexpected status code %d", resp.StatusCode) + err = fmt.Errorf("session creation failed, unexpected status code %d", resp.StatusCode) } if err != nil { log.Error(err, "session creation failed", "endpoint", u.Host, "statusCode", resp.StatusCode, "headerDate", resp.Header["Date"], "body", body) diff --git a/pkg/nsx/endpoint_test.go b/pkg/nsx/endpoint_test.go index dd8108616..33679fb94 100644 --- a/pkg/nsx/endpoint_test.go +++ b/pkg/nsx/endpoint_test.go @@ -144,7 +144,7 @@ func TestCreateAuthSession(t *testing.T) { err = ep.createAuthSession(nil, nil, "admin", "password", jar) mockObj.AssertCalled(t, "Host") mockObj.AssertCalled(t, "Scheme") - assert.Equal(err.Error(), "session creation failed for response error 403", "Auth should be failed") + assert.Equal(err.Error(), "session creation failed, unexpected status code 403", "Auth should be failed") err = ep.createAuthSession(nil, nil, "admin", "password", jar) assert.Equal(err.Error(), "no token in response", "Auth should be failed")