Skip to content

Add clear_cloud_attributes_on_remove to databricks_cluster#5812

Open
renaudhartert-db wants to merge 4 commits into
mainfrom
cluster-clear-cloud-attributes-on-remove
Open

Add clear_cloud_attributes_on_remove to databricks_cluster#5812
renaudhartert-db wants to merge 4 commits into
mainfrom
cluster-clear-cloud-attributes-on-remove

Conversation

@renaudhartert-db

Copy link
Copy Markdown
Contributor

Summary

Removing a cloud-attributes block (aws_attributes, azure_attributes, gcp_attributes) from a databricks_cluster was silently suppressed: terraform plan reported 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_remove flag (default false, so existing behavior is unchanged). When it is true and a cloud-attributes block is removed from configuration, the removal produces a real diff and Edit that 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.go and common/reflect_resource.go are generated (DO NOT EDIT) files. The resource depends on a new SetConditionalSuppressDiff helper added there. That helper is behavior-preserving for all existing callers: the existing SetSuppressDiff/diffSuppressor now 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.go cover 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 clearing Edit).

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.
@renaudhartert-db renaudhartert-db requested review from a team as code owners June 16, 2026 12:42
@renaudhartert-db renaudhartert-db requested review from parthban-db and removed request for a team June 16, 2026 12:42
@renaudhartert-db renaudhartert-db requested review from Divyansh-db and removed request for parthban-db June 16, 2026 12:51

@Divyansh-db Divyansh-db left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@github-actions

Copy link
Copy Markdown
Contributor

Unit tests

If this PR is from a fork, the tests check runs offline against a pre-warmed Go module cache because fork PRs cannot authenticate to the internal Go module proxy.

If this PR changes go.mod or go.sum, the tests check will fail until a maintainer warms the cache for it:

Actions -> Warm Go Cache -> Run workflow -> pr_number = 5812

Re-run the failed check once the cache warming completes.

Integration tests

Integration tests don't run automatically for external contributors; an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/terraform

Inputs:

  • PR number: 5812
  • Commit SHA: 310eda4ab02c224f702d98054e49f9afda34d0a5

Checks will be approved automatically on success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants