Skip to content

Support selecting resources for deletion with bundle deploy --select - #7023

Open
andersrexdb wants to merge 1 commit into
mainfrom
select-deletions
Open

andersrexdb wants to merge 1 commit into
mainfrom
select-deletions

Conversation

@andersrexdb

@andersrexdb andersrexdb commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Resolve --select selectors against the computed plan (Plan.FilterToSelected) instead of the config, so resources removed from config and planned for deletion can be selected like any other. The old ResolveSelect mutator is reduced to recording the select_used telemetry flag (renamed MarkSelectUsed).

When a selected resource is being deleted, the plan's closure follows reverse dependency edges: its dependents are deleted too so none are left dangling, while its own dependencies are left untouched — mirroring bundle destroy. A deployed selection still follows forward edges to pull in its dependencies. Grants and permissions sub-nodes move with their parent in both directions.

Deleting a resource whose dependent is still live (still in config, not itself being deleted) is an error before any API delete requests are sent. An invalid --select (a name in neither config nor state) is rejected before the predeploy script runs or any files are uploaded.

Note: When --plan is used alongside a --select that doesn't match the selectors the plan was built with, a warning is emitted. The plan serializes was_filtered and selectors so a pre-filtered plan file can be passed to bundle deploy --plan without re-specifying --select.

Tests

Added unit tests (TestFilterToSelected_*) and acceptance tests under acceptance/bundle/select.

This pull request and its description were written by Isaac.

@andersrexdb
andersrexdb requested review from a team as code owners October 12, 2026 12:40
@andersrexdb
andersrexdb requested a review from denik October 12, 2026 12:40
@github-actions github-actions Bot added the DABs DABs related issues label Oct 12, 2026
andersrexdb added a commit that referenced this pull request Oct 12, 2026
Add the trailing PR link required by the changelog validation so the
Changelog Preview workflow passes.

Co-authored-by: Isaac <no-reply@databricks.com>
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 30adca7

Run: 38715536177

Env ❌​FAIL 🔄​flaky ✅​pass 🙈​skip Time
❌​ aws linux-2core-8gb 1 3 281 18 7:48
❌​ aws-windows-latest-4core-16gb 1 3 283 16 7:55
🔄​ azure linux-2core-8gb 3 281 18 6:23
🔄​ azure-windows-latest-4core-16gb 3 283 16 5:13
❌​ gcp linux-2core-8gb 3 282 18 6:48
🔄​ gcp-windows-latest-4core-16gb 3 284 16 5:55
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
❌​ TestAccept 🔄​f 🔄​f 🔄​f 🔄​f ❌​F 🔄​f
❌​ TestAccept/bundle/select/deletion_dependents 🔄​f 🔄​f 🔄​f 🔄​f ❌​F 🔄​f
❌​ TestAccept/bundle/select/deletion_dependents/DMS= ❌​F ❌​F ✅​p ✅​p ✅​p 🔄​f
❌​ TestAccept/bundle/select/deletion_dependents/DMS=true 🔄​f 🔄​f 🔄​f 🔄​f ❌​F ✅​p

Resolve --select selectors against the computed plan (Plan.FilterToSelected)
instead of the config, so resources removed from config and planned for deletion
can be selected like any other. The old ResolveSelect mutator is reduced to
recording the select_used telemetry flag (renamed MarkSelectUsed).

When a selected resource is being deleted, the plan's closure follows reverse
dependency edges: its dependents are deleted too so none are left dangling, while
its own dependencies are left untouched — mirroring bundle destroy. A deployed
selection still follows forward edges to pull in its dependencies. Grants and
permissions sub-nodes move with their parent in both directions.

Deleting a resource whose dependent is still live (still in config, not itself
being deleted) is an error before any API delete requests are sent. An invalid
--select (a name in neither config nor state) is rejected before the predeploy
script runs or any files are uploaded.

When --plan is used alongside a --select that doesn't match the selectors the
plan was built with, a warning is emitted. The plan serializes was_filtered and
selectors so a pre-filtered plan file can be passed to bundle deploy --plan
without re-specifying --select.

Co-authored-by: Isaac <no-reply@databricks.com>
@@ -0,0 +1 @@
* `databricks bundle deploy --select` and `bundle plan --select` can now select resources removed from config, so a selective deploy applies their deletion. Deleting a selected resource also deletes its dependents that are also being removed, mirroring `bundle destroy`. Selecting a resource for deletion errors if a live resource still references it, preventing a broken bundle. An unqualified `--select <name>` is ambiguous when a resource of the same name exists in both config and state as different types. ([#7023](https://github.com/databricks/cli/pull/7023))

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 typically use shorter messages here, e.g. PR title is good enough.


# A resource removed from config is selectable by name, like any created or updated
# one. The plan is filtered to just its deletion.
trace $CLI bundle plan --select jobs.gone

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.

should we parametrize selector? $SELECTOR

in test.toml: EnvMatrix.SELECTOR = ["jobs.gone", "gone"]

Resources: 3 created, 0 changed, 0 deleted, 0 unchanged

>>> [CLI] bundle plan --select jobs.producer
Error: cannot delete jobs.producer: jobs.consumer still references it; remove the reference or also remove jobs.consumer from the config

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.

Should not this configuration fail even without --select? There is a reference to a missing resource, the whole config is not valid.

This branch has not been deployed

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

Labels

DABs DABs related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants