Fix spurious grants create for empty grants list on direct engine - #6039
Open
radakam wants to merge 7 commits into
Open
Fix spurious grants create for empty grants list on direct engine#6039radakam wants to merge 7 commits into
radakam wants to merge 7 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: a80615d
9 interesting tests: 4 RECOVERED, 4 SKIP, 1 flaky
Top 45 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
denik
added a commit
that referenced
this pull request
Jul 29, 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 29, 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 29, 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 29, 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 29, 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 29, 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
radakam
added a commit
that referenced
this pull request
Jul 29, 2026
This is the only combination that reaches reconcile on the Terraform-first path with a perturbed config, which is how the empty grants and secret-scope `level` bugs were found in the first place. The nightly (drift on, wide seed window) is expected to stop early on it until those fixes land: seed 7 empties a schema's grants list and hits #6039. The committed run (5 seeds, drift off) stays green, so per-PR CI is unaffected.
Contributor
|
What happens if I have grants and then replace it with |
Emptying grants on a node that already has state must still plan the revoke. SkipCreate is only consulted for nodes without state; applied unconditionally the node would fall into the delete branch, where grants' no-op DoDelete silently keeps the grant. The engines agree on the end state but not on the plan summary: direct keeps the emptied node in state and counts it as unchanged, terraform has no grants resource left, so the plan output is per-engine.
denik
added a commit
that referenced
this pull request
Jul 30, 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 30, 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
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
SkipCreateto the direct engine'sIResource: a resource can report that a desired state needs no create, andmakePlanomits the node instead of planning one.ResourceGrantsimplements it for an empty grants list.It is only consulted 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.Why
Terraform writes no
databricks_grantsresource for an empty list, sobundle deployment migraterecords no state for the grants node, andbundle planshowed a spuriousgrants -> createthat contradicted migrate's "no actions planned".Normalizing empty grants away in config (as
apply_bundle_permissionsdoes for permissions) would instead send an emptied list to the delete branch, where grants' no-opDoDeletekeeps the grants.Found by fuzz testing.
Tests
schema_empty_grantsmigrate invariant (excluded in acc: add empty-grants invariant config, disable failing migrate variant #6055 pending this fix).grants/schemas/remove_alltest: emptying a populated list still revokes. Plan summary is per-engine since direct keeps the emptied node in state as unchanged.