diff options
Diffstat (limited to 'client/go/internal/vespa')
40 files changed, 53 insertions, 34 deletions
diff --git a/client/go/internal/vespa/application.go b/client/go/internal/vespa/application.go index 29ae0c4b959..cb43578af32 100644 --- a/client/go/internal/vespa/application.go +++ b/client/go/internal/vespa/application.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package vespa import ( diff --git a/client/go/internal/vespa/crypto.go b/client/go/internal/vespa/crypto.go index 5e273538869..13d3ac570cc 100644 --- a/client/go/internal/vespa/crypto.go +++ b/client/go/internal/vespa/crypto.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package vespa import ( diff --git a/client/go/internal/vespa/crypto_test.go b/client/go/internal/vespa/crypto_test.go index 89d50d15d70..6fa2f8218db 100644 --- a/client/go/internal/vespa/crypto_test.go +++ b/client/go/internal/vespa/crypto_test.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package vespa import ( diff --git a/client/go/internal/vespa/deploy.go b/client/go/internal/vespa/deploy.go index d42c65cef1e..b39c51916e7 100644 --- a/client/go/internal/vespa/deploy.go +++ b/client/go/internal/vespa/deploy.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. // vespa deploy API // Author: bratseth diff --git a/client/go/internal/vespa/deploy_test.go b/client/go/internal/vespa/deploy_test.go index ff278578e8a..d1dffe0f6d6 100644 --- a/client/go/internal/vespa/deploy_test.go +++ b/client/go/internal/vespa/deploy_test.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package vespa import ( diff --git a/client/go/internal/vespa/detect_hostname.go b/client/go/internal/vespa/detect_hostname.go index 9729fd80400..e6b2d113ec1 100644 --- a/client/go/internal/vespa/detect_hostname.go +++ b/client/go/internal/vespa/detect_hostname.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. // Author: arnej package vespa diff --git a/client/go/internal/vespa/detect_hostname_test.go b/client/go/internal/vespa/detect_hostname_test.go index 26b3095dbf6..3a423f50986 100644 --- a/client/go/internal/vespa/detect_hostname_test.go +++ b/client/go/internal/vespa/detect_hostname_test.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package vespa import ( diff --git a/client/go/internal/vespa/document/circuit_breaker.go b/client/go/internal/vespa/document/circuit_breaker.go index 9bcf2e3f619..7a1d2a37b40 100644 --- a/client/go/internal/vespa/document/circuit_breaker.go +++ b/client/go/internal/vespa/document/circuit_breaker.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package document import ( diff --git a/client/go/internal/vespa/document/circuit_breaker_test.go b/client/go/internal/vespa/document/circuit_breaker_test.go index 05dbd6da2f5..b7653759dab 100644 --- a/client/go/internal/vespa/document/circuit_breaker_test.go +++ b/client/go/internal/vespa/document/circuit_breaker_test.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package document import ( diff --git a/client/go/internal/vespa/document/dispatcher.go b/client/go/internal/vespa/document/dispatcher.go index 2a492fe91dd..153631a8f5e 100644 --- a/client/go/internal/vespa/document/dispatcher.go +++ b/client/go/internal/vespa/document/dispatcher.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package document import ( diff --git a/client/go/internal/vespa/document/dispatcher_test.go b/client/go/internal/vespa/document/dispatcher_test.go index 834ec8490a6..4c52bd759d9 100644 --- a/client/go/internal/vespa/document/dispatcher_test.go +++ b/client/go/internal/vespa/document/dispatcher_test.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package document import ( diff --git a/client/go/internal/vespa/document/document.go b/client/go/internal/vespa/document/document.go index a9b184190fb..e2a77f7b126 100644 --- a/client/go/internal/vespa/document/document.go +++ b/client/go/internal/vespa/document/document.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package document import ( diff --git a/client/go/internal/vespa/document/document_test.go b/client/go/internal/vespa/document/document_test.go index d37febf3da8..3fcdbd3b292 100644 --- a/client/go/internal/vespa/document/document_test.go +++ b/client/go/internal/vespa/document/document_test.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package document import ( diff --git a/client/go/internal/vespa/document/http.go b/client/go/internal/vespa/document/http.go index a2e399549c4..f878938d6fc 100644 --- a/client/go/internal/vespa/document/http.go +++ b/client/go/internal/vespa/document/http.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package document import ( diff --git a/client/go/internal/vespa/document/http_test.go b/client/go/internal/vespa/document/http_test.go index 6faa14705f0..57c663d6f4c 100644 --- a/client/go/internal/vespa/document/http_test.go +++ b/client/go/internal/vespa/document/http_test.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package document import ( diff --git a/client/go/internal/vespa/document/queue.go b/client/go/internal/vespa/document/queue.go index eed5209ca9e..b5dd8459e20 100644 --- a/client/go/internal/vespa/document/queue.go +++ b/client/go/internal/vespa/document/queue.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package document import ( diff --git a/client/go/internal/vespa/document/queue_test.go b/client/go/internal/vespa/document/queue_test.go index f2bdf416570..448356c7449 100644 --- a/client/go/internal/vespa/document/queue_test.go +++ b/client/go/internal/vespa/document/queue_test.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package document import ( diff --git a/client/go/internal/vespa/document/stats.go b/client/go/internal/vespa/document/stats.go index e53d787cd01..82630b4af1c 100644 --- a/client/go/internal/vespa/document/stats.go +++ b/client/go/internal/vespa/document/stats.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package document import ( diff --git a/client/go/internal/vespa/document/stats_test.go b/client/go/internal/vespa/document/stats_test.go index 8788836f9ad..c9b80878b75 100644 --- a/client/go/internal/vespa/document/stats_test.go +++ b/client/go/internal/vespa/document/stats_test.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package document import ( diff --git a/client/go/internal/vespa/document/throttler.go b/client/go/internal/vespa/document/throttler.go index e32fb804b23..39900156563 100644 --- a/client/go/internal/vespa/document/throttler.go +++ b/client/go/internal/vespa/document/throttler.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package document import ( diff --git a/client/go/internal/vespa/document/throttler_test.go b/client/go/internal/vespa/document/throttler_test.go index a22f059207f..03f0bc75bdc 100644 --- a/client/go/internal/vespa/document/throttler_test.go +++ b/client/go/internal/vespa/document/throttler_test.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package document import ( diff --git a/client/go/internal/vespa/find_home.go b/client/go/internal/vespa/find_home.go index 89b5f5a7e21..46dcdedd71c 100644 --- a/client/go/internal/vespa/find_home.go +++ b/client/go/internal/vespa/find_home.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. // get or find VESPA_HOME // Author: arnej diff --git a/client/go/internal/vespa/find_user.go b/client/go/internal/vespa/find_user.go index 8385e5e1e71..b572f3bc4c1 100644 --- a/client/go/internal/vespa/find_user.go +++ b/client/go/internal/vespa/find_user.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. // load default environment variables (from $VESPA_HOME/conf/vespa/default-env.txt) // Author: arnej diff --git a/client/go/internal/vespa/find_user_test.go b/client/go/internal/vespa/find_user_test.go index 484a9a9cc2c..4dbc97ba1c5 100644 --- a/client/go/internal/vespa/find_user_test.go +++ b/client/go/internal/vespa/find_user_test.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package vespa import ( diff --git a/client/go/internal/vespa/id.go b/client/go/internal/vespa/id.go index b0dc770ad52..0131043abbe 100644 --- a/client/go/internal/vespa/id.go +++ b/client/go/internal/vespa/id.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. // vespa document ids // Author: bratseth diff --git a/client/go/internal/vespa/id_test.go b/client/go/internal/vespa/id_test.go index 343affc1602..8343332e841 100644 --- a/client/go/internal/vespa/id_test.go +++ b/client/go/internal/vespa/id_test.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package vespa import ( diff --git a/client/go/internal/vespa/load_env.go b/client/go/internal/vespa/load_env.go index 87d60738366..f98d09fb197 100644 --- a/client/go/internal/vespa/load_env.go +++ b/client/go/internal/vespa/load_env.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. // load default environment variables (from $VESPA_HOME/conf/vespa/default-env.txt) // Author: arnej diff --git a/client/go/internal/vespa/load_env_test.go b/client/go/internal/vespa/load_env_test.go index b5903c50397..ffd553e041d 100644 --- a/client/go/internal/vespa/load_env_test.go +++ b/client/go/internal/vespa/load_env_test.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package vespa import ( diff --git a/client/go/internal/vespa/log.go b/client/go/internal/vespa/log.go index 81088b8c0a1..00ce406b4e0 100644 --- a/client/go/internal/vespa/log.go +++ b/client/go/internal/vespa/log.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package vespa import ( diff --git a/client/go/internal/vespa/log_test.go b/client/go/internal/vespa/log_test.go index 2d0c75d0a0a..1d50fff2bbe 100644 --- a/client/go/internal/vespa/log_test.go +++ b/client/go/internal/vespa/log_test.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package vespa import ( diff --git a/client/go/internal/vespa/prestart.go b/client/go/internal/vespa/prestart.go index d2b0909693e..5b29915bcb2 100644 --- a/client/go/internal/vespa/prestart.go +++ b/client/go/internal/vespa/prestart.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. // Author: arnej package vespa diff --git a/client/go/internal/vespa/switch_user.go b/client/go/internal/vespa/switch_user.go index ccfe7c4e7c3..c84da567224 100644 --- a/client/go/internal/vespa/switch_user.go +++ b/client/go/internal/vespa/switch_user.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. // load default environment variables (from $VESPA_HOME/conf/vespa/default-env.txt) // Author: arnej diff --git a/client/go/internal/vespa/system.go b/client/go/internal/vespa/system.go index cdf401bf43c..b49dad97ee7 100644 --- a/client/go/internal/vespa/system.go +++ b/client/go/internal/vespa/system.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package vespa import "fmt" diff --git a/client/go/internal/vespa/target.go b/client/go/internal/vespa/target.go index f96723dc433..8c3f5c9b7c3 100644 --- a/client/go/internal/vespa/target.go +++ b/client/go/internal/vespa/target.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package vespa @@ -37,6 +37,7 @@ const ( ) var errWaitTimeout = errors.New("wait timed out") +var errAuth = errors.New("auth failed") // Authenticator authenticates the given HTTP request. type Authenticator interface { @@ -108,12 +109,10 @@ type LogOptions struct { // Do sends request to this service. Authentication of the request happens automatically. func (s *Service) Do(request *http.Request, timeout time.Duration) (*http.Response, error) { - s.once.Do(func() { - util.ConfigureTLS(s.httpClient, s.TLSOptions.KeyPair, s.TLSOptions.CACertificate, s.TLSOptions.TrustAll) - }) + util.ConfigureTLS(s.httpClient, s.TLSOptions.KeyPair, s.TLSOptions.CACertificate, s.TLSOptions.TrustAll) if s.auth != nil { if err := s.auth.Authenticate(request); err != nil { - return nil, err + return nil, fmt.Errorf("%w: %s", errAuth, err) } } return s.httpClient.Do(request, timeout) @@ -124,12 +123,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 @@ -220,7 +215,9 @@ func wait(service *Service, okFn responseFunc, reqFn requestFunc, timeout, retry loopOnce := timeout == 0 for time.Now().Before(deadline) || loopOnce { response, err = service.Do(reqFn(), 10*time.Second) - if err == nil { + if errors.Is(err, errAuth) { + return status, fmt.Errorf("aborting wait: %w", err) + } else if err == nil { status = response.StatusCode body, err := io.ReadAll(response.Body) if err != nil { diff --git a/client/go/internal/vespa/target_cloud.go b/client/go/internal/vespa/target_cloud.go index 7d50d921216..31108dae51f 100644 --- a/client/go/internal/vespa/target_cloud.go +++ b/client/go/internal/vespa/target_cloud.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package vespa import ( diff --git a/client/go/internal/vespa/target_custom.go b/client/go/internal/vespa/target_custom.go index b120dd73d9d..0f3817e8c13 100644 --- a/client/go/internal/vespa/target_custom.go +++ b/client/go/internal/vespa/target_custom.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package vespa import ( diff --git a/client/go/internal/vespa/target_test.go b/client/go/internal/vespa/target_test.go index 68b60774c94..4c2fda8368e 100644 --- a/client/go/internal/vespa/target_test.go +++ b/client/go/internal/vespa/target_test.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package vespa import ( @@ -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) } @@ -120,6 +120,8 @@ func TestCustomTargetAwaitDeployment(t *testing.T) { func TestCloudTargetWait(t *testing.T) { var logWriter bytes.Buffer target, client := createCloudTarget(t, &logWriter) + client.NextResponseError(errAuth) + assertService(t, true, target, "deploy", time.Second) // No retrying on auth error client.NextStatus(401) assertService(t, true, target, "deploy", time.Second) // No retrying on 4xx client.NextStatus(500) @@ -151,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) } diff --git a/client/go/internal/vespa/tls_options.go b/client/go/internal/vespa/tls_options.go index 2578116ef68..5625e66fbf3 100644 --- a/client/go/internal/vespa/tls_options.go +++ b/client/go/internal/vespa/tls_options.go @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package vespa diff --git a/client/go/internal/vespa/xml/config.go b/client/go/internal/vespa/xml/config.go index 0ce7413d671..e77e04c3a6f 100644 --- a/client/go/internal/vespa/xml/config.go +++ b/client/go/internal/vespa/xml/config.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package xml import ( diff --git a/client/go/internal/vespa/xml/config_test.go b/client/go/internal/vespa/xml/config_test.go index 0180a243406..e17a608b554 100644 --- a/client/go/internal/vespa/xml/config_test.go +++ b/client/go/internal/vespa/xml/config_test.go @@ -1,3 +1,4 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package xml import ( |