Fix spurious grants create for empty grants list on direct engine - #6039
Open
radakam wants to merge 6 commits into
Open
Fix spurious grants create for empty grants list on direct engine#6039radakam wants to merge 6 commits into
radakam wants to merge 6 commits into
Conversation
radakam
marked this pull request as ready for review
July 23, 2026 13:14
Contributor
Approval status: pending
|
Collaborator
Integration test reportCommit: 98822e4
8 interesting tests: 4 RECOVERED, 4 SKIP
Top 6 slowest tests (at least 2 minutes):
|
radakam
force-pushed
the
fix-empty-grants-migrate
branch
2 times, most recently
from
July 24, 2026 08:08
0c35ccb to
61002e0
Compare
An empty grants: [] list produced no databricks_grants resource in terraform state, so bundle deployment migrate wrote no grants entry. The direct engine's makePlan then always emitted a plan node for the grants config node, so bundle plan showed a spurious 'create' for the empty grants node -- contradicting migrate's 'no actions planned'. Skip an empty grants node in makePlan when there is no existing state entry. When a state entry exists (grants were deployed and are now being emptied), the node is still emitted so the revoke is planned.
With the direct-engine fix in place, the migrate invariant no longer shows a spurious grants -> create for an empty grants: [] list, so remove the no_empty_grants exclude added by the invariant-config PR and regenerate the migrate matrix. This is the variant the fuzz-found config was disabled for.
radakam
force-pushed
the
fix-empty-grants-migrate
branch
from
July 24, 2026 08:18
61002e0 to
5a47a08
Compare
denik
added a commit
that referenced
this pull request
Jul 24, 2026
grants: [] triggers a spurious grants update when the plan is computed from saved state rather than a live remote read (config has a non-nil empty slice, state persists none). --planmode=offline hits the same known direct-engine bug that migrate already excludes this config for (fixed by #6039). Exclude the offline variant until that lands, mirroring migrate/test.toml. Co-authored-by: Isaac
denik
added a commit
that referenced
this pull request
Jul 24, 2026
grants: [] triggers a spurious grants update when the plan is computed from saved state rather than a live remote read (config has a non-nil empty slice, state persists none). --planmode=offline hits the same known direct-engine bug that migrate already excludes this config for (fixed by #6039). Exclude the offline variant until that lands, mirroring migrate/test.toml. Co-authored-by: Isaac
denik
reviewed
Jul 24, 2026
denik
added a commit
that referenced
this pull request
Jul 24, 2026
grants: [] triggers a spurious grants update when the plan is computed from saved state rather than a live remote read (config has a non-nil empty slice, state persists none). --planmode=offline hits the same known direct-engine bug that migrate already excludes this config for (fixed by #6039). Exclude the offline variant until that lands, mirroring migrate/test.toml. Co-authored-by: Isaac
The planner asserted on *dresources.GrantsState directly to detect an empty grants list. Add an optional SkipCreate method to IResource so the predicate lives with the resource, and have makePlan consult it through the adapter. The state lookup stays in the planner: a node that already has state must keep its plan entry even when creating it would be a no-op, otherwise it falls into the delete branch and grants' no-op DoDelete would silently stop revoking.
…grants-migrate # Conflicts: # bundle/direct/dresources/grants_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Add an optional
SkipCreatemethod to the direct engine'sIResource: a resource can report that a given desired state needs no create at all, andmakePlanthen omits the node instead of planning one.ResourceGrantsimplements it for an empty grants list.The planner only consults it for nodes with no state entry. A node that already has state keeps its plan entry, so emptying a previously deployed
grants:list still plans the revoke — dropping it there would move the node to the delete branch, where grants' deliberately no-opDoDeletewould silently skip the revoke.Why
Terraform writes no
databricks_grantsresource for an empty grants list, sobundle deployment migraterecords no state for the grants node. ButmakePlanemitted a node for every grants config unconditionally, sobundle planshowed a spuriousgrants -> create, contradicting migrate's "no actions planned".Permissions avoid this because an empty
permissions: []either drops the node or defaults to a realIS_OWNERresource. Grants have no default owner, so the Terraform-faithful behavior for an empty list is a no-op.Found by fuzz testing.
Tests
schema_empty_grantsmigrate invariant (added in acc: add empty-grants invariant config, disable failing migrate variant #6055, previously excluded pending this fix). Verified it fails without the fix (Unexpected action='create' for resources.schemas.foo.grants) and passes with it.grants_test.gofor the empty, unset, and populated cases, plus a resource that doesn't implementSkipCreate. They call through the adapter so the optional-method discovery and type validation are covered too.