-
Notifications
You must be signed in to change notification settings - Fork 177
direct: retry 504 errors #5349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+558
−16
Merged
direct: retry 504 errors #5349
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
44ac109
Add adapter-level retry for transient HTTP errors in direct engine
denik c955b5c
update tests
denik a176d26
tests
denik 4967558
Scope retry to 504+!IsRetriable; add opt-in retrySafe for idempotent …
denik 4edfda4
clean up
denik d5e1599
rename doRefresh to doRead
denik f51f6ba
Move retry logic from adapter to call sites in apply.go and bundle_pl…
denik 05f5bd7
Log and fall through on transient errors in WaitAfterCreate/WaitAfter…
denik 82e3e2c
Rename retryErr to retryOnTransientErr
denik 73d0b05
Fix log prefix in Destroy: "destroying" not "deploying"
denik c68f966
Reduce default retry interval from 30s to 15s
denik 1720072
Use errors.AsType[T] instead of errors.As for Go 1.26+ compatibility
denik dd2b0e4
Revert unrelated cosmetic changes in adapter.go
denik fe5f124
Inline IsRetrySafe: export RetrySafeError, use errors.AsType at call …
denik 5219571
Retry WaitAfterCreate/WaitAfterUpdate on transient errors instead of …
denik 564f68e
Guard apiErr nil in retryWith log line
denik 0059f64
Export FaultRules/FaultRule and add unit tests for fault injection logic
denik 95d6a8a
restructure
denik bf19721
Mark acceptance/bin/fault.py as executable
denik 80a9f58
Fix uniq -c count width portability in 504/plan acceptance test
denik e7b037f
Add NEXT_CHANGELOG entry for 504 retry
denik 42f0cc1
add a comment about DoCreate opt-in
denik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| #!/usr/bin/env python3 | ||
| """Set up a fault rule on the testserver for the current test token. | ||
|
|
||
| Usage: fault.py PATTERN STATUS_CODE OFFSET TIMES | ||
|
|
||
| PATTERN HTTP method and path, supports trailing * wildcard, | ||
| e.g. "PUT /api/2.0/permissions/pipelines/*" | ||
| STATUS_CODE HTTP status code to return, e.g. 504 | ||
| OFFSET number of requests to let through before fault starts | ||
| TIMES number of times to return the fault response | ||
|
|
||
| The rule is scoped to the current DATABRICKS_TOKEN so it only affects | ||
| the test that registers it, even when tests share a server. | ||
| """ | ||
|
|
||
| import json | ||
| import os | ||
| import sys | ||
| import urllib.request | ||
|
|
||
| host = os.environ.get("DATABRICKS_HOST", "") | ||
| token = os.environ.get("DATABRICKS_TOKEN", "") | ||
|
|
||
| if not host: | ||
| print("DATABRICKS_HOST not set", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| if len(sys.argv) != 5: | ||
| print(f"usage: {sys.argv[0]} PATTERN STATUS_CODE OFFSET TIMES", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| pattern, status_code, offset, times = sys.argv[1], int(sys.argv[2]), int(sys.argv[3]), int(sys.argv[4]) | ||
| body = '{"error_code":"INJECTED","message":"Fault injected by test."}' | ||
|
|
||
| data = json.dumps( | ||
| { | ||
| "pattern": pattern, | ||
| "status_code": status_code, | ||
| "body": body, | ||
| "offset": offset, | ||
| "times": times, | ||
| } | ||
| ).encode() | ||
|
|
||
| req = urllib.request.Request( | ||
| f"{host}/__testserver/fault", | ||
| data=data, | ||
| headers={"Content-Type": "application/json", "Authorization": f"Bearer {token}"}, | ||
| method="POST", | ||
| ) | ||
| urllib.request.urlopen(req) |
10 changes: 10 additions & 0 deletions
10
acceptance/bundle/resources/permissions/pipelines/504/create/databricks.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| bundle: | ||
| name: test-bundle | ||
|
|
||
| resources: | ||
| pipelines: | ||
| foo: | ||
| name: foo | ||
| permissions: | ||
| - level: CAN_VIEW | ||
| user_name: viewer@example.com |
4 changes: 4 additions & 0 deletions
4
acceptance/bundle/resources/permissions/pipelines/504/create/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
acceptance/bundle/resources/permissions/pipelines/504/create/output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Deploying resources... | ||
| Warn: deploying resources.pipelines.foo.permissions: retrying after 504 Gateway Timeout from PUT /api/2.0/permissions/pipelines/[UUID] | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> print_requests.py //api/2.0/permissions/pipelines | ||
| "PUT /api/2.0/permissions/pipelines/[UUID]" | ||
| "PUT /api/2.0/permissions/pipelines/[UUID]" |
8 changes: 8 additions & 0 deletions
8
acceptance/bundle/resources/permissions/pipelines/504/create/script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Inject a single 504 on the first permissions PUT to simulate a transient error. | ||
| # Permissions Set is idempotent, so DoCreate opts in via retrySafe and the deploy succeeds. | ||
| fault.py "PUT /api/2.0/permissions/pipelines/*" 504 0 1 | ||
|
|
||
| $CLI bundle deploy | ||
|
|
||
| # Two PUT requests should appear: the initial 504 and the successful retry. | ||
| trace print_requests.py //api/2.0/permissions/pipelines | jq '.method + " " + .path' |
1 change: 1 addition & 0 deletions
1
acceptance/bundle/resources/permissions/pipelines/504/create/test.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| RecordRequests = true |
10 changes: 10 additions & 0 deletions
10
acceptance/bundle/resources/permissions/pipelines/504/plan/databricks.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| bundle: | ||
| name: test-bundle | ||
|
|
||
| resources: | ||
| pipelines: | ||
| foo: | ||
| name: foo | ||
| permissions: | ||
| - level: CAN_VIEW | ||
| user_name: viewer@example.com |
4 changes: 4 additions & 0 deletions
4
acceptance/bundle/resources/permissions/pipelines/504/plan/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
acceptance/bundle/resources/permissions/pipelines/504/plan/output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] bundle plan | ||
| Warn: planning resources.pipelines.foo.permissions: retrying after 504 Gateway Timeout from GET /api/2.0/permissions/pipelines/[UUID] | ||
| Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged | ||
|
|
||
| >>> print_requests.py //api/2.0/permissions/pipelines --get --oneline | ||
| 2 {"method": "GET", "path": "/api/2.0/permissions/pipelines/[UUID]"} | ||
|
|
||
| >>> [CLI] bundle plan | ||
| Warn: planning resources.pipelines.foo.permissions: retrying after 504 Gateway Timeout from GET /api/2.0/permissions/pipelines/[UUID] | ||
| Warn: planning resources.pipelines.foo.permissions: retrying after 504 Gateway Timeout from GET /api/2.0/permissions/pipelines/[UUID] | ||
| Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged | ||
| 3 {"method": "GET", "path": "/api/2.0/permissions/pipelines/[UUID]"} | ||
|
|
||
| >>> musterr [CLI] bundle plan | ||
| Warn: planning resources.pipelines.foo.permissions: retrying after 504 Gateway Timeout from GET /api/2.0/permissions/pipelines/[UUID] | ||
| Warn: planning resources.pipelines.foo.permissions: retrying after 504 Gateway Timeout from GET /api/2.0/permissions/pipelines/[UUID] | ||
| Error: cannot plan resources.pipelines.foo.permissions: reading id="/pipelines/[UUID]": Fault injected by test. (504 INJECTED) | ||
|
|
||
| Endpoint: GET [DATABRICKS_URL]/api/2.0/permissions/pipelines/[UUID]? | ||
| HTTP Status: 504 Gateway Timeout | ||
| API error_code: INJECTED | ||
| API message: Fault injected by test. | ||
|
|
||
| Error: planning failed | ||
|
|
||
| 3 {"method": "GET", "path": "/api/2.0/permissions/pipelines/[UUID]"} |
15 changes: 15 additions & 0 deletions
15
acceptance/bundle/resources/permissions/pipelines/504/plan/script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Deploy first so the permissions resource exists; plan reads it on subsequent runs. | ||
| $CLI bundle deploy | ||
| rm -f out.requests.txt | ||
|
|
||
| fault.py "GET /api/2.0/permissions/pipelines/*" 504 0 1 | ||
| trace $CLI bundle plan | ||
| trace print_requests.py //api/2.0/permissions/pipelines --get --oneline | uniq -c | sed 's/^ *//' | contains.py "2 " | ||
|
|
||
| fault.py "GET /api/2.0/permissions/pipelines/*" 504 0 2 | ||
| trace $CLI bundle plan | ||
| print_requests.py //api/2.0/permissions/pipelines --get --oneline | uniq -c | sed 's/^ *//' | contains.py "3 " | ||
|
|
||
| fault.py "GET /api/2.0/permissions/pipelines/*" 504 0 3 | ||
| trace musterr $CLI bundle plan | ||
| print_requests.py //api/2.0/permissions/pipelines --get --oneline | uniq -c | sed 's/^ *//' | contains.py "3 " |
4 changes: 4 additions & 0 deletions
4
acceptance/bundle/resources/permissions/pipelines/504/test.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] | ||
| EnvMatrix.READPLAN = [] | ||
| RecordRequests = true | ||
| Env.DATABRICKS_BUNDLE_RETRY_INTERVAL_MS = "100" |
10 changes: 10 additions & 0 deletions
10
acceptance/bundle/resources/permissions/pipelines/504/update/databricks.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| bundle: | ||
| name: test-bundle | ||
|
|
||
| resources: | ||
| pipelines: | ||
| foo: | ||
| name: foo | ||
| permissions: | ||
| - level: CAN_VIEW | ||
| user_name: viewer@example.com |
4 changes: 4 additions & 0 deletions
4
acceptance/bundle/resources/permissions/pipelines/504/update/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
acceptance/bundle/resources/permissions/pipelines/504/update/output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Deploying resources... | ||
| Warn: deploying resources.pipelines.foo.permissions: retrying after 504 Gateway Timeout from PUT /api/2.0/permissions/pipelines/[UUID] | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> print_requests.py //api/2.0/permissions/pipelines | ||
| "PUT /api/2.0/permissions/pipelines/[UUID]" | ||
| "PUT /api/2.0/permissions/pipelines/[UUID]" |
13 changes: 13 additions & 0 deletions
13
acceptance/bundle/resources/permissions/pipelines/504/update/script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| trace $CLI bundle deploy | ||
|
|
||
| update_file.py databricks.yml CAN_VIEW CAN_MANAGE | ||
|
|
||
| # Inject a single 504 on the first permissions PUT to simulate a transient error. | ||
| # The retrying adapter should retry after DATABRICKS_BUNDLE_RETRY_INTERVAL_MS and succeed. | ||
| fault.py "PUT /api/2.0/permissions/pipelines/*" 504 0 1 | ||
|
|
||
| rm out.requests.txt | ||
| trace $CLI bundle deploy | ||
|
|
||
| # Two PUT requests should appear: the initial 504 and the successful retry. | ||
| trace print_requests.py //api/2.0/permissions/pipelines | jq '.method + " " + .path' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.