-
Notifications
You must be signed in to change notification settings - Fork 168
postgres: Support replace_existing on branches and endpoints
#5264
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
8 commits
Select commit
Hold shift + click to select a range
468ea80
postgres: Support replace_existing on branches and endpoints
pietern 34211e7
direct: Suppress MANAGED_BY_PARENT errors on Delete
pietern 1e799c9
testproxy: forward raw error body and headers from upstream
pietern a8f9e88
Merge branch 'testserver-proxy-fix' into postgres-replace-existing
pietern fd48cdc
changelog: replace_existing for postgres branches and endpoints
pietern 24c2d0f
acc: refresh replace_existing test comments after destroy started pas…
pietern dcb0c5f
acc: refresh refschema snapshot for replace_existing fields
pietern 60141ba
direct: Suppress MANAGED_BY_PARENT in Recreate as well
pietern 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
24 changes: 24 additions & 0 deletions
24
acceptance/bundle/resources/postgres_branches/replace_existing/databricks.yml.tmpl
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: deploy-postgres-replace-branch-$UNIQUE_NAME | ||
|
|
||
| sync: | ||
| paths: [] | ||
|
|
||
| resources: | ||
| postgres_projects: | ||
| my_project: | ||
| project_id: test-pg-proj-$UNIQUE_NAME | ||
| display_name: "Replace existing branch test" | ||
| pg_version: 16 | ||
| history_retention_duration: "604800s" | ||
|
|
||
| # Take over the implicitly-created production branch with replace_existing | ||
| # and apply a non-default spec (no_expiry: true). The field is input-only | ||
| # and not surfaced in get-branch, but it is visible in the recorded | ||
| # request body so the diff confirms it was sent. | ||
| postgres_branches: | ||
| production: | ||
| parent: ${resources.postgres_projects.my_project.id} | ||
| branch_id: production | ||
| replace_existing: true | ||
| no_expiry: true |
16 changes: 16 additions & 0 deletions
16
acceptance/bundle/resources/postgres_branches/replace_existing/out.destroy.direct.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,16 @@ | ||
| The following resources will be deleted: | ||
| delete resources.postgres_branches.production | ||
| delete resources.postgres_projects.my_project | ||
|
|
||
| This action will result in the deletion of the following Lakebase projects along with | ||
| all their branches, databases, and endpoints. All data stored in them will be permanently lost: | ||
| delete resources.postgres_projects.my_project | ||
|
|
||
| This action will result in the deletion of the following Lakebase branches. | ||
| All data stored in them will be permanently lost: | ||
| delete resources.postgres_branches.production | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/deploy-postgres-replace-branch-[UNIQUE_NAME]/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! |
16 changes: 16 additions & 0 deletions
16
acceptance/bundle/resources/postgres_branches/replace_existing/out.destroy.terraform.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,16 @@ | ||
| The following resources will be deleted: | ||
| delete resources.postgres_branches.production | ||
| delete resources.postgres_projects.my_project | ||
|
|
||
| This action will result in the deletion of the following Lakebase projects along with | ||
| all their branches, databases, and endpoints. All data stored in them will be permanently lost: | ||
| delete resources.postgres_projects.my_project | ||
|
|
||
| This action will result in the deletion of the following Lakebase branches. | ||
| All data stored in them will be permanently lost: | ||
| delete resources.postgres_branches.production | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/deploy-postgres-replace-branch-[UNIQUE_NAME]/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! |
31 changes: 31 additions & 0 deletions
31
...tance/bundle/resources/postgres_branches/replace_existing/out.requests.deploy.direct.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,31 @@ | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/postgres/projects", | ||
| "q": { | ||
| "project_id": "test-pg-proj-[UNIQUE_NAME]" | ||
| }, | ||
| "body": { | ||
| "spec": { | ||
| "display_name": "Replace existing branch test", | ||
| "history_retention_duration": "604800s", | ||
| "pg_version": 16 | ||
| } | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches", | ||
| "q": { | ||
| "branch_id": "production", | ||
| "replace_existing": "true" | ||
| }, | ||
| "body": { | ||
| "spec": { | ||
| "no_expiry": true | ||
| } | ||
| } | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production" | ||
| } |
32 changes: 32 additions & 0 deletions
32
...ce/bundle/resources/postgres_branches/replace_existing/out.requests.deploy.terraform.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,32 @@ | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/postgres/projects", | ||
| "q": { | ||
| "project_id": "test-pg-proj-[UNIQUE_NAME]" | ||
| }, | ||
| "body": { | ||
| "spec": { | ||
| "display_name": "Replace existing branch test", | ||
| "history_retention_duration": "604800s", | ||
| "pg_version": 16 | ||
| } | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches", | ||
| "q": { | ||
| "branch_id": "production", | ||
| "replace_existing": "true" | ||
| }, | ||
| "body": { | ||
| "parent": "projects/test-pg-proj-[UNIQUE_NAME]", | ||
| "spec": { | ||
| "no_expiry": true | ||
| } | ||
| } | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production" | ||
| } |
47 changes: 47 additions & 0 deletions
47
...ance/bundle/resources/postgres_branches/replace_existing/out.requests.destroy.direct.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,47 @@ | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/postgres/projects", | ||
| "q": { | ||
| "project_id": "test-pg-proj-[UNIQUE_NAME]" | ||
| }, | ||
| "body": { | ||
| "spec": { | ||
| "display_name": "Replace existing branch test", | ||
| "history_retention_duration": "604800s", | ||
| "pg_version": 16 | ||
| } | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches", | ||
| "q": { | ||
| "branch_id": "production", | ||
| "replace_existing": "true" | ||
| }, | ||
| "body": { | ||
| "spec": { | ||
| "no_expiry": true | ||
| } | ||
| } | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production" | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production" | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]" | ||
| } | ||
| { | ||
| "method": "DELETE", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production" | ||
| } | ||
| { | ||
| "method": "DELETE", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]" | ||
| } |
48 changes: 48 additions & 0 deletions
48
...e/bundle/resources/postgres_branches/replace_existing/out.requests.destroy.terraform.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,48 @@ | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/postgres/projects", | ||
| "q": { | ||
| "project_id": "test-pg-proj-[UNIQUE_NAME]" | ||
| }, | ||
| "body": { | ||
| "spec": { | ||
| "display_name": "Replace existing branch test", | ||
| "history_retention_duration": "604800s", | ||
| "pg_version": 16 | ||
| } | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches", | ||
| "q": { | ||
| "branch_id": "production", | ||
| "replace_existing": "true" | ||
| }, | ||
| "body": { | ||
| "parent": "projects/test-pg-proj-[UNIQUE_NAME]", | ||
| "spec": { | ||
| "no_expiry": true | ||
| } | ||
| } | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production" | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]" | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production" | ||
| } | ||
| { | ||
| "method": "DELETE", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production" | ||
| } | ||
| { | ||
| "method": "DELETE", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]" | ||
| } |
6 changes: 6 additions & 0 deletions
6
acceptance/bundle/resources/postgres_branches/replace_existing/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
acceptance/bundle/resources/postgres_branches/replace_existing/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,34 @@ | ||
|
|
||
| >>> [CLI] bundle validate | ||
| Name: deploy-postgres-replace-branch-[UNIQUE_NAME] | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/deploy-postgres-replace-branch-[UNIQUE_NAME]/default | ||
|
|
||
| Validation OK! | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-postgres-replace-branch-[UNIQUE_NAME]/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] postgres get-branch projects/test-pg-proj-[UNIQUE_NAME]/branches/production | ||
| { | ||
| "name": "projects/test-pg-proj-[UNIQUE_NAME]/branches/production", | ||
| "parent": "projects/test-pg-proj-[UNIQUE_NAME]", | ||
| "status": { | ||
| "branch_id": "production", | ||
| "current_state": "READY", | ||
| "default": true, | ||
| "is_protected": false, | ||
| "state_change_time": "[TIMESTAMP]" | ||
| }, | ||
| "uid": "[BRANCH_UID]" | ||
| } | ||
|
|
||
| >>> print_requests.py --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/ | ||
|
|
||
| === bundle destroy | ||
| >>> print_requests.py --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/ |
28 changes: 28 additions & 0 deletions
28
acceptance/bundle/resources/postgres_branches/replace_existing/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,28 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| # Belt-and-braces in case bundle destroy was skipped or partially failed. | ||
| $CLI postgres delete-project "projects/test-pg-proj-${UNIQUE_NAME}" 2>/dev/null || true | ||
| rm -f out.requests.txt | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| trace $CLI bundle validate | ||
|
|
||
| rm -f out.requests.txt | ||
| trace $CLI bundle deploy | ||
|
|
||
| # Confirm the implicit production branch is now under management. | ||
| trace $CLI postgres get-branch "projects/test-pg-proj-${UNIQUE_NAME}/branches/production" | jq 'del(.create_time, .update_time, .status.logical_size_bytes)' | ||
|
|
||
| trace print_requests.py --keep --get '//postgres' '^//workspace-files/' '^//workspace/' '^//telemetry-ext' '^//operations/' > out.requests.deploy.$DATABRICKS_BUNDLE_ENGINE.json | ||
|
|
||
| # bundle destroy: the backend rejects independent deletion of the root | ||
| # branch with a MANAGED_BY_PARENT marker; both engines disregard that | ||
| # error and let the project delete cascade-clean the branch. Per-engine | ||
| # output is captured so regressions in either engine's destroy flow show | ||
| # up in the diff. | ||
| title "bundle destroy" | ||
| $CLI bundle destroy --auto-approve > out.destroy.$DATABRICKS_BUNDLE_ENGINE.txt 2>&1 || true | ||
|
|
||
| trace print_requests.py --keep --get '//postgres' '^//workspace-files/' '^//workspace/' '^//telemetry-ext' '^//operations/' > out.requests.destroy.$DATABRICKS_BUNDLE_ENGINE.json |
1 change: 1 addition & 0 deletions
1
acceptance/bundle/resources/postgres_branches/replace_existing/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 @@ | ||
| # All configuration inherited from parent test.toml |
43 changes: 43 additions & 0 deletions
43
acceptance/bundle/resources/postgres_endpoints/replace_existing/databricks.yml.tmpl
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,43 @@ | ||
| bundle: | ||
| name: deploy-postgres-replace-endpoint-$UNIQUE_NAME | ||
|
|
||
| sync: | ||
| paths: [] | ||
|
|
||
| resources: | ||
| # The project's default_endpoint_settings are inherited by every implicit | ||
| # primary endpoint. We set suspend_timeout_duration to 300s here so the | ||
| # primary endpoint of the "develop" branch below would otherwise come up | ||
| # with 300s. | ||
| postgres_projects: | ||
| my_project: | ||
| project_id: test-pg-proj-$UNIQUE_NAME | ||
| display_name: "Replace existing endpoint test" | ||
| pg_version: 16 | ||
| history_retention_duration: "604800s" | ||
| default_endpoint_settings: | ||
| autoscaling_limit_min_cu: 0.5 | ||
| autoscaling_limit_max_cu: 4 | ||
| suspend_timeout_duration: "300s" | ||
|
|
||
| # Non-default branch managed normally — the server auto-provisions its | ||
| # primary read-write endpoint with the project defaults above. | ||
| postgres_branches: | ||
| develop: | ||
| parent: ${resources.postgres_projects.my_project.id} | ||
| branch_id: develop | ||
| no_expiry: true | ||
|
|
||
| # Take over the implicitly-created primary endpoint of the develop branch | ||
| # and override the inherited suspend_timeout_duration (300s) with 600s. A | ||
| # successful deploy with 600s reflected in get-endpoint proves | ||
| # replace_existing applied the spec. | ||
| postgres_endpoints: | ||
| primary: | ||
| parent: ${resources.postgres_branches.develop.id} | ||
| endpoint_id: primary | ||
| replace_existing: true | ||
| endpoint_type: ENDPOINT_TYPE_READ_WRITE | ||
| autoscaling_limit_min_cu: 0.5 | ||
| autoscaling_limit_max_cu: 4 | ||
| suspend_timeout_duration: "600s" |
17 changes: 17 additions & 0 deletions
17
acceptance/bundle/resources/postgres_endpoints/replace_existing/out.destroy.direct.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 @@ | ||
| The following resources will be deleted: | ||
| delete resources.postgres_branches.develop | ||
| delete resources.postgres_endpoints.primary | ||
| delete resources.postgres_projects.my_project | ||
|
|
||
| This action will result in the deletion of the following Lakebase projects along with | ||
| all their branches, databases, and endpoints. All data stored in them will be permanently lost: | ||
| delete resources.postgres_projects.my_project | ||
|
|
||
| This action will result in the deletion of the following Lakebase branches. | ||
| All data stored in them will be permanently lost: | ||
| delete resources.postgres_branches.develop | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/deploy-postgres-replace-endpoint-[UNIQUE_NAME]/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! |
17 changes: 17 additions & 0 deletions
17
acceptance/bundle/resources/postgres_endpoints/replace_existing/out.destroy.terraform.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 @@ | ||
| The following resources will be deleted: | ||
| delete resources.postgres_branches.develop | ||
| delete resources.postgres_endpoints.primary | ||
| delete resources.postgres_projects.my_project | ||
|
|
||
| This action will result in the deletion of the following Lakebase projects along with | ||
| all their branches, databases, and endpoints. All data stored in them will be permanently lost: | ||
| delete resources.postgres_projects.my_project | ||
|
|
||
| This action will result in the deletion of the following Lakebase branches. | ||
| All data stored in them will be permanently lost: | ||
| delete resources.postgres_branches.develop | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/deploy-postgres-replace-endpoint-[UNIQUE_NAME]/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is create-only field, right? In that case, why do we need to track it in STATE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no way to pass it into
DoCreatewithout putting it in the state type.I couldn't find precedent for this in other resources.
Hypothetically if we were to add a create-only side channel, I'm not sure the added complexity is worth it.