diff options
| author | Steve Azzopardi <sazzopardi@gitlab.com> | 2023-01-30 09:21:17 +0100 |
|---|---|---|
| committer | Steve Azzopardi <sazzopardi@gitlab.com> | 2023-01-30 09:54:42 +0100 |
| commit | 80f684e48eca2bf1ef2006d84f8c49bec7104344 (patch) | |
| tree | d96c92030bfe86a5183a7268361b2ec70788f73c /internal/command/discover | |
| parent | 51eab44edafd0c097e82c1a74fd379cae4869a42 (diff) | |
| download | gitlab-shell-80f684e48eca2bf1ef2006d84f8c49bec7104344.tar.gz | |
feat: make retryable http default client
What
---
Make the retryableHTTP client introduced in
https://gitlab.com/gitlab-org/gitlab-shell/-/merge_requests/703 the
default HTTP client.
Why
---
In
https://gitlab.com/gitlab-com/gl-infra/production/-/issues/7979#note_1254964426
we've seen a 99% error reduction on `git` commands from `gitlab-shell`
when the retryableHTTP client is used.
This has been running in production for over 2 weeks in `us-east1-b` and
5 days fleet-wide so we should be confident that this client works as
expected.
Reference: https://gitlab.com/gitlab-com/gl-infra/production/-/issues/7979
Signed-off-by: Steve Azzopardi <sazzopardi@gitlab.com>
Diffstat (limited to 'internal/command/discover')
| -rw-r--r-- | internal/command/discover/discover_test.go | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/internal/command/discover/discover_test.go b/internal/command/discover/discover_test.go index ccbfa7e..df9ca47 100644 --- a/internal/command/discover/discover_test.go +++ b/internal/command/discover/discover_test.go @@ -16,33 +16,31 @@ import ( "gitlab.com/gitlab-org/gitlab-shell/v14/internal/config" ) -var ( - requests = []testserver.TestRequestHandler{ - { - Path: "/api/v4/internal/discover", - Handler: func(w http.ResponseWriter, r *http.Request) { - if r.URL.Query().Get("key_id") == "1" || r.URL.Query().Get("username") == "alex-doe" { - body := map[string]interface{}{ - "id": 2, - "username": "alex-doe", - "name": "Alex Doe", - } - json.NewEncoder(w).Encode(body) - } else if r.URL.Query().Get("username") == "broken_message" { - body := map[string]string{ - "message": "Forbidden!", - } - w.WriteHeader(http.StatusForbidden) - json.NewEncoder(w).Encode(body) - } else if r.URL.Query().Get("username") == "broken" { - w.WriteHeader(http.StatusInternalServerError) - } else { - fmt.Fprint(w, "null") +var requests = []testserver.TestRequestHandler{ + { + Path: "/api/v4/internal/discover", + Handler: func(w http.ResponseWriter, r *http.Request) { + if r.URL.Query().Get("key_id") == "1" || r.URL.Query().Get("username") == "alex-doe" { + body := map[string]interface{}{ + "id": 2, + "username": "alex-doe", + "name": "Alex Doe", + } + json.NewEncoder(w).Encode(body) + } else if r.URL.Query().Get("username") == "broken_message" { + body := map[string]string{ + "message": "Forbidden!", } - }, + w.WriteHeader(http.StatusForbidden) + json.NewEncoder(w).Encode(body) + } else if r.URL.Query().Get("username") == "broken" { + w.WriteHeader(http.StatusInternalServerError) + } else { + fmt.Fprint(w, "null") + } }, - } -) + }, +} func TestExecute(t *testing.T) { url := testserver.StartSocketHttpServer(t, requests) @@ -112,7 +110,7 @@ func TestFailingExecute(t *testing.T) { { desc: "When the API fails", arguments: &commandargs.Shell{GitlabUsername: "broken"}, - expectedError: "Failed to get username: Internal API error (500)", + expectedError: "Failed to get username: Internal API unreachable", }, } |
