Commit 2225149
authored
engine/direct: recover from a failed Create during Recreate (#5173)
## Changes
* `bundle/direct/apply.go`: `Recreate` now drops the deployment state
entry (`db.DeleteState`) between `DoDelete` and the follow-up `Create`,
instead of `db.SaveState(key, "", nil, nil)`.
* `bundle/direct/bundle_plan.go`: Treat an existing state entry whose
`__id__` is empty as missing, so the next plan re-plans `Create` instead
of erroring with `invalid state: empty id`. This covers state files
written by pre-fix CLIs.
*
`acceptance/bundle/resources/vector_search_endpoints/recreate/create-fails/`:
New test that triggers the failure path end-to-end by renaming
`my_endpoint` onto a sibling endpoint's name and switching its
`endpoint_type`. The first Recreate's `Create` 409s on the conflict; the
next `bundle plan` recovers cleanly.
## Why
A direct-engine `Recreate` was a `DoDelete` → `SaveState(key, "", nil,
nil)` → `Create` sequence. If the follow-up `Create` failed for any
reason (in our reproducer: a name collision against another bundle
resource), `Finalize` persisted a state row with `__id__ == ""`. Every
subsequent `bundle plan` then refused to proceed (`invalid state: empty
id`) and `bundle destroy` couldn't recover either, leaving the bundle in
a broken state until the user hand-edited `resources.json`.
Dropping the state entry up front means a failed `Create` simply looks
like "no state for this resource" on the next plan, which is the natural
recovery path. The planner-side tolerance handles state files already
written by older CLIs.
## Tests
* New acceptance test
`bundle/resources/vector_search_endpoints/recreate/create-fails`
exercises the full path: initial deploy, Recreate triggered by
`endpoint_type` change, `Create` 409 from a name collision with
`blocker_endpoint`, then `bundle plan` showing `create my_endpoint` and
`bundle destroy` cleaning up.
* `go test ./bundle/...` passes.
* `./task lint` passes.
* `./task test` had unrelated local failures (Python
`databricks-bundles` module not installed in the fresh worktree's venv,
surfacing in pydabs/invariant tests); CI should not hit that.
_PR description drafted with Claude Code._1 parent 5853c9a commit 2225149
8 files changed
Lines changed: 90 additions & 7 deletions
File tree
- acceptance/bundle/resources/vector_search_endpoints/recreate/create-fails
- bundle/direct
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
185 | 189 | | |
186 | 190 | | |
187 | 191 | | |
188 | 192 | | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | 193 | | |
195 | 194 | | |
196 | 195 | | |
| |||
0 commit comments