Skip to content

Commit 342fd07

Browse files
denikIsaac
andcommitted
Do not write back a permissions entry the last deploy set
Seen by an identity other than the one that deployed, the config lacks the owner entry deploy added, so config-remote-sync added it to the declared permissions although nothing changed remotely. aws: TestAccept/bundle/config-remote-sync/permissions TestAccept/bundle/config-remote-sync/job_run_as gcp: TestAccept/bundle/config-remote-sync/permissions Co-authored-by: Isaac <no-reply@databricks.com>
1 parent 5cb1618 commit 342fd07

4 files changed

Lines changed: 15 additions & 14 deletions

File tree

‎acceptance/bundle/config-remote-sync/permissions/other_identity/declared/output.txt‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,10 @@ IS_OWNER [TEST_SP_APPLICATION_ID]
1616
=== The current identity runs config-remote-sync without any remote change
1717

1818
>>> [CLI] bundle config-remote-sync --save
19-
Detected changes in 1 resource(s):
20-
21-
Resource: resources.jobs.my_job
22-
permissions[service_principal_name='[TEST_SP_APPLICATION_ID]']: add
23-
19+
No changes detected.
2420

2521

2622
>>> diff.py databricks.yml.backup databricks.yml
27-
--- databricks.yml.backup
28-
+++ databricks.yml
29-
@@ -12,2 +12,4 @@
30-
- level: CAN_VIEW
31-
group_name: users
32-
+ - level: IS_OWNER
33-
+ service_principal_name: [TEST_SP_APPLICATION_ID]
3423

3524
=== The current identity is granted CAN_MANAGE on the job, outside the bundle
3625

@@ -51,7 +40,7 @@ No changes detected.
5140
>>> as-test-sp [CLI] bundle deploy
5241
Uploading bundle files to /Workspace/Users/[TEST_SP_APPLICATION_ID]/.bundle/test-bundle-[UNIQUE_NAME]/files...
5342
Updated jobs.my_job.permissions
54-
Files: 1 uploaded, 0 deleted
43+
Files: 0 uploaded, 0 deleted
5544
Resources: 0 created, 1 changed, 0 deleted, 1 unchanged
5645

5746
=== The job's ACL after the deploy
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Badness = "Run by an identity other than the deployer, config-remote-sync adds the deployer's IS_OWNER to the declared permissions although nobody changed the ACL. It also reports no change for a grant made to the syncing identity itself, so the deployer's next deploy revokes that grant (the revoke predates the permissions sync, which was meant to prevent it)."
1+
Badness = "Run by an identity other than the deployer, config-remote-sync reports no change for a grant made to the syncing identity itself, so the deployer's next deploy revokes that grant (the revoke predates the permissions sync, which was meant to prevent it)."

‎bundle/configsync/diff_test.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,12 @@ resources:
354354
"[user_name='me@example.com'].level": {
355355
Action: deployplan.Update, Old: "IS_OWNER", New: "IS_OWNER", Remote: "CAN_MANAGE",
356356
},
357+
// The owner entry deploy added for another identity: deployed, unchanged remotely.
358+
"[service_principal_name='deployer']": {
359+
Action: deployplan.Update,
360+
Old: dresources.StatePermission{Level: iam.PermissionLevelIsOwner, ServicePrincipalName: "deployer"},
361+
Remote: dresources.StatePermission{Level: iam.PermissionLevelIsOwner, ServicePrincipalName: "deployer"},
362+
},
357363
"object_id": {Action: deployplan.Update, Remote: "/jobs/456"},
358364
},
359365
},

‎bundle/configsync/permissions.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ func addDeclaredPermissionsChanges(changes Changes, b *bundle.Bundle, resourceKe
7979
if _, _, ok := nodes[0].KeyValue(); !ok || (changeDesc.New != nil && !declared[nodes[0].String()]) {
8080
continue
8181
}
82+
// An entry the last deploy set and the remote still has was not changed remotely. It is
83+
// missing only from the config as this identity sees it, e.g. the owner entry deploy added
84+
// for the identity that deployed.
85+
if changeDesc.New == nil && changeDesc.Remote != nil && structdiff.IsEqual(changeDesc.Old, changeDesc.Remote) {
86+
continue
87+
}
8288

8389
fieldPath := "permissions" + path
8490
change, err := convertPlanChange(parentKey, fieldPath, changeDesc, "", b.Config.Presets.NamePrefix)

0 commit comments

Comments
 (0)