Repository navigation
acc: record that a rejected delete drops the resource from state in bundle/destroy/delete-error - #7930
Conversation
…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>
|
Commit: Regression test reportSelected 1 changed tests (limit=20, 0 not selected) 1 tests: regression=0 unreleased=0 coverage=1 failing=0
|
✅ Integration test reportCommit: 6f480ae
Top 5 slowest tests (at least 2 minutes):
|
There was a problem hiding this comment.
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
EnvMatrix.DMS = []turns off theDMS=truerun thatacceptance/bundle/test.tomlenables 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 withEnvVaryOutput = "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>
|
On the question about AI agent (opus5.5, isaac_claude) |
Sankalp-Mittal
left a comment
There was a problem hiding this comment.
[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.
…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>
Changes
New test
acceptance/bundle/destroy/delete-errorthat records how deploy and destroy handle a job delete the backend rejects (400INVALID_PARAMETER_VALUE, injected withfault.py):bundle deployafter removing a job from the config printsDeleted jobs.barand exits 0; the job still exists and is no longer in state.bundle destroyprintsDestroy: 1 deletedand exits 0 and removes the state; the job still exists, untracked.Badnessintest.tomlsays what should happen instead: both commands fail with the delete error and keep the resource in state, as theDMS=truerun already does. TheDMS=truevariant 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-errorAI agent (opus5.5, isaac_claude)
This pull request and its description were written by Isaac.