Skip to content

Commit c59239d

Browse files
denikIsaac
andcommitted
acc: Run remove_principal_manage on both engines; record request and plan diff
Enable terraform too (it revokes via a precise Remove: [MANAGE] and converges the same way, confirmed on aws-cli), with the engine-specific revoke request and the direct plan diff recorded per engine. Shows the fix: the direct revoke request removes MANAGE by name alongside ALL_PRIVILEGES. Co-authored-by: Isaac <[email protected]>
1 parent c078c97 commit c59239d

7 files changed

Lines changed: 77 additions & 27 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"[principal='[email protected]']": {
3+
"action": "update",
4+
"old": {
5+
"principal": "[email protected]",
6+
"privileges": [
7+
"MANAGE"
8+
]
9+
},
10+
"remote": {
11+
"principal": "[email protected]",
12+
"privileges": [
13+
"MANAGE"
14+
]
15+
}
16+
}
17+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"method": "PATCH",
3+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_remove_principal_manage_[UNIQUE_NAME]",
4+
"body": {
5+
"changes": [
6+
{
7+
"add": [
8+
"CREATE_TABLE"
9+
],
10+
"principal": "[USERNAME]",
11+
"remove": [
12+
"ALL_PRIVILEGES"
13+
]
14+
},
15+
{
16+
"principal": "[email protected]",
17+
"remove": [
18+
"ALL_PRIVILEGES",
19+
"MANAGE"
20+
]
21+
}
22+
]
23+
}
24+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"method": "PATCH",
3+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_remove_principal_manage_[UNIQUE_NAME]",
4+
"body": {
5+
"changes": [
6+
{
7+
"principal": "[email protected]",
8+
"remove": [
9+
"MANAGE"
10+
]
11+
}
12+
]
13+
}
14+
}

‎acceptance/bundle/resources/grants/schemas/remove_principal_manage/out.test.toml‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎acceptance/bundle/resources/grants/schemas/remove_principal_manage/output.txt‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/schema-grants-remove-principal-manage-[UNIQUE_NAME]/default/files...
44
Created schemas.grants_schema
55
Created schemas.grants_schema.grants
6-
Files: 4 uploaded, 0 deleted
6+
Files: 3 uploaded, 0 deleted
77
Resources: 2 created, 0 changed, 0 deleted, 0 unchanged
88

99
>>> [CLI] grants get schema main.schema_remove_principal_manage_[UNIQUE_NAME]
@@ -12,11 +12,7 @@ json.privilege_assignments[].principal = "[email protected]";
1212
json.privilege_assignments[].privileges[] = "CREATE_TABLE";
1313
json.privilege_assignments[].privileges[] = "MANAGE";
1414

15-
>>> [CLI] bundle deploy
16-
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/schema-grants-remove-principal-manage-[UNIQUE_NAME]/default/files...
17-
Updated schemas.grants_schema.grants
18-
Files: 1 uploaded, 0 deleted
19-
Resources: 0 created, 1 changed, 0 deleted, 1 unchanged
15+
>>> [CLI] bundle deploy -qq
2016

2117
>>> [CLI] grants get schema main.schema_remove_principal_manage_[UNIQUE_NAME]
2218
json.privilege_assignments[].principal = "[USERNAME]";
@@ -25,14 +21,6 @@ json.privilege_assignments[].privileges[] = "CREATE_TABLE";
2521
>>> [CLI] bundle plan
2622
Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged
2723

28-
>>> [CLI] bundle deploy
29-
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/schema-grants-remove-principal-manage-[UNIQUE_NAME]/default/files...
30-
Files: 0 uploaded, 0 deleted
31-
Resources: 0 created, 0 changed, 0 deleted, 2 unchanged
32-
33-
>>> [CLI] bundle plan
34-
Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged
35-
3624
>>> errcode [CLI] bundle destroy --auto-approve
3725
The following resources will be deleted:
3826
delete resources.schemas.grants_schema

‎acceptance/bundle/resources/grants/schemas/remove_principal_manage/script‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,28 @@ trap cleanup EXIT
99
trace $CLI bundle deploy
1010
trace $CLI grants get schema main.schema_remove_principal_manage_$UNIQUE_NAME | gron.py --noindex | sort_lines.py --repl | contains.py "$CURRENT_USER_NAME" '[email protected]'
1111

12+
# Flush the grant requests; we only want to record the revoke request below.
13+
print_requests.py --method PATCH //permissions > LOG.grant_requests
14+
1215
# Remove the MANAGE principal from config.
1316
grep -v 'TO_REMOVE' databricks.yml > tmp.yml && mv tmp.yml databricks.yml
1417

15-
trace $CLI bundle deploy
18+
# The plan revokes the removed principal. The per-resource change diff is a direct
19+
# engine concept (terraform's plan JSON does not expose it), so record it for direct.
20+
if [ "$DATABRICKS_BUNDLE_ENGINE" = "direct" ]; then
21+
$CLI bundle plan -o json | jq '.plan["resources.schemas.grants_schema.grants"].changes' > out.plan.changes.direct.json
22+
fi
1623

17-
# The removed principal is gone: MANAGE was revoked by name, not just via
18-
# Remove: [ALL_PRIVILEGES] (which the backend does not apply to MANAGE).
19-
trace $CLI grants get schema main.schema_remove_principal_manage_$UNIQUE_NAME | gron.py --noindex | sort_lines.py --repl
24+
# Deploy with -qq: the direct variant writes out.plan.changes.direct.json into the
25+
# bundle root above, so the "Files: N uploaded" count would differ between engines.
26+
trace $CLI bundle deploy -qq
2027

21-
# The deploy converges: no perpetual update.
22-
trace $CLI bundle plan
23-
trace $CLI bundle deploy
28+
# The revoke request (engine-specific): the direct engine removes MANAGE by name in
29+
# addition to ALL_PRIVILEGES, terraform removes MANAGE directly. Removing only
30+
# ALL_PRIVILEGES would leave MANAGE behind on the backend.
31+
print_requests.py --method PATCH //permissions > out.requests.$DATABRICKS_BUNDLE_ENGINE.txt
32+
33+
# The removed principal is gone, and the deploy converges (no perpetual update) on
34+
# both engines.
35+
trace $CLI grants get schema main.schema_remove_principal_manage_$UNIQUE_NAME | gron.py --noindex | sort_lines.py --repl
2436
trace $CLI bundle plan

‎acceptance/bundle/resources/grants/schemas/remove_principal_manage/test.toml‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)