Repository navigation
direct: treat a missing cluster's 400 "does not exist" as not found #8068
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
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
448fbf0
direct: treat a cluster's 400 "does not exist" as not found
denik 0e93de1
Reuse the fake workspace in the cluster unit tests
denik ccb8a07
Update golden for the testserver's missing-cluster message
denik 6ead098
Address review: exact match, cancel library read, map library-status …
denik db54596
Add PR link to the changelog entry
denik 203530b
Drop the message matcher; rely on the DoRead precedence and deleteCon…
denik a519305
acc: narrow the deleted-out-of-band comment and show the state after …
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * Fix `bundle deploy` and `bundle destroy` with the direct engine sometimes failing with "Cluster ... does not exist" when a cluster in the state was already deleted. ([#8068](https://github.com/databricks/cli/pull/8068)) |
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
10 changes: 10 additions & 0 deletions
10
acceptance/bundle/resources/clusters/deleted-out-of-band-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: | ||
| clusters: | ||
| foo: | ||
| cluster_name: foo | ||
| spark_version: 13.3.x-scala2.12 | ||
| node_type_id: i3.xlarge | ||
| num_workers: 1 |
2 changes: 2 additions & 0 deletions
2
acceptance/bundle/resources/clusters/deleted-out-of-band-plan/out.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,2 @@ | ||
| Cloud = false | ||
| EnvMatrix.DMS = ["", "true"] |
50 changes: 50 additions & 0 deletions
50
acceptance/bundle/resources/clusters/deleted-out-of-band-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,50 @@ | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Created clusters.foo | ||
| Files: 1 uploaded, 0 deleted | ||
| Resources: 1 created, 0 changed, 0 deleted, 0 unchanged | ||
|
|
||
| === deploy: the cluster is still in config, so it is created again | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Created clusters.foo | ||
| Files: 2 uploaded, 0 deleted | ||
| Resources: 1 created, 0 changed, 0 deleted, 0 unchanged | ||
|
|
||
| >>> print_requests.py //clusters | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.1/clusters/create", | ||
| "body": { | ||
| "autotermination_minutes": 60, | ||
| "cluster_name": "foo", | ||
| "node_type_id": "[NODE_TYPE_ID]", | ||
| "num_workers": 1, | ||
| "spark_version": "13.3.x-scala2.12" | ||
| } | ||
| } | ||
|
|
||
| === saved plan: the delete was planned while the cluster existed | ||
|
|
||
| >>> [CLI] bundle plan -o json | ||
|
|
||
| >>> [CLI] bundle deploy --plan plan.json --auto-approve | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Warn: destroying resources.clusters.foo: Treating resources.clusters.foo id=[FOO_ID_2] as already deleted despite delete error: Cluster [FOO_ID_2] does not exist | ||
| Deleted clusters.foo | ||
| Files: 3 uploaded, 0 deleted | ||
| Resources: 0 created, 0 changed, 1 deleted, 0 unchanged | ||
|
|
||
| >>> print_state.py | ||
| [] | ||
|
|
||
| >>> print_requests.py //clusters | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.1/clusters/permanent-delete", | ||
| "body": { | ||
| "cluster_id": "[FOO_ID_2]" | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
acceptance/bundle/resources/clusters/deleted-out-of-band-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,27 @@ | ||
| # A cluster is permanently deleted out of band. The backend then answers the cluster GET, | ||
| # library-status and permanent-delete for it with 400 INVALID_PARAMETER_VALUE "does not exist". | ||
| trace $CLI bundle deploy | ||
| cluster_id=$(read_id.py foo) | ||
| print_requests.py > LOG.requests_deploy | ||
|
|
||
| title "deploy: the cluster is still in config, so it is created again" | ||
| $CLI clusters permanent-delete $cluster_id | ||
| print_requests.py > LOG.requests_oob_delete | ||
| trace $CLI bundle deploy | ||
| trace print_requests.py //clusters | ||
|
|
||
| title "saved plan: the delete was planned while the cluster existed" | ||
| update_file.py databricks.yml " clusters: | ||
| foo: | ||
| cluster_name: foo | ||
| spark_version: 13.3.x-scala2.12 | ||
| node_type_id: i3.xlarge | ||
| num_workers: 1 | ||
| " " {} | ||
| " | ||
| trace $CLI bundle plan -o json > plan.json | ||
| $CLI clusters permanent-delete $(read_id.py foo) | ||
| print_requests.py > LOG.requests_plan | ||
| trace $CLI bundle deploy --plan plan.json --auto-approve | ||
| trace print_state.py | jq -c ".state | keys" | ||
| trace print_requests.py //clusters |
3 changes: 3 additions & 0 deletions
3
acceptance/bundle/resources/clusters/deleted-out-of-band-plan/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,3 @@ | ||
| Cloud = false | ||
| RecordRequests = true | ||
| Ignore = [".databricks/", "plan.json"] |
10 changes: 10 additions & 0 deletions
10
acceptance/bundle/resources/clusters/deleted-out-of-band/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: | ||
| clusters: | ||
| foo: | ||
| cluster_name: foo | ||
| spark_version: 13.3.x-scala2.12 | ||
| node_type_id: i3.xlarge | ||
| num_workers: 1 |
2 changes: 2 additions & 0 deletions
2
acceptance/bundle/resources/clusters/deleted-out-of-band/out.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,2 @@ | ||
| Cloud = false | ||
| EnvMatrix.DMS = ["", "true"] |
51 changes: 51 additions & 0 deletions
51
acceptance/bundle/resources/clusters/deleted-out-of-band/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,51 @@ | ||
|
|
||
| === destroy | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default | ||
|
|
||
| Destroy: 0 deleted | ||
|
|
||
| >>> print_state.py | ||
|
|
||
| >>> print_requests.py --get --sort //clusters //libraries | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/libraries/cluster-status", | ||
| "q": { | ||
| "cluster_id": "1126-000000-deleted0" | ||
| } | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.1/clusters/get", | ||
| "q": { | ||
| "cluster_id": "1126-000000-deleted0" | ||
| } | ||
| } | ||
|
|
||
| === deploy: the cluster is removed from config | ||
|
|
||
| >>> [CLI] bundle deploy --auto-approve | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Files: 2 uploaded, 0 deleted | ||
| Resources: 0 created, 0 changed, 0 deleted, 0 unchanged | ||
|
|
||
| >>> print_state.py | ||
| [] | ||
|
|
||
| >>> print_requests.py --get --sort //clusters //libraries | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/libraries/cluster-status", | ||
| "q": { | ||
| "cluster_id": "1126-000000-deleted0" | ||
| } | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.1/clusters/get", | ||
| "q": { | ||
| "cluster_id": "1126-000000-deleted0" | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
acceptance/bundle/resources/clusters/deleted-out-of-band/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,30 @@ | ||
| # The state points at a cluster that was deleted out of band. The backend answers clusters/get | ||
| # and libraries/cluster-status for it with 400 INVALID_PARAMETER_VALUE "does not exist"; the | ||
| # stub in test.toml delays the cluster GET so the library-status GET answers first. | ||
| seed_state() { | ||
| mkdir -p .databricks/bundle/default | ||
| cp state.json .databricks/bundle/default/resources.json | ||
| # MSYS_NO_PATHCONV=1 keeps Git Bash on Windows from rewriting the workspace path. | ||
| MSYS_NO_PATHCONV=1 $CLI workspace mkdirs /Workspace/Users/$CURRENT_USER_NAME/.bundle/test-bundle/default | ||
| } | ||
|
|
||
| # Destroy runs first: a deploy pushes a newer state that the destroy would pull instead. | ||
| title "destroy" | ||
| seed_state | ||
| trace $CLI bundle destroy --auto-approve | ||
| trace print_state.py | jq -c ".state | keys" | ||
| trace print_requests.py --get --sort //clusters //libraries | ||
|
|
||
| title "deploy: the cluster is removed from config" | ||
| seed_state | ||
| update_file.py databricks.yml " clusters: | ||
| foo: | ||
| cluster_name: foo | ||
| spark_version: 13.3.x-scala2.12 | ||
| node_type_id: i3.xlarge | ||
| num_workers: 1 | ||
| " " {} | ||
| " | ||
| trace $CLI bundle deploy --auto-approve | ||
| trace print_state.py | jq -c ".state | keys" | ||
| trace print_requests.py --get --sort //clusters //libraries |
17 changes: 17 additions & 0 deletions
17
acceptance/bundle/resources/clusters/deleted-out-of-band/state.json
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 @@ | ||
| { | ||
| "state_version": 3, | ||
| "lineage": "test-lineage", | ||
| "serial": 1, | ||
| "state": { | ||
| "resources.clusters.foo": { | ||
| "__id__": "1126-000000-deleted0", | ||
| "state": { | ||
| "autotermination_minutes": 60, | ||
| "cluster_name": "foo", | ||
| "node_type_id": "i3.xlarge", | ||
| "num_workers": 1, | ||
| "spark_version": "13.3.x-scala2.12" | ||
| } | ||
| } | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
acceptance/bundle/resources/clusters/deleted-out-of-band/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,9 @@ | ||
| Cloud = false | ||
| RecordRequests = true | ||
| Ignore = [".databricks/"] | ||
|
|
||
| [[Server]] | ||
| Pattern = "GET /api/2.1/clusters/get" | ||
| Delay = "300ms" | ||
| Response.StatusCode = 400 | ||
| Response.Body = '''{"error_code": "INVALID_PARAMETER_VALUE", "message": "Cluster 1126-000000-deleted0 does not exist"}''' |
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.
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.