-
Notifications
You must be signed in to change notification settings - Fork 228
Add postgres_snapshot_schedules bundle resource #6449
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
janniklasrose
merged 20 commits into
main
from
janniklasrose/postgres-snapshot-schedules
Sep 9, 2026
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
222eaa4
Bump databricks-sdk-go from v0.175.0 to v0.177.0
janniklasrose 686d31b
Add postgres_snapshot_schedules bundle resource
janniklasrose c57ed62
Remove redundant snapshot_schedules acceptance subtests
janniklasrose 48d3fa7
Add snapshotScheduleName helper to normalize a trailing slash
janniklasrose 9970a2c
Assert no drift after removing the snapshot schedule
janniklasrose 120176f
task generate-check
janniklasrose 4400109
Merge remote-tracking branch 'origin/main' into janniklasrose/postgre…
janniklasrose 877b6ae
Wire postgres_snapshot_schedules into resource exhaustiveness checks
janniklasrose c032faa
Fix changelog fragment format for postgres_snapshot_schedules
janniklasrose 2aadf86
Resolve postgres_snapshot_schedules URL to the branch restore page
janniklasrose 6a4da27
Build snapshot schedule URL via workspaceurls helper
janniklasrose 7b40ce7
Fix resource-type list tests and derive snapshot URL from ID
janniklasrose adc3126
Remove postgres_snapshot_schedules from the noURL allowlist
janniklasrose 31f4012
Merge remote-tracking branch 'origin/main' into janniklasrose/postgre…
janniklasrose 21c12cc
Give PostgresSnapshotScheduleConfig a value-receiver MarshalJSON
janniklasrose 77ae3b5
Remove URL handling from postgres_snapshot_schedules
janniklasrose 0ae783f
Only allow snapshot schedules on the root branch
janniklasrose 1cb15f6
Expose the snapshot schedule name via GetName
janniklasrose d985cb0
Merge remote-tracking branch 'origin/main' into janniklasrose/postgre…
janniklasrose ea32dbc
Regenerate PyDABs for postgres_snapshot_schedules
janniklasrose 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_snapshot_schedules` bundle resource for managing a Lakebase Postgres branch's automatic-snapshot schedule (direct deployment engine only). ([#6449](https://github.com/databricks/cli/pull/6449)) |
11 changes: 11 additions & 0 deletions
11
acceptance/bundle/deployment/bind/postgres_snapshot_schedule/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,11 @@ | ||
| bundle: | ||
| name: test-bundle | ||
|
|
||
| resources: | ||
| postgres_snapshot_schedules: | ||
| schedule1: | ||
| branch: projects/test-project/branches/main | ||
| schedule: | ||
| - daily_schedule: | ||
| hour: 3 | ||
| retention: "604800s" |
3 changes: 3 additions & 0 deletions
3
acceptance/bundle/deployment/bind/postgres_snapshot_schedule/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
acceptance/bundle/deployment/bind/postgres_snapshot_schedule/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,30 @@ | ||
|
|
||
| >>> [CLI] bundle deployment bind schedule1 projects/test-project/branches/main/snapshot-schedule --auto-approve | ||
| Successfully bound postgres_snapshot_schedule with an id 'projects/test-project/branches/main/snapshot-schedule' | ||
| 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 snapshot schedules: | ||
| schedule1: | ||
| Name: projects/test-project/branches/main/snapshot-schedule | ||
| URL: (not deployed) | ||
|
|
||
| >>> [CLI] bundle deployment unbind schedule1 | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: test-bundle | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default | ||
| Resources: | ||
| Postgres snapshot schedules: | ||
| schedule1: | ||
| Name: | ||
| URL: (not deployed) | ||
6 changes: 6 additions & 0 deletions
6
acceptance/bundle/deployment/bind/postgres_snapshot_schedule/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,6 @@ | ||
| SCHEDULE_NAME="projects/test-project/branches/main/snapshot-schedule" | ||
| trace $CLI bundle deployment bind schedule1 "${SCHEDULE_NAME}" --auto-approve | ||
| trace $CLI bundle summary | ||
|
|
||
| trace $CLI bundle deployment unbind schedule1 | ||
| trace $CLI bundle summary |
26 changes: 26 additions & 0 deletions
26
acceptance/bundle/deployment/bind/postgres_snapshot_schedule/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,26 @@ | ||
| Cloud = false | ||
|
|
||
| # The snapshot schedule was added to the Postgres API in databricks-sdk-go | ||
| # v0.177.0, which the pinned Terraform provider does not yet include, so there is | ||
| # no databricks_..._snapshot_schedule resource. Run the direct engine only. | ||
| EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] | ||
|
|
||
| Ignore = [ | ||
| ".databricks" | ||
| ] | ||
|
|
||
| [[Server]] | ||
| Pattern = "GET /api/2.0/postgres/projects/test-project/branches/main/snapshot-schedule" | ||
| Response.Body = ''' | ||
| { | ||
| "name": "projects/test-project/branches/main/snapshot-schedule", | ||
| "schedule": [ | ||
| { | ||
| "daily_schedule": { | ||
| "hour": 3 | ||
| }, | ||
| "retention": "604800s" | ||
| } | ||
| ] | ||
| } | ||
| ''' |
22 changes: 22 additions & 0 deletions
22
acceptance/bundle/invariant/configs/postgres_snapshot_schedule.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,22 @@ | ||
| bundle: | ||
| name: test-bundle-$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| postgres_projects: | ||
| project: | ||
| project_id: test-pg-project-$UNIQUE_NAME | ||
| display_name: Test Postgres Project | ||
|
|
||
| postgres_branches: | ||
| foo: | ||
| parent: ${resources.postgres_projects.project.name} | ||
| branch_id: test-branch-$UNIQUE_NAME | ||
| no_expiry: true | ||
|
|
||
| postgres_snapshot_schedules: | ||
| foo: | ||
| branch: ${resources.postgres_branches.foo.name} | ||
| schedule: | ||
| - daily_schedule: | ||
| hour: 3 | ||
| retention: "604800s" |
19 changes: 19 additions & 0 deletions
19
acceptance/bundle/python/postgres_snapshot_schedules-support/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,19 @@ | ||
| bundle: | ||
| name: my_project | ||
|
|
||
| sync: {paths: []} # don't need to copy files | ||
|
|
||
| python: | ||
| resources: | ||
| - "resources:load_resources" | ||
| mutators: | ||
| - "mutators:update_postgres_snapshot_schedule" | ||
|
|
||
| resources: | ||
| postgres_snapshot_schedules: | ||
| my_snapshot_schedule_1: | ||
| branch: "projects/test-project/branches/production" | ||
| schedule: | ||
| - retention: "604800s" | ||
| daily_schedule: | ||
| hour: 3 |
13 changes: 13 additions & 0 deletions
13
acceptance/bundle/python/postgres_snapshot_schedules-support/mutators.py
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 @@ | ||
| from dataclasses import replace | ||
|
|
||
| from databricks.bundles.core import postgres_snapshot_schedule_mutator | ||
| from databricks.bundles.postgres_snapshot_schedules import PostgresSnapshotSchedule | ||
|
|
||
|
|
||
| @postgres_snapshot_schedule_mutator | ||
| def update_postgres_snapshot_schedule( | ||
| schedule: PostgresSnapshotSchedule, | ||
| ) -> PostgresSnapshotSchedule: | ||
| assert isinstance(schedule.branch, str) | ||
|
|
||
| return replace(schedule, branch=f"{schedule.branch} (updated)") |
4 changes: 4 additions & 0 deletions
4
acceptance/bundle/python/postgres_snapshot_schedules-support/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
acceptance/bundle/python/postgres_snapshot_schedules-support/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,40 @@ | ||
|
|
||
| >>> uv run [UV_ARGS] -q [CLI] bundle validate --output json | ||
| { | ||
| "experimental": { | ||
| "python": { | ||
| "mutators": [ | ||
| "mutators:update_postgres_snapshot_schedule" | ||
| ], | ||
| "resources": [ | ||
| "resources:load_resources" | ||
| ] | ||
| } | ||
| }, | ||
| "resources": { | ||
| "postgres_snapshot_schedules": { | ||
| "my_snapshot_schedule_1": { | ||
| "branch": "projects/test-project/branches/production (updated)", | ||
| "schedule": [ | ||
| { | ||
| "daily_schedule": { | ||
| "hour": 3 | ||
| }, | ||
| "retention": "604800s" | ||
| } | ||
| ] | ||
| }, | ||
| "my_snapshot_schedule_2": { | ||
| "branch": "projects/other-project/branches/production (updated)", | ||
| "schedule": [ | ||
| { | ||
| "daily_schedule": { | ||
| "hour": 5 | ||
| }, | ||
| "retention": "604800s" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
acceptance/bundle/python/postgres_snapshot_schedules-support/resources.py
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,20 @@ | ||
| from databricks.bundles.core import Resources | ||
|
|
||
|
|
||
| def load_resources() -> Resources: | ||
| resources = Resources() | ||
|
|
||
| resources.add_postgres_snapshot_schedule( | ||
| "my_snapshot_schedule_2", | ||
| { | ||
| "branch": "projects/other-project/branches/production", | ||
| "schedule": [ | ||
| { | ||
| "retention": "604800s", | ||
| "daily_schedule": {"hour": 5}, | ||
| }, | ||
| ], | ||
| }, | ||
| ) | ||
|
|
||
| return resources |
5 changes: 5 additions & 0 deletions
5
acceptance/bundle/python/postgres_snapshot_schedules-support/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,5 @@ | ||
|
|
||
| trace uv run $UV_ARGS -q $CLI bundle validate --output json | \ | ||
| jq "pick(.experimental.python, .resources)" | ||
|
|
||
| rm -fr .databricks __pycache__ |
7 changes: 7 additions & 0 deletions
7
acceptance/bundle/python/postgres_snapshot_schedules-support/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,7 @@ | ||
| Cloud = false # tests do not interact with APIs | ||
|
|
||
| # postgres_snapshot_schedules only exist in the current version of the wheel | ||
| EnvMatrix.PYDAB_VERSION = ["current"] | ||
|
|
||
| # postgres_snapshot_schedules are only supported on the direct deployment engine | ||
| EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] |
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
22 changes: 22 additions & 0 deletions
22
acceptance/bundle/resources/postgres_snapshot_schedules/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,22 @@ | ||
| bundle: | ||
| name: deploy-pg-ss-basic-$UNIQUE_NAME | ||
|
|
||
| sync: | ||
| paths: [] | ||
|
|
||
| resources: | ||
| postgres_projects: | ||
| my_project: | ||
| project_id: test-pg-proj-$UNIQUE_NAME | ||
| display_name: "Test Project for Snapshot Schedules" | ||
| pg_version: 16 | ||
|
|
||
| postgres_snapshot_schedules: | ||
| main_schedule: | ||
| # Snapshots are only allowed on the project's root branch (the implicitly | ||
| # created "production" branch). | ||
| branch: ${resources.postgres_projects.my_project.id}/branches/production | ||
| schedule: | ||
| - daily_schedule: | ||
| hour: 3 | ||
| retention: "604800s" |
34 changes: 34 additions & 0 deletions
34
acceptance/bundle/resources/postgres_snapshot_schedules/basic/out.requests.create.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 @@ | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule" | ||
| } | ||
| { | ||
| "method": "PATCH", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule", | ||
| "q": { | ||
| "update_mask": "schedule" | ||
| }, | ||
| "body": { | ||
| "schedule": [ | ||
| { | ||
| "daily_schedule": { | ||
| "hour": 3 | ||
| }, | ||
| "retention": "604800s" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/postgres/projects", | ||
| "q": { | ||
| "project_id": "test-pg-proj-[UNIQUE_NAME]" | ||
| }, | ||
| "body": { | ||
| "spec": { | ||
| "display_name": "Test Project for Snapshot Schedules", | ||
| "pg_version": 16 | ||
| } | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
acceptance/bundle/resources/postgres_snapshot_schedules/basic/out.requests.remove.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,20 @@ | ||
| { | ||
| "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/snapshot-schedule" | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule" | ||
| } | ||
| { | ||
| "method": "PATCH", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule", | ||
| "q": { | ||
| "update_mask": "schedule" | ||
| }, | ||
| "body": {} | ||
| } |
33 changes: 33 additions & 0 deletions
33
acceptance/bundle/resources/postgres_snapshot_schedules/basic/out.requests.update.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,33 @@ | ||
| { | ||
| "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]" | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule" | ||
| } | ||
| { | ||
| "method": "GET", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule" | ||
| } | ||
| { | ||
| "method": "PATCH", | ||
| "path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/production/snapshot-schedule", | ||
| "q": { | ||
| "update_mask": "schedule" | ||
| }, | ||
| "body": { | ||
| "schedule": [ | ||
| { | ||
| "daily_schedule": { | ||
| "hour": 5 | ||
| }, | ||
| "retention": "604800s" | ||
| } | ||
| ] | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
acceptance/bundle/resources/postgres_snapshot_schedules/basic/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
Is it expected that it shows not deployed here?
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's no URL - we show the same for other resources that don't have a URL, so out of scope here but I'll take a look if we can return something else (like "not supported")