Skip to content

Commit 1577a32

Browse files
committed
Improved request retry logic
1 parent 78d62de commit 1577a32

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,23 @@ vendor:
4545
@echo "✓ Filling vendor folder with library code..."
4646
@go mod vendor
4747

48-
test-azcli:
48+
test-azcli: install
4949
@echo "✓ Running Terraform Acceptance Tests for Azure..."
5050
@/bin/bash scripts/run.sh azcli '^(TestAcc|TestAzureAcc)' --debug --tee
5151

52-
test-azsp:
52+
test-azsp: install
5353
@echo "✓ Running Terraform Acceptance Tests for Azure..."
5454
@/bin/bash scripts/run.sh azsp '^(TestAcc|TestAzureAcc)' --debug --tee
5555

56-
test-mws:
56+
test-mws: install
5757
@echo "✓ Running acceptance Tests for Multiple Workspace APIs on AWS..."
5858
@/bin/bash scripts/run.sh mws '^TestMwsAcc' --debug --tee
5959

60-
test-awsst:
60+
test-awsst: install
6161
@echo "✓ Running Terraform Acceptance Tests for AWS ST..."
6262
@/bin/bash scripts/run.sh awsst '^(TestAcc|TestAwsAcc)' --debug --tee
6363

64-
test-awsmt:
64+
test-awsmt: install
6565
@echo "✓ Running Terraform Acceptance Tests for AWS MT..."
6666
@/bin/bash scripts/run.sh awsmt '^(TestAcc|TestAwsAcc)' --debug --tee
6767

common/http.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ var (
2626
"does not have any associated worker environments",
2727
"There is no worker environment with id",
2828
"ClusterNotReadyException",
29+
"connection reset by peer",
30+
"connection refused",
31+
"i/o timeout",
2932
}
3033
)
3134

@@ -204,13 +207,8 @@ func (c *DatabricksClient) parseError(resp *http.Response) APIError {
204207
// checkHTTPRetry inspects HTTP errors from the Databricks API for known transient errors on Workspace creation
205208
func (c *DatabricksClient) checkHTTPRetry(ctx context.Context, resp *http.Response, err error) (bool, error) {
206209
if ue, ok := err.(*url.Error); ok {
207-
if strings.Contains(ue.Error(), "connection refused") || strings.Contains(ue.Error(), "i/o timeout") {
208-
log.Printf("[INFO] Attempting retry because of IO error: %s", ue.Error())
209-
return true, APIError{
210-
Message: ue.Error(),
211-
ErrorCode: "IO_ERROR",
212-
}
213-
}
210+
apiError := APIError{ErrorCode: "IO_ERROR", Message: ue.Error()}
211+
return apiError.IsRetriable(), apiError
214212
}
215213
if resp == nil {
216214
// If response is nil we can't make retry choices.

0 commit comments

Comments
 (0)