Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@

### Dependency updates
* Bump `github.com/databricks/databricks-sdk-go` from v0.141.0 to v0.147.0 ([#5636](https://github.com/databricks/cli/pull/5636)).
* Bump Terraform provider from v1.117.0 to v1.118.0 ([#5637](https://github.com/databricks/cli/pull/5637)).

### API Changes
17 changes: 17 additions & 0 deletions acceptance/bin/print_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,20 @@ def main():
help="Collapse consecutive duplicate requests (like uniq), e.g. repeated GET polls",
)
parser.add_argument("--oneline", action="store_true", help="Print output with one request per line")
parser.add_argument(
"--del-body",
action="append",
default=[],
metavar="FIELDS",
help="Comma-separated body fields to delete from each request (repeatable). Use for "
"body fields that diverge between deployment engines, e.g. identity fields the "
"terraform provider serializes into the body but the direct engine sends as query params.",
)
parser.add_argument("--fname", default="out.requests.txt")
args = parser.parse_args()

del_body_fields = [field for group in args.del_body for field in group.split(",")]

test_tmp_dir = os.environ.get("TEST_TMP_DIR")
if test_tmp_dir:
requests_file = Path(test_tmp_dir) / args.fname
Expand All @@ -207,6 +218,12 @@ def main():

requests = read_json_many(data)
filtered_requests = filter_requests(requests, args.path_filters, args.get, args.sort, args.unique)

for req in filtered_requests:
body = req.get("body")
if isinstance(body, dict):
for field in del_body_fields:
body.pop(field, None)
if args.verbose:
print(
f"Read {len(data)} chars, {len(requests)} requests, {len(filtered_requests)} after filtering",
Expand Down
4 changes: 2 additions & 2 deletions acceptance/bundle/migrate/runas/out.create_requests.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"headers": {
"User-Agent": [
"databricks-tf-provider/1.117.0 databricks-sdk-go/[SDK_VERSION] go/1.25.8 os/[OS] cli/[DEV_VERSION] terraform/1.5.5 sdk/sdkv2 resource/pipeline auth/pat"
"databricks-tf-provider/1.118.0 databricks-sdk-go/[SDK_VERSION] go/1.25.8 os/[OS] cli/[DEV_VERSION] terraform/1.5.5 sdk/sdkv2 resource/pipeline auth/pat"
]
},
"method": "POST",
Expand Down Expand Up @@ -32,7 +32,7 @@
{
"headers": {
"User-Agent": [
"databricks-tf-provider/1.117.0 databricks-sdk-go/[SDK_VERSION] go/1.25.8 os/[OS] cli/[DEV_VERSION] terraform/1.5.5 sdk/sdkv2 resource/permissions auth/pat"
"databricks-tf-provider/1.118.0 databricks-sdk-go/[SDK_VERSION] go/1.25.8 os/[OS] cli/[DEV_VERSION] terraform/1.5.5 sdk/sdkv2 resource/permissions auth/pat"
]
},
"method": "PUT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Resources:
Name: Test Project for Branch
URL: (not deployed)

>>> print_requests.py --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/
>>> print_requests.py --del-body project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/resources/postgres_branches/basic/script
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ trace $CLI postgres get-branch "${branch_name}" | jq 'del(.create_time, .update_
trace $CLI bundle summary

# Filter requests to only show postgres operations (exclude workspace, telemetry, and operation polling)
trace print_requests.py --keep --get '//postgres' '^//workspace-files/' '^//workspace/' '^//telemetry-ext' '^//operations/' > out.requests.$DATABRICKS_BUNDLE_ENGINE.json
trace print_requests.py --del-body project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id --keep --get '//postgres' '^//workspace-files/' '^//workspace/' '^//telemetry-ext' '^//operations/' > out.requests.$DATABRICKS_BUNDLE_ENGINE.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"method": "POST",
"path": "/api/2.0/postgres/projects",
"q": {
"project_id": "test-pg-proj-[UNIQUE_NAME]"
},
"body": {
"spec": {
"default_endpoint_settings": {
Expand All @@ -10,22 +15,17 @@
"history_retention_duration": "604800s",
"pg_version": 16
}
},
"method": "POST",
"path": "/api/2.0/postgres/projects",
"q": {
"project_id": "test-pg-proj-[UNIQUE_NAME]"
}
}
{
"body": {
"spec": {
"no_expiry": true
}
},
"method": "POST",
"path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches",
"q": {
"branch_id": "old-branch-[UNIQUE_NAME]"
},
"body": {
"spec": {
"no_expiry": true
}
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"path": "/api/2.0/postgres/[MAIN_ID]"
}
{
"body": {
"spec": {
"no_expiry": true
}
},
"method": "POST",
"path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches",
"q": {
"branch_id": "new-branch-[UNIQUE_NAME]"
},
"body": {
"spec": {
"no_expiry": true
}
}
}
12 changes: 3 additions & 9 deletions acceptance/bundle/resources/postgres_branches/recreate/script
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ trace $CLI bundle deploy

branch_id_1=`read_id.py main`

print_requests() {
local name=$1
jq --sort-keys 'select(.method != "GET" and (.path | contains("/postgres")))' < out.requests.txt > out.requests.${name}.$DATABRICKS_BUNDLE_ENGINE.txt
rm -f out.requests.txt
}

print_requests create
print_requests.py --del-body parent,project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id '//postgres' '^//workspace-files/' '^//workspace/' '^//telemetry-ext' '^//operations/' > out.requests.create.txt

title "Change branch_id (should trigger recreation in direct, update in terraform)"
sed "s/old-branch-${UNIQUE_NAME}/new-branch-${UNIQUE_NAME}/" databricks.yml > databricks.yml.new
Expand All @@ -39,7 +33,7 @@ trace cat databricks.yml
$CLI bundle plan > out.plan.txt 2>&1
trace $CLI bundle deploy --auto-approve

print_requests update
print_requests.py --del-body parent,project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id '//postgres' '^//workspace-files/' '^//workspace/' '^//telemetry-ext' '^//operations/' > out.requests.update.txt

title "Fetch new branch ID"
branch_id_2=`read_id.py main`
Expand All @@ -49,7 +43,7 @@ $CLI postgres get-branch $branch_id_2 | jq 'del(.create_time, .update_time, .sta
title "Destroy and verify cleanup"
trace $CLI bundle destroy --auto-approve

print_requests destroy
print_requests.py --del-body parent,project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id '//postgres' '^//workspace-files/' '^//workspace/' '^//telemetry-ext' '^//operations/' > out.requests.destroy.txt

# Clean up any orphaned old branch (terraform doesn't delete it on recreation)
$CLI postgres delete-branch $branch_id_1 2>/dev/null || true
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Deployment complete!
"uid": "[BRANCH_UID]"
}

>>> print_requests.py --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/
>>> print_requests.py --del-body project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/

=== bundle destroy
>>> print_requests.py --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/
>>> print_requests.py --del-body project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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
trace print_requests.py --del-body project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id --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
Expand All @@ -25,4 +25,4 @@ trace print_requests.py --keep --get '//postgres' '^//workspace-files/' '^//work
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
trace print_requests.py --del-body project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id --keep --get '//postgres' '^//workspace-files/' '^//workspace/' '^//telemetry-ext' '^//operations/' > out.requests.destroy.$DATABRICKS_BUNDLE_ENGINE.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Deploying resources...
Updating deployment state...
Deployment complete!

>>> print_requests.py --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/
>>> print_requests.py --del-body project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/

>>> [CLI] postgres get-branch [DEV_BRANCH_ID]
{
Expand Down Expand Up @@ -55,7 +55,7 @@ Deploying resources...
Updating deployment state...
Deployment complete!

>>> print_requests.py --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/
>>> print_requests.py --del-body project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/

=== Update is_protected to true and re-deploy
>>> update_file.py databricks.yml is_protected: false is_protected: true
Expand Down Expand Up @@ -99,7 +99,7 @@ Deploying resources...
Updating deployment state...
Deployment complete!

>>> print_requests.py --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/
>>> print_requests.py --del-body project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/

>>> [CLI] postgres get-branch [DEV_BRANCH_ID]
{
Expand Down Expand Up @@ -135,7 +135,7 @@ Deploying resources...
Updating deployment state...
Deployment complete!

>>> print_requests.py --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/
>>> print_requests.py --del-body project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/

>>> [CLI] postgres get-branch [DEV_BRANCH_ID]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trap cleanup EXIT

print_requests() {
local name=$1
trace print_requests.py --keep --get '//postgres' '^//workspace-files/' '^//workspace/' '^//telemetry-ext' '^//operations/' > out.requests.${name}.$DATABRICKS_BUNDLE_ENGINE.json
trace print_requests.py --del-body project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id --keep --get '//postgres' '^//workspace-files/' '^//workspace/' '^//telemetry-ext' '^//operations/' > out.requests.${name}.$DATABRICKS_BUNDLE_ENGINE.json
rm -f out.requests.txt
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Resources:
Name: Test Project for Catalog
URL: (not deployed)

>>> print_requests.py --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/
>>> print_requests.py --del-body project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/resources/postgres_catalogs/basic/script
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ trace $CLI postgres get-catalog "${catalog_name}" | jq 'del(.create_time, .updat
trace $CLI bundle summary

# Filter requests to only show postgres operations (exclude workspace, telemetry, and operation polling).
trace print_requests.py --keep --get '//postgres' '^//workspace-files/' '^//workspace/' '^//telemetry-ext' '^//operations/' > out.requests.json
trace print_requests.py --del-body project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id --keep --get '//postgres' '^//workspace-files/' '^//workspace/' '^//telemetry-ext' '^//operations/' > out.requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Resources:
Name:
URL: (not deployed)

>>> print_requests.py --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/
>>> print_requests.py --del-body project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id --keep --get //postgres ^//workspace-files/ ^//workspace/ ^//telemetry-ext ^//operations/

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ trace $CLI postgres get-database "${database_name}" | jq 'del(.create_time, .upd
trace $CLI bundle summary

# Filter requests to only show postgres operations (exclude workspace, telemetry, and operation polling)
trace print_requests.py --keep --get '//postgres' '^//workspace-files/' '^//workspace/' '^//telemetry-ext' '^//operations/' > out.requests.$DATABRICKS_BUNDLE_ENGINE.json
trace print_requests.py --del-body project_id,branch_id,endpoint_id,database_id,role_id,catalog_id,synced_table_id --keep --get '//postgres' '^//workspace-files/' '^//workspace/' '^//telemetry-ext' '^//operations/' > out.requests.$DATABRICKS_BUNDLE_ENGINE.json
Loading
Loading