Do not wait on unauthorized request
@@ -239,8 +239,8 @@ func (t *cloudTarget) waitForRun(signer *RequestSigner, runID int64, timeout tim
return req
}
jobSuccessFunc := func(status int, response []byte) (bool, error) {
- if status/100 != 2 {
- return false, nil
+ if ok, err := isOK(status); !ok {
+ return ok, err
}
var resp jobResponse
if err := json.Unmarshal(response, &resp); err != nil {
@@ -297,8 +297,8 @@ func (t *cloudTarget) discoverEndpoints(signer *RequestSigner, timeout time.Dura
}
var endpointURL string
endpointFunc := func(status int, response []byte) (bool, error) {
- if status/100 != 2 {
- return false, nil
+ if ok, err := isOK(status); !ok {
+ return ok, err
}
var resp deploymentResponse
if err := json.Unmarshal(response, &resp); err != nil {
@@ -321,6 +321,13 @@ func (t *cloudTarget) discoverEndpoints(signer *RequestSigner, timeout time.Dura
return nil
}
+func isOK(status int) (bool, error) {
+ if status == 401 {
+ return false, fmt.Errorf("status %d: invalid api key", status)
+ }
+ return status/100 == 2, nil
+}
+
// LocalTarget creates a target for a Vespa platform running locally.
func LocalTarget() Target {
return &customTarget{targetType: localTargetType, baseURL: "http://127.0.0.1"}
