Add clear_cloud_attributes_on_remove to databricks_cluster#5812
Add clear_cloud_attributes_on_remove to databricks_cluster#5812renaudhartert-db wants to merge 4 commits into
clear_cloud_attributes_on_remove to databricks_cluster#5812Conversation
Removing a cloud-attributes block (aws_attributes, azure_attributes, gcp_attributes) from a databricks_cluster was silently suppressed, so the value could not be cleared through Terraform (ES-1927346). This adds an opt-in clear_cloud_attributes_on_remove flag: with it set, removing the whole block produces a real diff and Edit that clears it. Keeping the block, even partially specified, preserves the historical suppression so partially-set blocks do not perpetually diff against platform-returned defaults. Includes the generated common helpers (SetConditionalSuppressDiff) that the resource depends on; these mirror the universe change and reconcile on the next codegen regeneration.
Divyansh-db
left a comment
There was a problem hiding this comment.
Discussed offline, one test case with the flag is missing.
| "github.com/stretchr/testify/mock" | ||
| ) | ||
|
|
||
| // These tests cover the ES-1927346 behavior and the clear_cloud_attributes_on_remove |
There was a problem hiding this comment.
We should not list the internal information here
…est case Remove the internal ticket reference and design-doc mentions from the test file and resource comments. Add the missing clear_cloud_attributes_on_remove = true counterpart to the "unchanged kept block" case, so the behavior table is symmetric across both flag values (proving the flag is inert when a block is present and unchanged). Co-authored-by: Isaac
Unit testsIf this PR is from a fork, the If this PR changes Actions -> Warm Go Cache -> Run workflow -> pr_number = 5812 Re-run the failed check once the cache warming completes. Integration testsIntegration tests don't run automatically for external contributors; an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
Summary
Removing a cloud-attributes block (
aws_attributes,azure_attributes,gcp_attributes) from adatabricks_clusterwas silently suppressed:terraform planreported no changes and the value (e.g.instance_profile_arn) stayed on the cluster, with no way to clear it through Terraform. The cloud-attribute blocks are diff-suppressed to hide the perpetual diff the platform causes by echoing back default cloud attributes the configuration never set. (ES-1927346)This adds an opt-in, per-cluster
clear_cloud_attributes_on_removeflag (defaultfalse, so existing behavior is unchanged). When it istrueand a cloud-attributes block is removed from configuration, the removal produces a real diff andEditthat clears it. Keeping the block, even partially specified, preserves the historical suppression, so a partially-set block does not perpetually diff against platform-returned defaults; only removing the whole block clears.Notes for reviewers
common/customizable_schema.goandcommon/reflect_resource.goare generated (DO NOT EDIT) files. The resource depends on a newSetConditionalSuppressDiffhelper added there. That helper is behavior-preserving for all existing callers: the existingSetSuppressDiff/diffSuppressornow route through it with an always-true predicate. The change is being landed at its generator source separately and will reconcile on the next regeneration; it is included here so the resource change builds and can be reviewed as a unit.Tests
Table-driven unit tests in
clusters/resource_cluster_clear_on_remove_test.gocover the behavior at three altitudes: the diff (both flag values, plus explicit-empty and empty-block edges), the read (server defaults for an unconfigured block are dropped, never stored), and the update (whether the diff produces a clearingEdit).