Repository navigation
Detect remote permission changes on undeployed permissions blocks in config-remote-sync - #7716
Conversation
Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
|
Commit: Regression test reportSelected 2 changed tests (limit=20, 0 not selected) 4 tests: regression=2 unreleased=0 coverage=2 failing=0
TestAccept/bundle/config-remote-sync/unmanaged_permissions/DMS=: branch ✅ | main (054a0bf) ❌ | latest (v1.27.0) ❌main (054a0bf): latest (v1.27.0): same output as main (054a0bf) TestAccept/bundle/config-remote-sync/unmanaged_permissions/DMS=true: branch ✅ | main (054a0bf) ❌ | latest (v1.27.0) ❌main (054a0bf): latest (v1.27.0): same output as main (054a0bf) |
✅ Integration test reportCommit: 19299a5
Top 3 slowest tests (at least 2 minutes):
|
| @@ -30,4 +30,6 @@ | ||
| - group_name: users | ||
| level: CAN_VIEW | ||
| + - level: CAN_RUN |
There was a problem hiding this comment.
Is it correct from a bundle perspective that they are merged?
There was a problem hiding this comment.
[AI] Yes, I think merging is right here. A resource's permissions block is the whole ACL the bundle manages: deploy sends it with Permissions.Set (a PUT; DoCreate goes through DoUpdate) plus the deploying user's entry, so any grant missing from the block is removed. Without the late@example.com entry, the "Deploy keeps the remote owner and grant" step would drop the grant made in the UI, which is what sync is there to prevent.
It is also the same merge sync already does for a deployed block: per principal, keyed by user_name/group_name/service_principal_name, so a remote grant becomes an add, a changed level a replace and a principal removed remotely a remove (the job step further down in this test). The deploying user's own entry is skipped.
The trade-off: with nothing deployed yet there is no state to compare against, so sync cannot tell a hand-written entry from a remote change, and a hand-written block that was never deployed is reverted to the remote ACL. That is the same remote-wins sync applies to other local edits that are not deployed yet (the plan marks them Update and sync writes the remote value; that is what LocalEdit counts). If you would rather keep hand-written entries, the undeployed path can be limited to adds, so remote grants are picked up and nothing declared is replaced or removed; that is a small change.
🤖 Factory-generated comment. I still review the code and double-check every claim myself.
Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Sankalp-Mittal
left a comment
There was a problem hiding this comment.
[AI Generated] Review by review-factory (Claude Fable 5.2 + Claude Opus 5.5, cross-verified). Only points the reviewers agreed on are posted.
No blocking or major issues found.
| // by readRemotePermissions. | ||
| func jobOwners(ctx context.Context, b *bundle.Bundle, plan *deployplan.Plan, unmanaged map[string][]dresources.StatePermission) map[string]string { | ||
| owners := make(map[string]string) | ||
| for resourceKey, entry := range plan.Plan { |
There was a problem hiding this comment.
[AI Generated] readRemotePermissions now also reads ACLs whose .permissions entry is Create, but jobACL still re-reads them here, so such jobs get a second Permissions.Get. Could jobACL use the passed map (and rename unmanaged) instead?
About line 124, which this PR does not change.
Co-authored-by: Isaac <no-reply@databricks.com>
Changes
bundle config-remote-syncnow also reads the remote ACL of a deployed resource whosepermissions:block was never deployed, and writes back per-principal differences the same way it does for deployed permissions.In that window the state has no
.permissionsentry, so the plan creates it without reading the ACL (no remote state), and neither the declared nor the unmanaged path looked at it. The ACL is now read with the existingreadPermissions, diffed against the declared entries with the adapter's keyed-slice comparison, and fed throughaddDeclaredPermissionsChanges, so only entries written in the config change and the current user'sFixPermissionsentry is left alone. When the config has no entry for the current user, their default grants (such as a cluster policy creator'sCAN_USE) are left out of the comparison, as for an unmanaged import. Therun_asowner lookup uses the same read instead of fetching the ACL again. Deploy is unchanged.Why
After a sync imports an unmanaged ACL and the user saves it, a grant made in the UI before the next deploy was reported as "No changes", and that deploy (
Permissions.Setwith the declared list) dropped it. The same applied to any hand-writtenpermissions:block before its first deploy. Like other undeployed edits, such a block now follows the remote ACL on sync. Replacements and removals there count towardoverwritten_local_editsin telemetry, since the block has no deployed baseline.Tests
Added a step to
config-remote-sync/unmanaged_permissions: after the imported permissions are saved and before they are deployed, a user is granted access to the pipeline remotely; sync writes it into the config and the deploy keeps it. The step fails on main. Added a unit test for the undeployed comparison (level change, removal, addition, current user's entry skipped) and extended the resource selection test. Added a sync before the deploy toconfig-remote-sync/cluster_policy_permissions: it reports no changes, so the creator'sCAN_USEis not imported into the saved block. Ran thebundle/configsyncunit tests and theconfig-remote-syncacceptance tests locally; golangci-lint clean.19299a5(latest)19299a5(latest)RIGHT-SIZED: reuses the existing sync-side ACL read, deploy unchanged19299a5(latest)b9f03a219299a5(latest)19299a5(latest)✅ success · ⏳ pending ·⚠️ warning · ❌ failed · ➖ n/a
This pull request and its description were written by Isaac.