Skip to content

acc: record that a rejected delete drops the resource from state in bundle/destroy/delete-error - #7930

Merged
denik merged 3 commits into
mainfrom
denik/cov-delete-err-test
Nov 26, 2026
Merged

denik merged 3 commits into
mainfrom
denik/cov-delete-err-test

Conversation

@denik

@denik denik commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Changes

New test acceptance/bundle/destroy/delete-error that records how deploy and destroy handle a job delete the backend rejects (400 INVALID_PARAMETER_VALUE, injected with fault.py):

  • bundle deploy after removing a job from the config prints Deleted jobs.bar and exits 0; the job still exists and is no longer in state.
  • bundle destroy prints Destroy: 1 deleted and exits 0 and removes the state; the job still exists, untracked.

Badness in test.toml says what should happen instead: both commands fail with the delete error and keep the resource in state, as the DMS=true run already does. The DMS=true variant is excluded for now because its output differs; the fix PR (stacked on this one) re-enables it.

Fix: #7931

Why

A delete that fails this way leaves a resource in the workspace that no bundle tracks, while the CLI reports success. New small test directory (no existing test sets up a delete fault for a removed resource); runtime about 0.5s per variant.

This PR was created by analyzing coverage gaps.

Coverage: bundle/direct/apply.go, (*DeploymentUnit).Delete, the branch for a delete error that is not missing, managed-by-parent or permission-denied.

Tests

go test ./acceptance -run TestAccept/bundle/destroy/delete-error

AI agent (opus5.5, isaac_claude)

This pull request and its description were written by Isaac.

…undle/destroy/delete-error

When the backend rejects a delete with an error other than not-found or
permission-denied, deploy and destroy without deployment history drop the
resource from state and succeed, leaving it in the workspace untracked.

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions github-actions Bot added DABs DABs related issues test-only-fix PRs that update failing of flaky tests without changing CLI code. labels Nov 24, 2026
@denik
denik added this pull request to stack #7932 November 24, 2026 15:13
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Commit: 6f480ae3b | Workflow run

Regression test report

Selected 1 changed tests (limit=20, 0 not selected)

1 tests: regression=0 unreleased=0 coverage=1 failing=0
test branch main (0c71683) latest (v1.28.0)
TestAccept/bundle/destroy/delete-error ✅ ✅ ✅

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: 6f480ae

Run: 45580453589

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 272 20 5:17
💚​ aws-windows-latest-4core-16gb 1 274 18 3:15
💚​ azure linux-2core-8gb 1 271 20 4:43
💚​ azure-windows-latest-4core-16gb 1 273 18 2:28
💚​ gcp linux-2core-8gb 1 272 20 5:17
💚​ gcp-windows-latest-4core-16gb 1 274 18 3:27
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 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 5 slowest tests (at least 2 minutes):
duration env testname
4:05 aws linux-2core-8gb TestAccept
3:28 azure linux-2core-8gb TestAccept
3:25 gcp linux-2core-8gb TestAccept
2:13 gcp-windows-latest-4core-16gb TestAccept
2:01 aws-windows-latest-4core-16gb TestAccept

@denik
denik marked this pull request as ready for review November 24, 2026 15:42
@denik
denik requested review from a team as code owners November 24, 2026 15:43

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review at 0fcadd0. Each finding was verified against the code.

No blocking issues found. 4 non-blocking comment(s) and 1 question(s) below.

This PR adds acceptance/bundle/destroy/delete-error, which records that a job delete rejected with 400 is dropped from state on both deploy and destroy while the CLI reports success. The Badness entry marks this as wrong and the DMS=true variant is turned off until the stacked fix lands. The test does what it says. What's left is small: the script uses inline jq where the testing rules ask for the acceptance/bin helpers, and a few toml and wording details could be tidied.

Questions

  1. EnvMatrix.DMS = [] turns off the DMS=true run that acceptance/bundle/test.toml enables for every bundle test. That run takes the branch that already returns the delete error (apply.go:315-319), so the correct behaviour isn't recorded anywhere and the current golden pins the wrong one. Should this test keep both variants with EnvVaryOutput = "DMS", so the fix shows up as a golden diff, or land together with the fix in #7931? (non-blocking)

Co-authored-by: Isaac <no-reply@databricks.com>
@denik

denik commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

On the question about EnvMatrix.DMS = []: this is the test half of a stack, and the fix (#7931) removes that line, so both variants run and share one golden there. The fix PR's diff of output.txt is where the correct behavior shows up. I kept this PR's golden on the wrong behavior with Badness rather than adding EnvVaryOutput, which would be removed again in the next PR.

AI agent (opus5.5, isaac_claude)

@Sankalp-Mittal Sankalp-Mittal 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.

[AI Generated] Review by review-factory (Claude Opus 5.5 + Claude Sonnet 5.5 + Claude Opus 5.5, cross-verified). Only points the reviewers agreed on are posted.

No issues found.

@denik
denik added this pull request to the merge queue Nov 26, 2026
Merged via the queue into main with commit 30ce017 Nov 26, 2026
27 checks passed
@denik
denik deleted the denik/cov-delete-err-test branch November 26, 2026 12:19
stevenayers pushed a commit to stevenayers/cli that referenced this pull request Nov 28, 2026
…atabricks#7931)

## Changes

`(*DeploymentUnit).Delete` returns the delete error again when the
backend rejects a delete with an error that is not missing,
managed-by-parent or permission-denied, and a re-read does not show the
resource gone. Before, without deployment history, it fell through to
dropping the resource from state: `bundle destroy` and `bundle deploy`
(for a resource removed from the config) reported success while the
resource stayed in the workspace, untracked.

This is a regression from databricks#6094 (7bf1485), which changed the final

```go
} else {
	return fmt.Errorf("deleting id=%s: %w", oldID, err)
}
```

into `} else if db.IsDeploymentMetadataService() { ...; return err }`
(renamed to `RecordsHistory` in databricks#7169), so the case without deployment
history lost its return.

Fix shape: I kept the pre-databricks#6094 behavior. The error is returned for
every run, with or without deployment history, and the resource stays in
state so the next deploy or destroy retries the delete. `RecordFailure`
is still called unconditionally in that branch; it is already a no-op
when history is not recorded, so nothing extra is written for runs
without history.

Tests:
- `bundle/destroy/delete-error` (from databricks#7930): output now shows both
commands failing with the delete error and the job kept in state;
`Badness` removed and the `DMS=true` variant re-enabled (both variants
now share one golden).
- `bundle/resources/materialization_sets/settled_failure`: its destroy
step recorded the old behavior ("forgives a delete error ... drops the
state while the set stays in the workspace") and was pinned to `DMS=""`
for that reason. It now asserts the destroy fails (`musterr`) and runs
on both variants.

- In the fix PR, `bundle/destroy/delete-error` asserts the failures with
`musterr` and prints the state after the partial destroy: `foo`
(rejected) is kept and `bar` (deleted) is gone.

Scope notes:
- Any delete error that is not missing, managed-by-parent or
permission-denied, and that a re-read cannot confirm as gone, now fails
the command on runs without deployment history, as it did before databricks#6094
and as it already does with history on. A resource type whose backend
reports an in-progress or already-done teardown with some other error
would need its `IsGone` (or the error classification) taught about it; I
did not find such a case among the existing tests.
- When a destroy partly fails, `destroyCore` returns before printing the
`Destroy: N deleted` summary. That is existing behavior for every delete
error (including runs with history) and is left for a separate change.

Overlap: databricks#7496 changes the same lines and keeps the fallthrough (with a
warning and a "removed from state" count). This PR removes the
fallthrough instead; the two need to be reconciled whichever lands
first.

## Why

A destroy that reports success while leaving resources in the workspace
is worse than a failure: the user has no state and no message pointing
at the leftover resource.

This PR was created by analyzing coverage gaps.

Coverage:
[bundle/direct/apply.go](http://go/cli/dashboard/coverage/file/bundle/direct/apply.go),
`(*DeploymentUnit).Delete`, the branch for a delete error that is not
missing, managed-by-parent or permission-denied.

## Tests

`go test ./acceptance -run 'TestAccept/bundle/destroy/delete-error'` and
`TestAccept/bundle/resources/materialization_sets`; `go test
./bundle/...`.

AI agent (opus5.5, isaac_claude)

This pull request and its description were written by Isaac.

---------

Co-authored-by: Isaac <no-reply@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DABs DABs related issues factory-generated test-only-fix PRs that update failing of flaky tests without changing CLI code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants