Skip to content

Skip the deploying identity when listing snapshot CAN_MANAGE principals - #7332

Draft
pietern wants to merge 2 commits into
mainfrom
pietern/f06-6774-snapshot-deployer-duplicate
Draft

pietern wants to merge 2 commits into
mainfrom
pietern/f06-6774-snapshot-deployer-duplicate

Conversation

@pietern

@pietern pietern commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Changes

BuildCanManage now skips the deploying identity when the top-level permissions section lists it with CAN_MANAGE, as its doc comment already said, and sends every other principal once. Bundles that list the deployer upload their snapshot to a new path once on the next deploy, because the stored principal list changes.

Why

Bug in the snapshot permissions added in #6774.

Tests

  • Unit tests in bundle/deploy/snapshot/upload_warning_test.go.
  • acceptance/bundle/deploy/immutable/can-manage now lists the deployer once.

This pull request and its description were written by Isaac.

@github-actions github-actions Bot added the DABs DABs related issues label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Commit: 2c28abf07 | Workflow run

Regression test report

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

1 tests: regression=1 unreleased=0 coverage=0 failing=0
test branch main (e1b8c92) latest (v1.24.0)
TestAccept/bundle/deploy/immutable/can-manage/DMS= ✅ ❌ ❌
TestAccept/bundle/deploy/immutable/can-manage/DMS=: branch ✅ | main (e1b8c92) ❌ | latest (v1.24.0) ❌

main (e1b8c92):

acceptance_test.go:1342: 
        	Error Trace:	/home/runner/work/cli/cli/libs/testdiff/testdiff.go:22
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1342
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1083
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:660
        	Error:      	Not equal: 
        	            	expected: "\n=== Deploy with a CAN_MANAGE permission entry\n>>> [CLI] bundle deploy\nCreated internal_immutable_snapshots.immutable\nCreated jobs.my_job\nCreated jobs.my_job.permissions\nFiles: 0 uploaded, 0 deleted\nResources: 3 created, 0 changed, 0 deleted, 0 unchanged\n\n=== Check can_manage_principals sent to the snapshot create API\n>>> print_requests.py //api/2.0/snapshots\n[\n  {\n    \"service_principal_name\": \"[USERNAME]\"\n  },\n  {\n    \"user_name\": \"deco-test-user@databricks.com\"\n  }\n]\n\n>>> [CLI] bundle destroy --auto-approve\nThe following resources will be deleted:\n  delete resources.jobs.my_job\n\nAll files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-immutable-can-manage-[UNIQUE_NAME]/default\n\nDestroy: 1 deleted\n"
        	            	actual  : "\n=== Deploy with a CAN_MANAGE permission entry\n>>> [CLI] bundle deploy\nCreated internal_immutable_snapshots.immutable\nCreated jobs.my_job\nCreated jobs.my_job.permissions\nFiles: 0 uploaded, 0 deleted\nResources: 3 created, 0 changed, 0 deleted, 0 unchanged\n\n=== Check can_manage_principals sent to the snapshot create API\n>>> print_requests.py //api/2.0/snapshots\n[\n  {\n    \"service_principal_name\": \"[USERNAME]\"\n  },\n  {\n    \"service_principal_name\": \"[USERNAME]\"\n  },\n  {\n    \"user_name\": \"deco-test-user@databricks.com\"\n  }\n]\n\n>>> [CLI] bundle destroy --auto-approve\nThe following resources will be deleted:\n  delete resources.jobs.my_job\n\nAll files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-immutable-can-manage-[UNIQUE_NAME]/default\n\nDestroy: 1 deleted\n"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -16,2 +16,5 @@
        	            	   {
        	            	+    "service_principal_name": "[USERNAME]"
        	            	+  },
        	            	+  {
        	            	     "user_name": "deco-test-user@databricks.com"
        	Test:       	TestAccept/bundle/deploy/immutable/can-manage/DMS=
        	Messages:   	bundle/deploy/immutable/can-manage/output.txt vs /tmp/TestAcceptbundledeployimmutablecan-manageDMS=1072362156/002/output.txt
FAIL

latest (v1.24.0): same output as main (e1b8c92)

BuildCanManage always adds the deploying identity, and its doc comment says
that identity is skipped when it also shows up in the top-level permissions
section. The loop had no such check, so the recommended setup (deployer listed
with CAN_MANAGE) sent the same principal twice in can_manage_principals.

Match the deployer by name in either the user_name or service_principal_name
field, as the permissions diagnostics do, and send other repeated principals
only once.

Bundles deployed with v1.23.0 that list the deployer with CAN_MANAGE have the
duplicate in state, so their next deploy uploads the snapshot to a new path
once. The changelog entry says so.

Cover this in TestBuildCanManage, a new test for the deployer listed in the
other name field, and the immutable/can-manage acceptance test, which now lists
the deployer in its permissions section.

Co-authored-by: Isaac <no-reply@databricks.com>
@pietern
pietern force-pushed the pietern/f06-6774-snapshot-deployer-duplicate branch from e2f663e to 69f04e6 Compare November 4, 2026 10:09
Co-authored-by: Isaac <no-reply@databricks.com>
@eng-dev-ecosystem-bot

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 2c28abf

Run: 41864570385

Env ✅​pass 🙈​skip Time
✅​ aws linux-2core-8gb 273 15 6:38
✅​ aws-windows-latest-4core-16gb 275 13 5:11
✅​ azure linux-2core-8gb 272 15 5:45
✅​ azure-windows-latest-4core-16gb 274 13 4:56
✅​ gcp linux-2core-8gb 271 16 5:50
✅​ gcp-windows-latest-4core-16gb 273 14 5:50
Top 3 slowest tests (at least 2 minutes):
duration env testname
3:40 azure-windows-latest-4core-16gb TestAccept
3:27 gcp-windows-latest-4core-16gb TestAccept
3:21 aws-windows-latest-4core-16gb TestAccept

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants