Repository navigation
direct: use the postgres role a failed create request created #7767
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
Open
denik
wants to merge
2
commits into
main
Choose a base branch
from
denik/postgres-role-create-recovery
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+363
−4
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 @@ | ||
| * Use the Lakebase role when its create request fails with a transient error but the role was created, instead of failing the deploy, in the direct deployment engine. ([#7767](https://github.com/databricks/cli/pull/7767)) |
24 changes: 24 additions & 0 deletions
24
acceptance/bundle/resources/postgres_roles/create_transient_500/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,24 @@ | ||
| bundle: | ||
| name: test-bundle | ||
|
|
||
| sync: | ||
| paths: [] | ||
|
|
||
| resources: | ||
| postgres_projects: | ||
| my_project: | ||
| project_id: test-pg-proj | ||
| display_name: "Test Postgres Project" | ||
| pg_version: 16 | ||
|
|
||
| postgres_branches: | ||
| main: | ||
| parent: ${resources.postgres_projects.my_project.id} | ||
| branch_id: main | ||
| no_expiry: true | ||
|
|
||
| postgres_roles: | ||
| owner: | ||
| parent: ${resources.postgres_branches.main.id} | ||
| role_id: app-owner | ||
| postgres_role: app_owner |
3 changes: 3 additions & 0 deletions
3
acceptance/bundle/resources/postgres_roles/create_transient_500/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,3 @@ | ||
| Cloud = false | ||
| EnvMatrix.DMS = ["", "true"] | ||
| EnvMatrix.READPLAN = [] |
67 changes: 67 additions & 0 deletions
67
acceptance/bundle/resources/postgres_roles/create_transient_500/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,67 @@ | ||
|
|
||
| === The create request fails with 500 but the role was created: deploy uses the role | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Created postgres_branches.main | ||
| Created postgres_projects.my_project | ||
| Created postgres_roles.owner | ||
| Files: 0 uploaded, 0 deleted | ||
| Resources: 3 created, 0 changed, 0 deleted, 0 unchanged | ||
|
|
||
| >>> print_requests.py --get //postgres/projects/test-pg-proj/branches/main/roles | ||
| POST /api/2.0/postgres/projects/test-pg-proj/branches/main/roles | ||
| GET /api/2.0/postgres/projects/test-pg-proj/branches/main/roles/app-owner | ||
|
|
||
| === The create request fails with 500 and the role was not created: deploy repeats the create | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Created postgres_branches.main | ||
| Created postgres_projects.my_project | ||
| Warn: deploying resources.postgres_roles.owner: retrying after 500 Internal Server Error from POST /api/2.0/postgres/projects/test-pg-proj/branches/main/roles | ||
| Created postgres_roles.owner | ||
| Files: 0 uploaded, 0 deleted | ||
| Resources: 3 created, 0 changed, 0 deleted, 0 unchanged | ||
|
|
||
| >>> print_requests.py --get //postgres/projects/test-pg-proj/branches/main/roles | ||
| POST /api/2.0/postgres/projects/test-pg-proj/branches/main/roles | ||
| GET /api/2.0/postgres/projects/test-pg-proj/branches/main/roles/app-owner | ||
| POST /api/2.0/postgres/projects/test-pg-proj/branches/main/roles | ||
| GET /api/2.0/postgres/projects/test-pg-proj/branches/main/roles/app-owner/operations/[UUID][0] | ||
|
|
||
| === The role cannot be read after the create request fails: deploy fails with the create error | ||
|
|
||
| >>> musterr [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Created postgres_branches.main | ||
| Created postgres_projects.my_project | ||
| Warn: deploying resources.postgres_roles.owner: checking whether projects/test-pg-proj/branches/main/roles/app-owner was created: Fault injected by test. | ||
| Error: cannot create resources.postgres_roles.owner: Fault injected by test. (500 INTERNAL_ERROR) | ||
|
|
||
| Endpoint: POST [DATABRICKS_URL]/api/2.0/postgres/projects/test-pg-proj/branches/main/roles?role_id=app-owner | ||
| HTTP Status: 500 Internal Server Error | ||
| API error_code: INTERNAL_ERROR | ||
| API message: Fault injected by test. | ||
|
|
||
| Files: 0 uploaded, 0 deleted | ||
|
|
||
| >>> print_requests.py --get //postgres/projects/test-pg-proj/branches/main/roles | ||
| POST /api/2.0/postgres/projects/test-pg-proj/branches/main/roles | ||
| GET /api/2.0/postgres/projects/test-pg-proj/branches/main/roles/app-owner | ||
|
|
||
| === With replace_existing, a failed create request is repeated without reading the role | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Created postgres_branches.main | ||
| Created postgres_projects.my_project | ||
| Warn: deploying resources.postgres_roles.owner: retrying after 500 Internal Server Error from POST /api/2.0/postgres/projects/test-pg-proj/branches/main/roles | ||
| Created postgres_roles.owner | ||
| Files: 0 uploaded, 0 deleted | ||
| Resources: 3 created, 0 changed, 0 deleted, 0 unchanged | ||
|
|
||
| >>> print_requests.py --get //postgres/projects/test-pg-proj/branches/main/roles | ||
| POST /api/2.0/postgres/projects/test-pg-proj/branches/main/roles | ||
| POST /api/2.0/postgres/projects/test-pg-proj/branches/main/roles | ||
| GET /api/2.0/postgres/projects/test-pg-proj/branches/main/roles/app-owner/operations/[UUID][1] |
29 changes: 29 additions & 0 deletions
29
acceptance/bundle/resources/postgres_roles/create_transient_500/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,29 @@ | ||
| title "The create request fails with 500 but the role was created: deploy uses the role" | ||
| fault.py --after-handler "POST /api/2.0/postgres/projects/*/branches/*/roles" 500 0 1 INTERNAL_ERROR | ||
| trace $CLI bundle deploy | ||
| trace print_requests.py --get //postgres/projects/test-pg-proj/branches/main/roles | jq -r '.method + " " + .path' | ||
| $CLI bundle destroy --auto-approve &> LOG.destroy | ||
| rm -f "$OUT_REQUESTS" | ||
|
|
||
| title "The create request fails with 500 and the role was not created: deploy repeats the create" | ||
| fault.py "POST /api/2.0/postgres/projects/*/branches/*/roles" 500 0 1 INTERNAL_ERROR | ||
| trace $CLI bundle deploy | ||
| trace print_requests.py --get //postgres/projects/test-pg-proj/branches/main/roles | jq -r '.method + " " + .path' | ||
| $CLI bundle destroy --auto-approve &> LOG.destroy | ||
| rm -f "$OUT_REQUESTS" | ||
|
|
||
| title "The role cannot be read after the create request fails: deploy fails with the create error" | ||
| fault.py "POST /api/2.0/postgres/projects/*/branches/*/roles" 500 0 1 INTERNAL_ERROR | ||
| fault.py "GET /api/2.0/postgres/projects/*/branches/*/roles/app-owner" 403 0 1 PERMISSION_DENIED | ||
| trace musterr $CLI bundle deploy | ||
| trace print_requests.py --get //postgres/projects/test-pg-proj/branches/main/roles | jq -r '.method + " " + .path' | ||
| $CLI bundle destroy --auto-approve &> LOG.destroy | ||
| rm -f "$OUT_REQUESTS" | ||
|
|
||
| title "With replace_existing, a failed create request is repeated without reading the role" | ||
| update_file.py databricks.yml "postgres_role: app_owner" "postgres_role: app_owner | ||
| replace_existing: true" | ||
| fault.py --after-handler "POST /api/2.0/postgres/projects/*/branches/*/roles" 500 0 1 INTERNAL_ERROR | ||
| trace $CLI bundle deploy | ||
| trace print_requests.py --get //postgres/projects/test-pg-proj/branches/main/roles | jq -r '.method + " " + .path' | ||
| $CLI bundle destroy --auto-approve &> LOG.destroy |
6 changes: 6 additions & 0 deletions
6
acceptance/bundle/resources/postgres_roles/create_transient_500/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,6 @@ | ||
| Cloud = false | ||
| RecordRequests = true | ||
| EnvMatrix.READPLAN = [] | ||
| Env.DATABRICKS_BUNDLE_ENGINE = "direct" | ||
| Env.DATABRICKS_BUNDLE_RETRY_INTERVAL_MS = "100" | ||
| SuppressLines.warn_retry = "" |
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.