Skip to content

acc: record config-remote-sync permission results when another identity syncs - #8146

Open
denik wants to merge 5 commits into
mainfrom
pmr/sync-permissions-other-identity-tests
Open

denik wants to merge 5 commits into
mainfrom
pmr/sync-permissions-other-identity-tests

Conversation

@denik

@denik denik commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Changes

Nine acceptance tests that record what bundle config-remote-sync does with permissions today when the identity that runs it is not the one that deploys, and when the synced config is deployed to another target. No production code changes; one rule is added to the testserver (below).

Since #7536, the sync imports the whole remote ACL of a deployed resource that declares no permissions, and leaves the syncing identity's own IS_OWNER/CAN_MANAGE out, because deploy adds an entry for the deploying identity. That holds when the same identity syncs and deploys. In these tests a service principal deploys (as a CI pipeline would) and another identity syncs the same deployment.

Test Result recorded
other_identity/can_manage The syncing identity holds a direct CAN_MANAGE on the job. The sync writes permissions: without it, and the service principal's next deploy revokes it.
other_identity/syncer_home The same, with the deployment in the syncing identity's home folder (e.g. a production root_path in the author's home, deployed by CI). Local only.
other_identity/experiment The same as can_manage for a resource type without IS_OWNER.
other_identity/owner The job's ownership was transferred to the syncing identity. The sync writes only the service principal's CAN_MANAGE, so its next deploy asks for the ownership back. That deploy fails with 403 only workspace admins can change the owner of a job; a deployer who is an admin would become the owner again.
other_identity/no_grants Nobody changed the ACL. The sync still reports a change and writes the deployer's IS_OWNER into the config; the next deploy starts managing the job's ACL.
other_identity/declared The job declares permissions. With no remote change, the sync adds the deployer's IS_OWNER to the block. A grant made to the syncing identity itself is reported as no change, and the next deploy revokes it.
other_identity/undeployed A block is added to the config and synced before it is deployed (the case #7716 added). The sync adds the deployer's IS_OWNER but not the syncing identity's own CAN_MANAGE, and the next deploy revokes it.
other_identity/handover The syncing identity deployed first, then the service principal deploys the synced config: its deploy asks for the ownership and fails the same way as in owner. Marked # Undefined.
other_target One identity, two targets. An ACL imported from the staging job is written to the shared resource definition, and the next deploy to prod replaces the prod job's ACL with it. Marked # Undefined.

The first seven carry a Badness note. The last two record behavior that is not decided either way.

Testserver: a permissions update by the as-test-sp guest that changes the owner of a job it does not own now fails with the backend's 403 ... only workspace admins can change the owner of a job .... The first cloud run of owner and handover showed that error where the testserver had accepted the change.

Why

A job, pipeline or other resource that declares no permissions used to keep whatever ACL it had: deploy did not touch it. After a sync writes a permissions: block, every later deploy replaces the ACL with that block. When the block was written from another identity's point of view, the deploy removes a grant that nobody meant to remove, or fails. On the commit before #7536 the scripts for the unmanaged cases end with the grant and the owner unchanged.

These tests are evidence for deciding what to do about it. They are useful whichever way that goes.

Tests

The nine tests above; all but syncer_home are Cloud = true. In this PR's first cloud run can_manage, experiment, no_grants, declared and other_target passed on AWS and GCP with the goldens recorded against the testserver (other_target also on Azure). owner and handover failed there with the 403 above; their goldens now record it and the testserver returns it. The whole bundle acceptance suite passes with the testserver change, with no other golden changed.

Gaps and risks

  • The testserver rule covers only what the cloud run showed: a guest that is not the job's owner changing the owner. Whether the backend lets an owner who is not an admin hand the job over is not modeled.
  • The other_identity tests assume, as resources/permissions/jobs/destroy_without_mgmtperms does, that the test's main identity is a workspace admin and the test service principal is not. They need that service principal, so they do not run on Azure.
  • The testserver does not make a job's creator its owner, so no_grants sets that ACL there; on a real workspace the ACL is left as the deploy made it.
  • Each imported block has a single entry, so the tests do not depend on the order in which the backend lists an ACL.
  • Risk: low. Tests and one testserver rule.

🤖 AI agent (fable5.2, isaac_claude)

This pull request and its description were written by Isaac.

…ty syncs

Six acceptance tests for the permissions sync added in #7536 where the
identity that runs config-remote-sync is not the one that deploys, and one
where the synced config is deployed to another target.

aws: TestAccept/bundle/config-remote-sync/permissions
gcp: TestAccept/bundle/config-remote-sync/permissions

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions github-actions Bot added DABs DABs related issues test-only-fix PRs that update failing of flaky tests without changing CLI code. labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Regression test report ✅

Commit: 7caa85e3e | Workflow run

Selected 9 changed tests (limit=20, 0 not selected)

50 tests: regression=0 unreleased=0 coverage=50 failing=0
test branch main (e6f3460) latest (v1.28.0)
TestAccept/bundle/config-remote-sync/permissions/other_identity/can_manage/DMS= ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_identity/can_manage/DMS=true ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_identity/declared/DMS= ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_identity/declared/DMS=true ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_identity/experiment/DMS= ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_identity/experiment/DMS=true ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_identity/handover/DMS= ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_identity/handover/DMS=true ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_identity/no_grants/DMS= ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_identity/no_grants/DMS=true ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_identity/owner/DMS= ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_identity/owner/DMS=true ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_identity/syncer_home/DMS= ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_identity/syncer_home/DMS=true ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_identity/undeployed/DMS= ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_identity/undeployed/DMS=true ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_target/DMS= ✅ ✅ ✅
TestAccept/bundle/config-remote-sync/permissions/other_target/DMS=true ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/added_remotely/DMS= ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/added_remotely/DMS=true ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/current_can_manage/DMS= ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/current_can_manage/DMS=true ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/current_can_manage_run/DMS= ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/current_can_manage_run/DMS=true ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/current_is_owner/DMS= ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/current_is_owner/DMS=true ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/delete_one/DMS= ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/delete_one/DMS=true ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/deleted_remotely/DMS= ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/deleted_remotely/DMS=true ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DMS= ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DMS=true ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DMS= ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DMS=true ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/empty_list/DMS= ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/empty_list/DMS=true ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/other_can_manage/DMS= ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/other_can_manage/DMS=true ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/other_can_manage_run/DMS= ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/other_can_manage_run/DMS=true ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/other_is_owner/DMS= ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/other_is_owner/DMS=true ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/reorder_locally/DMS= ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/reorder_locally/DMS=true ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/reorder_remotely/DMS= ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/reorder_remotely/DMS=true ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/update/DMS= ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/update/DMS=true ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/viewers/DMS= ✅ ✅ ✅
TestAccept/bundle/resources/permissions/jobs/viewers/DMS=true ✅ ✅ ✅

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: 7caa85e

Run: 46088406179

Env 🤯​MISS 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 209 30 5:45
💚​ aws-windows-latest-4core-16gb 1 185 38 4:29
🤯​ azure linux-2core-8gb 16 1 175 25 4:39
🤯​ azure-windows-latest-4core-16gb 16 1 172 26 3:38
💚​ gcp linux-2core-8gb 1 209 30 6:00
💚​ gcp-windows-latest-4core-16gb 1 185 38 3:47
17 interesting tests: 16 MISS, 1 RECOVERED
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🤯​ TestAccept/bundle/resources/permissions/jobs/added_remotely 🙈​s 🙈​s 🤯​M 🤯​M 🙈​s 🙈​s
🤯​ TestAccept/bundle/resources/permissions/jobs/current_can_manage 🙈​s 🙈​s 🤯​M 🤯​M 🙈​s 🙈​s
🤯​ TestAccept/bundle/resources/permissions/jobs/current_can_manage_run ✅​p ✅​p 🤯​M 🤯​M ✅​p ✅​p
🤯​ TestAccept/bundle/resources/permissions/jobs/current_is_owner 🙈​s 🙈​s 🤯​M 🤯​M 🙈​s 🙈​s
🤯​ TestAccept/bundle/resources/permissions/jobs/delete_one ✅​p ✅​p 🤯​M 🤯​M ✅​p ✅​p
🤯​ TestAccept/bundle/resources/permissions/jobs/deleted_remotely 🙈​s 🙈​s 🤯​M 🤯​M 🙈​s 🙈​s
🤯​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions ✅​p ✅​p 🤯​M 🤯​M ✅​p ✅​p
🤯​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions ✅​p ✅​p 🤯​M 🤯​M ✅​p ✅​p
🤯​ TestAccept/bundle/resources/permissions/jobs/empty_list 🙈​s 🙈​s 🤯​M 🤯​M 🙈​s 🙈​s
🤯​ TestAccept/bundle/resources/permissions/jobs/other_can_manage 🙈​s 🙈​s 🤯​M 🤯​M 🙈​s 🙈​s
🤯​ TestAccept/bundle/resources/permissions/jobs/other_can_manage_run 🙈​s 🙈​s 🤯​M 🤯​M 🙈​s 🙈​s
🤯​ TestAccept/bundle/resources/permissions/jobs/other_is_owner 🙈​s 🙈​s 🤯​M 🤯​M 🙈​s 🙈​s
🤯​ TestAccept/bundle/resources/permissions/jobs/reorder_locally 🙈​s 🙈​s 🤯​M 🤯​M 🙈​s 🙈​s
🤯​ TestAccept/bundle/resources/permissions/jobs/reorder_remotely 🙈​s 🙈​s 🤯​M 🤯​M 🙈​s 🙈​s
🤯​ TestAccept/bundle/resources/permissions/jobs/update 🙈​s 🙈​s 🤯​M 🤯​M 🙈​s 🙈​s
🤯​ TestAccept/bundle/resources/permissions/jobs/viewers 🙈​s 🙈​s 🤯​M 🤯​M 🙈​s 🙈​s
Top 6 slowest tests (at least 2 minutes):
duration env testname
4:04 gcp linux-2core-8gb TestAccept
4:01 azure linux-2core-8gb TestAccept
3:58 aws linux-2core-8gb TestAccept
3:42 aws-windows-latest-4core-16gb TestAccept
3:36 azure-windows-latest-4core-16gb TestAccept
2:59 gcp-windows-latest-4core-16gb TestAccept

denik and others added 4 commits November 28, 2026 00:00
A deploy by a non-admin service principal that asks for a job's ownership
fails on the real backend with 403 "only workspace admins can change the
owner of a job". The testserver let it through, so the owner and handover
tests recorded an ownership change that the cloud run does not show.

aws: TestAccept/bundle/config-remote-sync/permissions TestAccept/bundle/resources/permissions/jobs
gcp: TestAccept/bundle/config-remote-sync/permissions TestAccept/bundle/resources/permissions/jobs

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

- Each imported block has one entry, and ACL lines are sorted after the
  replacements, so neither the backend's order nor the principals' names
  change the output.
- no_grants sets the owner only where the testserver has none.
- handover is destroyed by the identity that created the job.
- The testserver checks the owner change on the validated ACL, so a request
  without an owner still gets the 400 it got before.

aws: TestAccept/bundle/config-remote-sync/permissions TestAccept/bundle/resources/permissions/jobs
gcp: TestAccept/bundle/config-remote-sync/permissions TestAccept/bundle/resources/permissions/jobs

Co-authored-by: Isaac <no-reply@databricks.com>
… and an undeployed block

aws: TestAccept/bundle/config-remote-sync/permissions TestAccept/bundle/resources/permissions/jobs
gcp: TestAccept/bundle/config-remote-sync/permissions TestAccept/bundle/resources/permissions/jobs

Co-authored-by: Isaac <no-reply@databricks.com>
aws: TestAccept/bundle/config-remote-sync/permissions TestAccept/bundle/resources/permissions/jobs
gcp: TestAccept/bundle/config-remote-sync/permissions TestAccept/bundle/resources/permissions/jobs

Co-authored-by: Isaac <no-reply@databricks.com>
@denik
denik marked this pull request as ready for review November 28, 2026 00:59
@denik
denik requested review from a team as code owners November 28, 2026 00:59

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review at 7caa85e. Each finding was verified against the code.

No blocking issues found. 5 non-blocking comment(s) below.

This PR adds nine acceptance tests that record what config-remote-sync does with permissions when the identity that syncs isn't the one that deploys, plus one cross-target case. It also adds a testserver rule that rejects a non-admin guest's attempt to change a job's owner with a 403. I found no wrong behavior. The testserver check holds up when traced through the creator-owned, guest-owned and owner-kept cases. What's left is cleanup: the scripts don't follow the acceptance rules for the permissions set output and for reading resource IDs, the no_grants script works around a testserver gap, the new owner lookup repeats the creator-owner fallback, and one comment needs clearer wording.

$CLI permissions set jobs $job_id --json '{"access_control_list":[
{"permission_level":"IS_OWNER","service_principal_name":"'"$TEST_SP_APPLICATION_ID"'"},
{"permission_level":"CAN_MANAGE","'"$CURRENT_USER_FIELD"'":"'"$CURRENT_USER_NAME"'"}
]}' > /dev/null

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nice to have] testing.md says to send noisy output to LOG.<name>, not to /dev/null. Here the response of permissions set is thrown away, so if a grant fails or comes back different on a cloud run, nothing records what the backend returned. Can these go to something like > LOG.permissions_set? The same applies to declared, experiment, handover, no_grants, owner, syncer_home, undeployed, and both calls in other_target.


title "The service principal deploys a job that declares no permissions"
trace as-test-sp $CLI bundle deploy
job_id=$(as-test-sp $CLI bundle summary -o json | jq -r '.resources.jobs.my_job.id')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nice to have] testing.md asks for the acceptance/bin/ helpers instead of inline jq pipelines, and read_id.py my_job prints the ID from state and registers the [MY_JOB_ID] replacement. Could this be job_id=$(as-test-sp read_id.py my_job)? In owner/script and handover/script (lines 10–11) that would also replace the hand-written jq plus add_repl "$job_id" MY_JOB_ID pair. The same pipeline appears in every other new script, and other_target would use read_id.py -t staging / -t prod.

title "Nobody changes the job's ACL: the deployer is its owner\n"
# The backend makes the creator of a job its owner. The testserver does not record that, so set
# it there; on a real workspace the ACL is left as the deploy made it.
if [ -z "$(print_acl jobs $job_id)" ]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nice to have] Locally the ACL is empty, so this branch writes IS_OWNER for the SP itself. The local run therefore sets the ACL in a test titled "Nobody changes the job's ACL", and the cloud run takes a different path to the same golden. testing.md asks to model API behavior in libs/testserver/, and the new jobOwner() already treats the creator as owner. Could GetPermissions for jobs report that creator as IS_OWNER so this branch can go, or does that change too many other goldens for this PR?


// jobOwner returns the principal with IS_OWNER in a job's ACL or, while no owner was set
// explicitly, the job's creator. Call with s.mu held.
func (s *FakeWorkspace) jobOwner(jobId int64) string {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nice to have] jobOwner repeats the rule guestHasJobAccess already applies: the creator is the owner only while the ACL names no IS_OWNER. If one copy changes, the access check and the new owner-change check will disagree. guestHasJobAccess could be written as hasAccess || s.jobOwner(jobId) == principal, which is equivalent because an explicit owner always has a direct entry. Could we do that so the fallback lives in one place?

}

// Only a workspace admin can change the owner of a job (verified against the backend). The
// primary identity is treated as an admin; an as-test-sp guest that is not the owner is not.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] "an as-test-sp guest that is not the owner is not" reads as if a guest that owns the job counts as an admin. The code does let such a guest hand ownership to anyone, but the PR description says that case wasn't checked against the backend. Could the comment say so, e.g. "A guest that owns the job may pass ownership on; whether the backend allows that is not modeled"?

@Sankalp-Mittal Sankalp-Mittal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI Generated] Review by review-factory (Claude Sonnet 5.5 + Claude Opus 5.5 + Claude Opus 5.5, cross-verified). Only points the reviewers agreed on are posted.

@@ -0,0 +1 @@
Badness = "A permissions block is added to the config by an identity other than the deployer and synced before it is deployed. config-remote-sync adds the deployer's IS_OWNER to the block and removes the new entry, but leaves out the syncing identity's own CAN_MANAGE, so the deployer's next deploy revokes it."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI Generated] nit: Dropping the hand-added CAN_VIEW users entry also happens with a single identity, as TestAddUndeployedPermissionsChanges expects. Can the Badness leave that out, or say that part isn't identity-specific?

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

DABs DABs related issues factory-generated test-only-fix PRs that update failing of flaky tests without changing CLI code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants