Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
bundle:
name: remove-is-protected-$UNIQUE_NAME

sync:
paths: []

resources:
postgres_projects:
my_project:
project_id: test-pg-proj-$UNIQUE_NAME
display_name: "Test Project for Branch Protection Removal"
pg_version: 16
history_retention_duration: 604800s

postgres_branches:
main:
parent: ${resources.postgres_projects.my_project.id}
branch_id: main
no_expiry: true
is_protected: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/remove-is-protected-[UNIQUE_NAME]/default/files...
Error: cannot update resources.postgres_branches.main: updating id=projects/test-pg-proj-[UNIQUE_NAME]/branches/main: Field 'spec.is_protected' is in update_mask but not provided in request (400 INVALID_PARAMETER_VALUE)

Endpoint: PATCH [DATABRICKS_URL]/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/main?update_mask=spec.is_protected
HTTP Status: 400 Bad Request
API error_code: INVALID_PARAMETER_VALUE
API message: Field 'spec.is_protected' is in update_mask but not provided in request

Files: 0 uploaded, 0 deleted

Exit code: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"is_protected": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"action": "update",
"changes": {
"is_protected": {
"action": "update",
"old": true,
"remote": true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"action": "update",
"changes": {
"is_protected": {
"action": "update",
"old": true,
"remote": true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"method": "PATCH",
"path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/main",
"q": {
"update_mask": "spec.is_protected"
},
"body": {
"spec": {
"no_expiry": true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cloud = true
EnvMatrix.DMS = ["", "true"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

=== Initial deployment

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/remove-is-protected-[UNIQUE_NAME]/default/files...
Created postgres_branches.main
Created postgres_projects.my_project
Files: 0 uploaded, 0 deleted
Resources: 2 created, 0 changed, 0 deleted, 0 unchanged

>>> [CLI] postgres get-branch projects/test-pg-proj-[UNIQUE_NAME]/branches/main
{
"is_protected": true
}

=== Remove is_protected: true

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.postgres_branches.main
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.main

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/remove-is-protected-[UNIQUE_NAME]/default

Destroy: 2 deleted
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
envsubst < databricks.yml.tmpl > databricks.yml

cleanup() {
$CLI postgres update-branch "projects/test-pg-proj-${UNIQUE_NAME}/branches/main" spec.is_protected --json '{"spec": {"is_protected": false}}' &> LOG.unprotect || true
trace $CLI bundle destroy --auto-approve
rm -f "$OUT_REQUESTS"
}
trap cleanup EXIT

# is_protected is a bool that defaults to false: remove it after setting it to true.
# Each step records whether the change reaches the backend: the planned changes, the
# deploy outcome, the PATCH it sent, the resource read back, and the plan that follows.
step() {
local name=$1
$CLI bundle plan -o json | nostamp | jq '.plan."resources.postgres_branches.main" | {action, changes}' > out.plan.$name.json
errcode $CLI bundle deploy &> out.deploy.$name.txt
print_requests.py --del-body project_id,branch_id,endpoint_id,role_id //postgres --method PATCH > out.requests.$name.json
$CLI postgres get-branch "projects/test-pg-proj-${UNIQUE_NAME}/branches/main" | jq '.status | {is_protected}' > out.get.$name.json
$CLI bundle plan -o json | nostamp | jq '.plan."resources.postgres_branches.main" | {action, changes}' > out.plan.after_$name.json
}

title "Initial deployment"
trace $CLI bundle deploy
rm -f "$OUT_REQUESTS"
trace $CLI postgres get-branch "projects/test-pg-proj-${UNIQUE_NAME}/branches/main" | jq '.status | {is_protected}'

title "Remove is_protected: true"
update_file.py databricks.yml "$(printf ' is_protected: true\n')" ""
step remove
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Verified against a real workspace on 2026-11-19: the direct engine masks spec.is_protected and omits it from
# the body, and the API rejects a masked scalar with no value. The old value stays in state, so
# out.plan.after_remove.json shows the removal pending again and every later deploy fails the same way.
Badness = "Removing is_protected fails: the field is named in update_mask but omitted from the body, which the API rejects"
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
bundle:
name: remove-disabled-$UNIQUE_NAME

sync:
paths: []

resources:
postgres_projects:
my_project:
project_id: test-pg-proj-$UNIQUE_NAME
display_name: "Test Project for Endpoint Disabled Removal"
pg_version: 16
history_retention_duration: 604800s

postgres_branches:
main:
parent: ${resources.postgres_projects.my_project.id}
branch_id: main
no_expiry: true

postgres_endpoints:
my_endpoint:
parent: ${resources.postgres_branches.main.id}
endpoint_id: my-endpoint
endpoint_type: ENDPOINT_TYPE_READ_ONLY
autoscaling_limit_min_cu: 0.5
autoscaling_limit_max_cu: 2
disabled: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/remove-disabled-[UNIQUE_NAME]/default/files...
Error: cannot update resources.postgres_endpoints.my_endpoint: updating id=projects/test-pg-proj-[UNIQUE_NAME]/branches/main/endpoints/my-endpoint: Field 'spec.disabled' is in update_mask but not provided in request (400 INVALID_PARAMETER_VALUE)

Endpoint: PATCH [DATABRICKS_URL]/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/main/endpoints/my-endpoint?update_mask=spec.disabled
HTTP Status: 400 Bad Request
API error_code: INVALID_PARAMETER_VALUE
API message: Field 'spec.disabled' is in update_mask but not provided in request

Files: 0 uploaded, 0 deleted

Exit code: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"disabled": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"action": "update",
"changes": {
"disabled": {
"action": "update",
"old": true,
"remote": true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"action": "update",
"changes": {
"disabled": {
"action": "update",
"old": true,
"remote": true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"method": "PATCH",
"path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/main/endpoints/my-endpoint",
"q": {
"update_mask": "spec.disabled"
},
"body": {
"spec": {
"autoscaling_limit_max_cu": 2,
"autoscaling_limit_min_cu": 0.5,
"endpoint_type": "ENDPOINT_TYPE_READ_ONLY"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cloud = true
EnvMatrix.DMS = ["", "true"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

=== Initial deployment

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/remove-disabled-[UNIQUE_NAME]/default/files...
Created postgres_branches.main
Created postgres_endpoints.my_endpoint
Created postgres_projects.my_project
Files: 0 uploaded, 0 deleted
Resources: 3 created, 0 changed, 0 deleted, 0 unchanged

>>> [CLI] postgres get-endpoint projects/test-pg-proj-[UNIQUE_NAME]/branches/main/endpoints/my-endpoint
{
"disabled": true
}

=== Remove disabled: true

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.postgres_branches.main
delete resources.postgres_endpoints.my_endpoint
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.main

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/remove-disabled-[UNIQUE_NAME]/default

Destroy: 3 deleted
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
envsubst < databricks.yml.tmpl > databricks.yml

cleanup() {
trace $CLI bundle destroy --auto-approve
rm -f "$OUT_REQUESTS"
}
trap cleanup EXIT

# disabled is a bool that defaults to false: remove it after setting it to true.
# Each step records whether the change reaches the backend: the planned changes, the
# deploy outcome, the PATCH it sent, the resource read back, and the plan that follows.
step() {
local name=$1
$CLI bundle plan -o json | nostamp | jq '.plan."resources.postgres_endpoints.my_endpoint" | {action, changes}' > out.plan.$name.json
errcode $CLI bundle deploy &> out.deploy.$name.txt
print_requests.py --del-body project_id,branch_id,endpoint_id,role_id //postgres --method PATCH > out.requests.$name.json
$CLI postgres get-endpoint "projects/test-pg-proj-${UNIQUE_NAME}/branches/main/endpoints/my-endpoint" | jq '.status | {disabled}' > out.get.$name.json
$CLI bundle plan -o json | nostamp | jq '.plan."resources.postgres_endpoints.my_endpoint" | {action, changes}' > out.plan.after_$name.json
}

title "Initial deployment"
trace $CLI bundle deploy
rm -f "$OUT_REQUESTS"
trace $CLI postgres get-endpoint "projects/test-pg-proj-${UNIQUE_NAME}/branches/main/endpoints/my-endpoint" | jq '.status | {disabled}'

title "Remove disabled: true"
update_file.py databricks.yml "$(printf ' disabled: true\n')" ""
step remove
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Verified against a real workspace on 2026-11-19: the direct engine masks spec.disabled and omits it from
# the body, and the API rejects a masked scalar with no value. The old value stays in state, so
# out.plan.after_remove.json shows the removal pending again and every later deploy fails the same way.
Badness = "Removing disabled fails: the field is named in update_mask but omitted from the body, which the API rejects"
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
bundle:
name: remove-pg-settings-key-$UNIQUE_NAME

sync:
paths: []

resources:
postgres_projects:
my_project:
project_id: test-pg-proj-$UNIQUE_NAME
display_name: "Test Project for Endpoint pg_settings Key Removal"
pg_version: 16
history_retention_duration: 604800s

postgres_branches:
main:
parent: ${resources.postgres_projects.my_project.id}
branch_id: main
no_expiry: true

postgres_endpoints:
my_endpoint:
parent: ${resources.postgres_branches.main.id}
endpoint_id: my-endpoint
endpoint_type: ENDPOINT_TYPE_READ_ONLY
autoscaling_limit_min_cu: 0.5
autoscaling_limit_max_cu: 2
settings:
pg_settings:
statement_timeout: "8000"
lock_timeout: "5000"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/remove-pg-settings-key-[UNIQUE_NAME]/default/files...
Updated postgres_endpoints.my_endpoint
Files: 0 uploaded, 0 deleted
Resources: 0 created, 1 changed, 0 deleted, 2 unchanged
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"settings": {
"pg_settings": {
"statement_timeout": "8000"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"action": "skip",
"changes": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"action": "update",
"changes": {
"settings.pg_settings['lock_timeout']": {
"action": "update",
"old": "5000",
"remote": "5000"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"method": "PATCH",
"path": "/api/2.0/postgres/projects/test-pg-proj-[UNIQUE_NAME]/branches/main/endpoints/my-endpoint",
"q": {
"update_mask": "spec.settings.pg_settings"
},
"body": {
"spec": {
"autoscaling_limit_max_cu": 2,
"autoscaling_limit_min_cu": 0.5,
"endpoint_type": "ENDPOINT_TYPE_READ_ONLY",
"settings": {
"pg_settings": {
"statement_timeout": "8000"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cloud = true
EnvMatrix.DMS = ["", "true"]
Loading
Loading