Repository navigation
Add postgres_data_apis bundle resource #7160
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
ruslantalpa
wants to merge
17
commits into
main
Choose a base branch
from
ruslantalpa/postgres-data-apis
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.
+2,564
−14
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
842e8ec
Add postgres_data_apis bundle resource
ruslantalpa 609a5c5
Match the testserver Data API fake to the real API
ruslantalpa a2c35e8
Detect postgres_data_apis spec drift by reading the spec from status
ruslantalpa 38e69e9
Add PR link to postgres_data_apis changelog entry
ruslantalpa 2115d85
Report status.url from the testserver Data API fake
ruslantalpa e0716ad
Declare postgres_data_apis status.url a stable output field
ruslantalpa 9aed236
Cover bools, durations and openapi_mode in the Data API invariant config
ruslantalpa b8a1c0e
Describe postgres_data_apis and OpenApiMode in the bundle schema
ruslantalpa eb2b84f
Keep the launchStageOverrides alignment unchanged
ruslantalpa e412b28
Update changelog entry to link #7160
ruslantalpa 12880b2
Use bash 3.2-compatible redirect in postgres_data_api bind test
ruslantalpa 3ab66ef
Skip DMS runs for postgres_data_apis until deployment history accepts it
ruslantalpa b7d7cad
Regenerate postgres_data_apis outputs after rebase onto main
ruslantalpa b83bc7f
Skip DMS runs for the postgres_data_api bind test
ruslantalpa a07dc42
Declare the production branch in the Data API acceptance tests
ruslantalpa 46d77f5
Reject a postgres_data_apis entry that sets only parent
ruslantalpa ab7d1a8
Document Data API field removal and status.url limitations
ruslantalpa 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 @@ | ||
| * Add the `postgres_data_apis` resource (Private Preview) for enabling and configuring the Data API of a Lakebase Postgres database. ([#7160](https://github.com/databricks/cli/pull/7160)) |
10 changes: 10 additions & 0 deletions
10
acceptance/bundle/deployment/bind/postgres_data_api/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: | ||
| postgres_data_apis: | ||
| data_api1: | ||
| parent: projects/test-project/branches/production/databases/test-database | ||
| db_schemas: | ||
| - public | ||
| db_max_rows: 500 |
2 changes: 2 additions & 0 deletions
2
acceptance/bundle/deployment/bind/postgres_data_api/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 = [""] |
94 changes: 94 additions & 0 deletions
94
acceptance/bundle/deployment/bind/postgres_data_api/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,94 @@ | ||
|
|
||
| === Enable the Data API on a database outside the bundle | ||
| === Deploy fails because the Data API is already enabled | ||
| >>> musterr [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Error: cannot create resources.postgres_data_apis.data_api1: Data API is already enabled for this database (409 ALREADY_EXISTS) | ||
|
|
||
| Endpoint: POST [DATABRICKS_URL]/api/2.0/postgres/projects/test-project/branches/production/databases/test-database/data-api | ||
| HTTP Status: 409 Conflict | ||
| API error_code: ALREADY_EXISTS | ||
| API message: Data API is already enabled for this database | ||
|
|
||
| Files: 2 uploaded, 0 deleted | ||
|
|
||
| === Bind adopts the existing Data API | ||
| >>> [CLI] bundle deployment bind data_api1 projects/test-project/branches/production/databases/test-database/data-api --auto-approve | ||
| Successfully bound postgres_data_api with an id 'projects/test-project/branches/production/databases/test-database/data-api' | ||
| Run 'bundle deploy' to deploy changes to your workspace | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: test-bundle | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default | ||
| Resources: | ||
| Postgres Data APIs: | ||
| data_api1: | ||
| Name: projects/test-project/branches/production/databases/test-database/data-api | ||
|
|
||
| >>> [CLI] bundle plan | ||
| update postgres_data_apis.data_api1 | ||
|
|
||
| Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Updated postgres_data_apis.data_api1 | ||
| Files: 0 uploaded, 0 deleted | ||
| Resources: 0 created, 1 changed, 0 deleted, 0 unchanged | ||
|
|
||
| >>> [CLI] postgres get-data-api projects/test-project/branches/production/databases/test-database/data-api | ||
| { | ||
| "name": "projects/test-project/branches/production/databases/test-database/data-api", | ||
| "status": { | ||
| "db_schemas": [ | ||
| "public" | ||
| ], | ||
| "db_max_rows": 500 | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle plan | ||
| Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged | ||
|
|
||
| === Unbind leaves the Data API enabled | ||
| >>> [CLI] bundle deployment unbind data_api1 | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: test-bundle | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default | ||
| Resources: | ||
| Postgres Data APIs: | ||
| data_api1: | ||
| Name: | ||
|
|
||
| >>> [CLI] postgres get-data-api projects/test-project/branches/production/databases/test-database/data-api | ||
| { | ||
| "name": "projects/test-project/branches/production/databases/test-database/data-api" | ||
| } | ||
|
|
||
| === Bind again; destroy turns off the Data API | ||
| >>> [CLI] bundle deployment bind data_api1 projects/test-project/branches/production/databases/test-database/data-api --auto-approve | ||
| Successfully bound postgres_data_api with an id 'projects/test-project/branches/production/databases/test-database/data-api' | ||
| Run 'bundle deploy' to deploy changes to your workspace | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.postgres_data_apis.data_api1 | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default | ||
|
|
||
| Destroy: 1 deleted | ||
|
|
||
| >>> musterr [CLI] postgres get-data-api projects/test-project/branches/production/databases/test-database/data-api | ||
| Error: Data API is not enabled for this database | ||
|
|
||
| >>> [CLI] postgres get-database projects/test-project/branches/production/databases/test-database | ||
| { | ||
| "name": "projects/test-project/branches/production/databases/test-database" | ||
| } |
31 changes: 31 additions & 0 deletions
31
acceptance/bundle/deployment/bind/postgres_data_api/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,31 @@ | ||
| DATABASE_NAME="projects/test-project/branches/production/databases/test-database" | ||
| DATA_API_NAME="${DATABASE_NAME}/data-api" | ||
|
|
||
| title "Enable the Data API on a database outside the bundle" | ||
| $CLI postgres create-project test-project --json '{"spec": {"display_name": "Test Project", "pg_version": 16}}' &> LOG.setup | ||
| $CLI postgres create-database projects/test-project/branches/production --database-id test-database --json '{"spec": {"postgres_database": "app_db", "role": "projects/test-project/branches/production/roles/owner"}}' >> LOG.setup 2>&1 | ||
| $CLI postgres create-data-api "${DATABASE_NAME}" --json '{"spec": {"db_schemas": ["public"]}}' >> LOG.setup 2>&1 | ||
|
|
||
| title "Deploy fails because the Data API is already enabled" | ||
| trace musterr $CLI bundle deploy | ||
|
|
||
| title "Bind adopts the existing Data API" | ||
| # Bind records the config as state. The plan compares it with the spec read back | ||
| # from status, so the configured db_max_rows is applied on the next deploy. | ||
| trace $CLI bundle deployment bind data_api1 "${DATA_API_NAME}" --auto-approve | ||
| trace $CLI bundle summary | ||
| trace $CLI bundle plan | ||
| trace $CLI bundle deploy | ||
| trace $CLI postgres get-data-api "${DATA_API_NAME}" | jq '{name, status: (.status | {db_schemas, db_max_rows})}' | ||
| trace $CLI bundle plan | ||
|
|
||
| title "Unbind leaves the Data API enabled" | ||
| trace $CLI bundle deployment unbind data_api1 | ||
| trace $CLI bundle summary | ||
| trace $CLI postgres get-data-api "${DATA_API_NAME}" | jq '{name}' | ||
|
|
||
| title "Bind again; destroy turns off the Data API" | ||
| trace $CLI bundle deployment bind data_api1 "${DATA_API_NAME}" --auto-approve | ||
| trace $CLI bundle destroy --auto-approve | ||
| trace musterr $CLI postgres get-data-api "${DATA_API_NAME}" | ||
| trace $CLI postgres get-database "${DATABASE_NAME}" | jq '{name}' |
9 changes: 9 additions & 0 deletions
9
acceptance/bundle/deployment/bind/postgres_data_api/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 | ||
|
|
||
| # Deployment history has no "postgres_data_apis." resource-key prefix yet. See dmsResourceTypes in | ||
| # libs/testserver/bundledeployments.go, which mirrors Universe. | ||
| EnvMatrixExclude.no_data_api_dms = ["DMS=true"] | ||
|
|
||
| Ignore = [ | ||
| ".databricks" | ||
| ] |
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
45 changes: 45 additions & 0 deletions
45
acceptance/bundle/invariant/configs/postgres_data_api.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,45 @@ | ||
| bundle: | ||
| name: test-bundle-$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| postgres_projects: | ||
| project: | ||
| project_id: test-pg-project-$UNIQUE_NAME | ||
| display_name: Test Postgres Project | ||
|
|
||
| # The Data API needs a read-write endpoint on the branch. Take over the | ||
| # "production" branch created with the project, which comes with one. | ||
| postgres_branches: | ||
| production: | ||
| parent: ${resources.postgres_projects.project.name} | ||
| branch_id: production | ||
| replace_existing: true | ||
| no_expiry: true | ||
|
|
||
| postgres_roles: | ||
| owner: | ||
| parent: ${resources.postgres_branches.production.name} | ||
| role_id: test-role-$UNIQUE_NAME | ||
| postgres_role: app_role | ||
|
|
||
| postgres_databases: | ||
| database: | ||
| parent: ${resources.postgres_branches.production.name} | ||
| database_id: test-database-$UNIQUE_NAME | ||
| postgres_database: app_db | ||
| role: ${resources.postgres_roles.owner.name} | ||
|
|
||
| postgres_data_apis: | ||
| foo: | ||
| parent: ${resources.postgres_databases.database.name} | ||
| db_schemas: | ||
| - public | ||
| db_max_rows: 1000 # CAN_REMOVE | ||
| server_cors_allowed_origins: # CAN_REMOVE | ||
| - https://app.example.com # CAN_REMOVE | ||
| jwt_cache_max_lifetime: 300s # CAN_REMOVE | ||
| openapi_mode: OPEN_API_MODE_IGNORE_PRIVILEGES # CAN_REMOVE | ||
| # Removing a bool converges like the other fields: the server keeps the | ||
| # last value and status reports it. | ||
| db_aggregates_enabled: false # CAN_REMOVE | ||
| server_timing_enabled: true # CAN_REMOVE |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| resources.postgres_data_apis.*.create_time *time.Time REMOTE | ||
| resources.postgres_data_apis.*.db_aggregates_enabled bool ALL | ||
| resources.postgres_data_apis.*.db_extra_search_path []string ALL | ||
| resources.postgres_data_apis.*.db_extra_search_path[*] string ALL | ||
| resources.postgres_data_apis.*.db_max_rows int ALL | ||
| resources.postgres_data_apis.*.db_schemas []string ALL | ||
| resources.postgres_data_apis.*.db_schemas[*] string ALL | ||
| resources.postgres_data_apis.*.id string INPUT | ||
| resources.postgres_data_apis.*.jwt_cache_max_lifetime *duration.Duration ALL | ||
| resources.postgres_data_apis.*.jwt_role_claim_key string ALL | ||
| resources.postgres_data_apis.*.lifecycle resources.Lifecycle INPUT | ||
| resources.postgres_data_apis.*.lifecycle.depends_on []resources.DependsOn INPUT | ||
| resources.postgres_data_apis.*.lifecycle.depends_on[*] resources.DependsOn INPUT | ||
| resources.postgres_data_apis.*.lifecycle.depends_on[*].resource string INPUT | ||
| resources.postgres_data_apis.*.lifecycle.prevent_destroy bool INPUT | ||
| resources.postgres_data_apis.*.modified_status string INPUT | ||
| resources.postgres_data_apis.*.name string REMOTE | ||
| resources.postgres_data_apis.*.openapi_mode postgres.OpenApiMode ALL | ||
| resources.postgres_data_apis.*.parent string ALL | ||
| resources.postgres_data_apis.*.server_cors_allowed_origins []string ALL | ||
| resources.postgres_data_apis.*.server_cors_allowed_origins[*] string ALL | ||
| resources.postgres_data_apis.*.server_timing_enabled bool ALL | ||
| resources.postgres_data_apis.*.status *postgres.DataApiDataApiStatus REMOTE | ||
| resources.postgres_data_apis.*.status.available_schemas []string REMOTE | ||
| resources.postgres_data_apis.*.status.available_schemas[*] string REMOTE | ||
| resources.postgres_data_apis.*.status.db_aggregates_enabled bool REMOTE | ||
| resources.postgres_data_apis.*.status.db_extra_search_path []string REMOTE | ||
| resources.postgres_data_apis.*.status.db_extra_search_path[*] string REMOTE | ||
| resources.postgres_data_apis.*.status.db_max_rows int REMOTE | ||
| resources.postgres_data_apis.*.status.db_schemas []string REMOTE | ||
| resources.postgres_data_apis.*.status.db_schemas[*] string REMOTE | ||
| resources.postgres_data_apis.*.status.jwt_cache_max_lifetime *duration.Duration REMOTE | ||
| resources.postgres_data_apis.*.status.jwt_role_claim_key string REMOTE | ||
| resources.postgres_data_apis.*.status.openapi_mode postgres.OpenApiMode REMOTE | ||
| resources.postgres_data_apis.*.status.server_cors_allowed_origins []string REMOTE | ||
| resources.postgres_data_apis.*.status.server_cors_allowed_origins[*] string REMOTE | ||
| resources.postgres_data_apis.*.status.server_timing_enabled bool REMOTE | ||
| resources.postgres_data_apis.*.status.url string REMOTE | ||
| resources.postgres_data_apis.*.update_time *time.Time REMOTE | ||
| resources.postgres_data_apis.*.url string INPUT |
41 changes: 41 additions & 0 deletions
41
acceptance/bundle/resources/postgres_data_apis/basic/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,41 @@ | ||
| bundle: | ||
| name: deploy-pg-data-api-$UNIQUE_NAME | ||
|
|
||
| sync: | ||
| paths: [] | ||
|
|
||
| resources: | ||
| postgres_projects: | ||
| my_project: | ||
| project_id: test-pg-proj-$UNIQUE_NAME | ||
| display_name: "Test Project for Data API" | ||
| pg_version: 16 | ||
|
|
||
| # The Data API needs a read-write endpoint on the branch. Take over the | ||
| # "production" branch created with the project, which comes with one. | ||
| postgres_branches: | ||
| production: | ||
| parent: ${resources.postgres_projects.my_project.id} | ||
| branch_id: production | ||
| replace_existing: true | ||
| no_expiry: true | ||
|
|
||
| postgres_roles: | ||
| owner: | ||
| parent: ${resources.postgres_branches.production.id} | ||
| role_id: app-owner | ||
| postgres_role: app_owner | ||
|
|
||
| postgres_databases: | ||
| my_database: | ||
| parent: ${resources.postgres_branches.production.id} | ||
| database_id: my-database | ||
| postgres_database: app_db | ||
| role: ${resources.postgres_roles.owner.id} | ||
|
|
||
| postgres_data_apis: | ||
| my_data_api: | ||
| parent: ${resources.postgres_databases.my_database.name} | ||
| db_schemas: | ||
| - public | ||
| db_max_rows: 100 | ||
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 an implicit dep on the branch; please include it in the config with
replace_existingto pull it in.Same for the other acc tests.