aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2023-10-23 10:35:38 +0200
committerMartin Polden <mpolden@mpolden.no>2023-10-23 10:35:38 +0200
commit1f1d04f10b39217e280f4ea3f8866a8becda8e5a (patch)
tree1bd0c7ea3848f3426db3e18022d6ccb4221df0f2 /client
parent872ac4c6f6f360c1934af0028f7bfb05b14ab300 (diff)
Use unauthenticated path for CLI health check
Diffstat (limited to 'client')
-rw-r--r--client/go/internal/cli/cmd/status_test.go14
-rw-r--r--client/go/internal/vespa/target.go8
-rw-r--r--client/go/internal/vespa/target_test.go6
3 files changed, 12 insertions, 16 deletions
diff --git a/client/go/internal/cli/cmd/status_test.go b/client/go/internal/cli/cmd/status_test.go
index 1e6c3230db3..394a0cd4ac4 100644
--- a/client/go/internal/cli/cmd/status_test.go
+++ b/client/go/internal/cli/cmd/status_test.go
@@ -60,7 +60,7 @@ func TestStatusCommandMultiClusterWait(t *testing.T) {
client.NextStatus(400)
assert.NotNil(t, cli.Run("status", "--cluster", "foo", "--wait", "10"))
assert.Equal(t, "Waiting up to 10s for cluster discovery...\nWaiting up to 10s for container foo...\n"+
- "Error: unhealthy container foo after waiting up to 10s: status 400 at http://127.0.0.1:8080/ApplicationStatus: aborting wait: got status 400\n", stderr.String())
+ "Error: unhealthy container foo after waiting up to 10s: status 400 at http://127.0.0.1:8080/status.html: aborting wait: got status 400\n", stderr.String())
}
func TestStatusCommandWithUrlTarget(t *testing.T) {
@@ -79,14 +79,14 @@ func TestStatusError(t *testing.T) {
cli.httpClient = client
assert.NotNil(t, cli.Run("status", "container"))
assert.Equal(t,
- "Error: unhealthy container default: status 500 at http://127.0.0.1:8080/ApplicationStatus: wait timed out\n",
+ "Error: unhealthy container default: status 500 at http://127.0.0.1:8080/status.html: wait timed out\n",
stderr.String())
stderr.Reset()
client.NextResponseError(io.EOF)
assert.NotNil(t, cli.Run("status", "container", "-t", "http://example.com"))
assert.Equal(t,
- "Error: unhealthy container at http://example.com/ApplicationStatus: EOF\n",
+ "Error: unhealthy container at http://example.com/status.html: EOF\n",
stderr.String())
}
@@ -189,7 +189,7 @@ func assertStatus(expectedTarget string, args []string, t *testing.T) {
clusterName = "foo"
mockServiceStatus(client, clusterName)
}
- client.NextResponse(mock.HTTPResponse{URI: "/ApplicationStatus", Status: 200})
+ client.NextResponse(mock.HTTPResponse{URI: "/status.html", Status: 200})
}
cli, stdout, _ := newTestCLI(t)
cli.httpClient = client
@@ -200,14 +200,14 @@ func assertStatus(expectedTarget string, args []string, t *testing.T) {
prefix += " " + clusterName
}
assert.Equal(t, prefix+" at "+expectedTarget+" is ready\n", stdout.String())
- assert.Equal(t, expectedTarget+"/ApplicationStatus", client.LastRequest.URL.String())
+ assert.Equal(t, expectedTarget+"/status.html", client.LastRequest.URL.String())
// Test legacy command
statusArgs = []string{"status query"}
stdout.Reset()
assert.Nil(t, cli.Run(append(statusArgs, args...)...))
assert.Equal(t, prefix+" at "+expectedTarget+" is ready\n", stdout.String())
- assert.Equal(t, expectedTarget+"/ApplicationStatus", client.LastRequest.URL.String())
+ assert.Equal(t, expectedTarget+"/status.html", client.LastRequest.URL.String())
}
func assertDocumentStatus(target string, args []string, t *testing.T) {
@@ -223,5 +223,5 @@ func assertDocumentStatus(target string, args []string, t *testing.T) {
"Container (document API) at "+target+" is ready\n",
stdout.String(),
"vespa status container")
- assert.Equal(t, target+"/ApplicationStatus", client.LastRequest.URL.String())
+ assert.Equal(t, target+"/status.html", client.LastRequest.URL.String())
}
diff --git a/client/go/internal/vespa/target.go b/client/go/internal/vespa/target.go
index 662e7383f97..5b29990fe4e 100644
--- a/client/go/internal/vespa/target.go
+++ b/client/go/internal/vespa/target.go
@@ -125,12 +125,8 @@ func (s *Service) SetClient(client util.HTTPClient) { s.httpClient = client }
// Wait polls the health check of this service until it succeeds or timeout passes.
func (s *Service) Wait(timeout time.Duration) error {
- url := s.BaseURL
- if s.deployAPI {
- url += "/status.html" // because /ApplicationStatus is not publicly reachable in Vespa Cloud
- } else {
- url += "/ApplicationStatus"
- }
+ // A path that does not need authentication, on any target
+ url := strings.TrimRight(s.BaseURL, "/") + "/status.html"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return err
diff --git a/client/go/internal/vespa/target_test.go b/client/go/internal/vespa/target_test.go
index 25e38a30151..4c2fda8368e 100644
--- a/client/go/internal/vespa/target_test.go
+++ b/client/go/internal/vespa/target_test.go
@@ -88,7 +88,7 @@ func TestCustomTargetWait(t *testing.T) {
client.NextResponseError(io.EOF)
}
// Then succeeds
- client.NextResponse(mock.HTTPResponse{URI: "/ApplicationStatus", Status: 200})
+ client.NextResponse(mock.HTTPResponse{URI: "/status.html", Status: 200})
assertService(t, false, target, "", time.Second)
}
@@ -153,10 +153,10 @@ func TestCloudTargetWait(t *testing.T) {
assert.Equal(t, 2, len(services))
client.NextResponse(response)
- client.NextResponse(mock.HTTPResponse{URI: "/ApplicationStatus", Status: 500})
+ client.NextResponse(mock.HTTPResponse{URI: "/status.html", Status: 500})
assertService(t, true, target, "default", 0)
client.NextResponse(response)
- client.NextResponse(mock.HTTPResponse{URI: "/ApplicationStatus", Status: 200})
+ client.NextResponse(mock.HTTPResponse{URI: "/status.html", Status: 200})
assertService(t, false, target, "feed", 0)
}