Skip to content

direct: downgrade a planned action when a resolved reference leaves it unchanged - #6914

Draft
denik wants to merge 1 commit into
denik/downgrade-actionfrom
denik/downgrade-action-impl
Draft

denik wants to merge 1 commit into
denik/downgrade-actionfrom
denik/downgrade-action-impl

Conversation

@denik

@denik denik commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #6895 (the demonstration tests). Implements the apply-time downgrade.

The bug

When a resource is recreated, the direct engine cannot resolve a reference to its output fields at plan time (a recreate does not preserve the id), so the dependent field diffs against the literal ${...} placeholder and the dependent gets a spurious recreate (immutable/id field) or update (mutable field) — even though the referenced value is unchanged.

The fix

References are already resolved at apply time, in dependency order, before each resource is deployed. This re-checks the plan's own entry.Changes there and drops any that were a phantom of an unresolved reference — a local edit (New != Old, where New was the placeholder) whose field now resolves back to Old — then recomputes the action and downgrades it (never upgrades). If nothing remains, the resource is skipped.

Working from the plan's own changes rather than re-diffing from scratch keeps the downgrade safe: a genuine edit still differs from Old and is kept; remote-only drift (New == Old) is never a phantom; changes a struct diff would not surface (a cluster's libraries) are untouched; child resources (permissions, grants) are excluded.

Effect

The direct engine now issues no spurious request: the recreate test's catalog recreate, and the update tests' PATCH, are downgraded to no-ops. (For context — the tests run direct-only now — terraform could not cancel a replace, so the direct engine ends up strictly more capable on the recreate case.)

Limitation

Apply-time only, so bundle plan still previews the spurious action; the deploy downgrades it. The goldens reflect that (plan unchanged; requests show the downgrade).

This pull request and its description were written by Isaac.

@eng-dev-ecosystem-bot

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

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 0e8d953

Run: 37001550792

Env ✅​pass 🙈​skip Time
✅​ aws linux 276 18 5:25
✅​ aws windows 278 16 3:41
✅​ azure linux 275 18 6:00
✅​ azure windows 277 16 4:06
✅​ gcp linux 276 18 5:17
✅​ gcp windows 278 16 5:05
Top 6 slowest tests (at least 2 minutes):
duration env testname
5:02 gcp windows TestAccept
4:05 azure windows TestAccept
4:01 azure linux TestAccept
4:00 aws linux TestAccept
3:59 gcp linux TestAccept
3:40 aws windows TestAccept

…t unchanged

A reference to a resource being recreated cannot be resolved at plan time (a recreate does
not preserve the id), so the planner diffs the dependent field against the literal "${...}"
placeholder and inflates the dependent's action -- a recreate for an immutable/id field, an
update for a mutable one -- even when the referenced value does not actually change.

At apply, references are resolved in dependency order before the resource is deployed. Re-check
the plan's own changes there and drop any that were a phantom of an unresolved reference: a
local edit (New != Old, where New was the placeholder) whose field now resolves back to Old.
Recompute the action over what remains and downgrade it -- never upgrade. If nothing remains,
the resource is skipped instead of recreated/updated.

Working from the plan's own changes rather than re-diffing from scratch keeps changes a struct
diff would not surface (a cluster's libraries) and remote-only drift (New == Old) intact; child
resources (permissions, grants) are excluded because their diff is specialized.

The recreate-reference acceptance tests now show the direct engine issuing no spurious request.

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

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants