-
- Downloads
feat: retry on error
What --- Change the default `HTTP.Client` to `github.com/hashicorp/go-retryablehttp.Client` to get automatic retries and exponential backoff. We retry the request 2 times resulting in 3 attempts of sending the request, the min retry wait is 1 second, and the maximum is 15 seconds. Hide the retry logic behind a temporary feature flag `FF_GITLAB_SHELL_RETRYABLE_HTTP` to easily roll this out in GitLab.com. When we verify that this works as expected we will remove `FF_GITLAB_SHELL_RETRYABLE_HTTP` and have the retry logic as the default logic. Why --- In https://gitlab.com/gitlab-com/gl-infra/production/-/issues/7979 users end up seeing the following errors when trying to `git-clone(1)` a repository locally on in CI. ```shell remote: =============================== remote: remote: ERROR: Internal API unreachable remote: remote: ================================ ``` When we look at the application logs we see the following error: ```json { "err": "http://gitlab-webservice-git.gitlab.svc:8181/api/v4/internal/allowed": dial tcp 10.69.184.120:8181: connect: connection refused", "msg": "Internal API unreachable"} ``` In https://gitlab.com/gitlab-com/gl-infra/production/-/issues/7979#note_1222670120 we've correlated these `connection refused` errors with infrastructure events that remove the git pods that are hosting `gitlab-webservice-git` service. We could try to make the underlying infrastructure more reactive to these changes as suggested in https://gitlab.com/gitlab-com/gl-infra/production/-/issues/7979#note_1225164944 but we can still end up serving bad requests. Implementing retry logic for 5xx or other errors would allow users to still be able to `git-clone(1)` reposirories, although it being slower. This is espically important during CI runs so users don't have to retry jobs themselves. Reference: https://gitlab.com/gitlab-com/gl-infra/production/-/issues/7979 Closes: https://gitlab.com/gitlab-org/gitlab-shell/-/issues/604 Signed-off-by:Steve Azzopardi <sazzopardi@gitlab.com>
Showing
- client/client_test.go 48 additions, 3 deletionsclient/client_test.go
- client/gitlabnet.go 3 additions, 2 deletionsclient/gitlabnet.go
- client/httpclient.go 11 additions, 8 deletionsclient/httpclient.go
- client/httpclient_test.go 1 addition, 1 deletionclient/httpclient_test.go
- client/testserver/testserver.go 29 additions, 0 deletionsclient/testserver/testserver.go
- go.mod 2 additions, 0 deletionsgo.mod
- go.sum 6 additions, 0 deletionsgo.sum
- internal/command/discover/discover_test.go 24 additions, 26 deletionsinternal/command/discover/discover_test.go
- internal/command/healthcheck/healthcheck_test.go 1 addition, 1 deletioninternal/command/healthcheck/healthcheck_test.go
- internal/command/personalaccesstoken/personalaccesstoken_test.go 2 additions, 4 deletions...l/command/personalaccesstoken/personalaccesstoken_test.go
- internal/command/twofactorrecover/twofactorrecover_test.go 2 additions, 4 deletionsinternal/command/twofactorrecover/twofactorrecover_test.go
- internal/command/twofactorverify/twofactorverify_test.go 1 addition, 1 deletioninternal/command/twofactorverify/twofactorverify_test.go
- internal/config/config.go 2 additions, 2 deletionsinternal/config/config.go
- internal/gitlabnet/lfsauthenticate/client_test.go 1 addition, 1 deletioninternal/gitlabnet/lfsauthenticate/client_test.go
- spec/gitlab_shell_discover_spec.rb 1 addition, 1 deletionspec/gitlab_shell_discover_spec.rb
Loading
| Loading
| @@ -6,6 +6,7 @@ require ( |
github.com/golang-jwt/jwt/v4 v4.4.1 | ||
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 | ||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 | ||
github.com/hashicorp/go-retryablehttp v0.7.1 | ||
github.com/mattn/go-shellwords v1.0.11 | ||
github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a | ||
github.com/otiai10/copy v1.4.2 | ||
Loading
| Loading
| @@ -48,6 +49,7 @@ require ( |
github.com/google/pprof v0.0.0-20210804190019-f964ff605595 // indirect | ||
github.com/google/uuid v1.3.0 // indirect | ||
github.com/googleapis/gax-go/v2 v2.2.0 // indirect | ||
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect | ||
github.com/hashicorp/yamux v0.1.1 // indirect | ||
github.com/jmespath/go-jmespath v0.4.0 // indirect | ||
github.com/kr/text v0.2.0 // indirect | ||
Loading
| Loading
|
Please register or sign in to comment