postgres: Support purge_on_delete on postgres_branches#5801
Draft
pietern wants to merge 17 commits into
Draft
Conversation
Co-authored-by: Isaac
# Conflicts: # libs/structs/structwalk/walktype_test.go
The dyn->typed ForceSendFields routing only handled one level of struct embedding. When a field declared in an SDK spec embedded two levels deep (e.g. PostgresProject -> PostgresProjectConfig -> ProjectSpec) was set to its zero value, its name was recorded in the wrong struct's ForceSendFields. The direct engine then failed to serialize the plan state with "field X cannot be found in struct Y". Route each field's ForceSendFields entry to the struct that actually declares it, at any embedding depth. This affected postgres_projects (enable_pg_native_login: false), postgres_branches, and postgres_endpoints (replace_existing: false). Terraform was unaffected (it serializes via dyn, not the SDK marshaler). Add a unit regression test for the deep-embedding case and a systemic guard that round-trips every registered resource type's zero-value fields, so any future resource using the embedded-spec wrapper pattern is covered automatically. Co-authored-by: Isaac
Adds support for purge_on_delete on Lakebase postgres_branches so bundles can hard-delete a branch on destroy. The flag is passed to the DeleteBranch API call as ?purge=true; when unset, the backend performs a soft delete that can be undone within the branch's retention window. The field is input-only: it is not modeled by the backend resource for branches, and the GET API never returns it. We store it in state purely so DoDelete can apply it on destroy. PrepareState preserves input.ForceSendFields so the structdiff comparison distinguishes "explicit false" from the fictional remote zero, and DoUpdate strips purge_on_delete from the API field mask so a state-only flip doesn't fire an unnecessary remote write. Acceptance tests are direct-engine only for now; the Terraform provider already supports the field but the provider bump that exposes it to DABs has not landed. Co-authored-by: Isaac
# Conflicts: # NEXT_CHANGELOG.md
Bump the pinned Databricks Terraform provider from v1.118.0 to v1.120.0, regenerate bundle/internal/tf/schema (and its ProviderVersion/checksums), and refresh the affected acceptance goldens. Co-authored-by: Isaac
Co-authored-by: Isaac
Co-authored-by: Isaac
# Conflicts: # bundle/terraform_dabs_map/generated.go
Co-authored-by: Isaac
The tf-bump merge (provider 1.120.0) exposes purge_on_delete on databricks_postgres_branch to DABs, so the contrast test now runs on terraform too. The destroy purge contrast is identical across engines (unified out.requests.destroy.json); only the branch-create body diverges (Terraform sends parent in the body, direct as a query param), so the deploy requests are split per-engine. Co-authored-by: Isaac
Co-authored-by: Isaac
…-delete # Conflicts: # NEXT_CHANGELOG.md
Co-authored-by: Isaac
Collaborator
Integration test reportCommit: aecad5b
229 interesting tests: 203 FAIL, 15 SKIP, 8 RECOVERED, 2 KNOWN, 1 flaky
Top 4 slowest tests (at least 2 minutes):
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds support for
purge_on_deleteon Lakebasepostgres_branchesso bundles can hard-delete a branch on destroy. The flag is passed to theDeleteBranchAPI call as?purge=true; when unset, the backend performs a soft delete that can be undone within the branch's retention window. This mirrors the existingpostgres_projectssupport (#5414).The field is input-only: it is not modeled by the backend resource for branches, and the GET API never returns it. We store it in state purely so
DoDeletecan apply it on destroy.PrepareStatepreservesinput.ForceSendFieldsso the structdiff comparison distinguishes "explicit false" from the fictional remote zero, andDoUpdatestripspurge_on_deletefrom the API field mask so a state-only flip doesn't fire an unnecessary remote write.Acceptance tests under
acceptance/bundle/resources/postgres_branches/:purge_on_delete/: deploys ahard_deleteand asoft_deletebranch side by side and asserts the destroy emits?purge=trueand a plainDELETErespectively, on both engines. The destroy purge contrast is identical across engines, soout.requests.destroy.jsonis unified; only the branch-create body diverges (Terraform sendsparentin the body, direct as a query parameter), so the deploy requests are split per-engine.purge_on_delete_transitions/: direct-engine only. Walkspurge_on_deletethrough unset → true → false → unset and records the persisted value at each step; final destroy is a plainDELETE.Notes
DeleteBranchRequest.Purge, and the TF provider bump to 1.120.0 (Bump Terraform provider to v1.120.0 #5792) which exposespurge_on_deleteondatabricks_postgres_branch. Both are merged into this branch and will drop out of the diff once they land on main.ForceSendFieldsrouting fix (direct: Fix state serialization for zero-value fields on deeply-embedded SDK specs #5782); without it, setting any zero-value spec field (e.g.is_protected: false) on a branch would fail state serialization.This pull request and its description were written by Isaac.