Skip to content

Commit 7a3ac12

Browse files
committed
direct: collapse ALL_PRIVILEGES instead of diffing grants
Revert the per-principal grant diff and keep the original buildGrantChanges (ALL_PRIVILEGES still wipes other privileges). Instead fix the false drift at comparison time: normalizeAssignments collapses a principal holding ALL_PRIVILEGES down to just ALL_PRIVILEGES on both the config and read sides, so config granting only ALL_PRIVILEGES matches a backend that also reports the concrete privileges it implies (#6030).
1 parent 41257f6 commit 7a3ac12

12 files changed

Lines changed: 125 additions & 147 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Fixed spurious `update` on catalog/schema/volume grants (direct engine): grants with `ALL_PRIVILEGES` now converge when the backend also reports concrete privileges, and privilege names are normalized to match the case and ordering Unity Catalog returns ([#6030](https://github.com/databricks/cli/issues/6030)).
1+
Fixed spurious `update` on catalog/schema/volume grants (direct engine): a principal granted `ALL_PRIVILEGES` no longer drifts when the backend also reports the concrete privileges it implies, and privilege names are normalized to match the case and ordering Unity Catalog returns ([#6030](https://github.com/databricks/cli/issues/6030)).

‎acceptance/bundle/resources/grants/catalogs/out.deploy1.requests.direct.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"CREATE_SCHEMA",
99
"USE_CATALOG"
1010
],
11-
"principal": "[email protected]"
11+
"principal": "[email protected]",
12+
"remove": [
13+
"ALL_PRIVILEGES"
14+
]
1215
}
1316
]
1417
}

‎acceptance/bundle/resources/grants/catalogs/out.deploy2.requests.direct.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
"changes": [
66
{
77
"add": [
8+
"USE_CATALOG",
89
"USE_SCHEMA"
910
],
1011
"principal": "[email protected]",
1112
"remove": [
12-
"CREATE_SCHEMA"
13+
"ALL_PRIVILEGES"
1314
]
1415
}
1516
]

‎acceptance/bundle/resources/grants/registered_models/out.deploy1.requests.direct.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
"add": [
88
"APPLY_TAG"
99
],
10-
"principal": "[email protected]"
10+
"principal": "[email protected]",
11+
"remove": [
12+
"ALL_PRIVILEGES"
13+
]
1114
}
1215
]
1316
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
>>> [CLI] bundle plan
3+
Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
>>> [CLI] bundle plan
3+
update schemas.grants_schema.grants
4+
5+
Plan: 0 to add, 1 to change, 0 to delete, 1 unchanged

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,6 @@ Deployment complete!
77

88
>>> [CLI] grants update schema main.schema_all_priv_coexist_[UNIQUE_NAME] --json @update.resolved.json
99

10-
>>> [CLI] bundle plan
11-
update schemas.grants_schema.grants
12-
13-
Plan: 0 to add, 1 to change, 0 to delete, 1 unchanged
14-
15-
>>> [CLI] bundle deploy
16-
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/schema-grants-all-privileges-coexist-[UNIQUE_NAME]/default/files...
17-
Deploying resources...
18-
Updating deployment state...
19-
Deployment complete!
20-
21-
>>> [CLI] bundle plan
22-
Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged
23-
24-
>>> [CLI] grants get schema main.schema_all_priv_coexist_[UNIQUE_NAME]
25-
json.privilege_assignments[].principal = "[USERNAME]";
26-
json.privilege_assignments[].privileges[] = "ALL_PRIVILEGES";
27-
2810
>>> errcode [CLI] bundle destroy --auto-approve
2911
The following resources will be deleted:
3012
delete resources.schemas.grants_schema

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,11 @@ trace $CLI bundle deploy
1212

1313
# Out of band, grant a concrete privilege in addition to the ALL_PRIVILEGES that
1414
# the config declares for the same principal. This reproduces issue #6030: the
15-
# backend then reports both ALL_PRIVILEGES and the concrete privilege, and the
16-
# deploy must revoke the concrete privilege to converge.
15+
# backend then reports both ALL_PRIVILEGES and the concrete privilege.
1716
envsubst < update.json > update.resolved.json
1817
trace $CLI grants update schema "$SCHEMA_FULL_NAME" --json @update.resolved.json > /dev/null
1918

20-
# The plan detects the extra privilege and applies the revocation on deploy.
21-
trace $CLI bundle plan
22-
trace $CLI bundle deploy
23-
24-
# The plan now converges to a no-op instead of reporting a perpetual update.
25-
trace $CLI bundle plan
26-
27-
# Only ALL_PRIVILEGES remains for the principal.
28-
trace $CLI grants get schema "$SCHEMA_FULL_NAME" | gron.py --noindex | sort_lines.py --repl
19+
# The plan output differs between engines: the direct engine treats ALL_PRIVILEGES
20+
# as implying every concrete privilege, so it reports no drift (issue #6030),
21+
# while terraform revokes the extra privilege to match the config exactly.
22+
trace $CLI bundle plan > out.plan.$DATABRICKS_BUNDLE_ENGINE.txt 2>&1

‎acceptance/bundle/resources/grants/volumes/out.deploy1.requests.direct.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"READ_VOLUME",
99
"WRITE_VOLUME"
1010
],
11-
"principal": "[email protected]"
11+
"principal": "[email protected]",
12+
"remove": [
13+
"ALL_PRIVILEGES"
14+
]
1215
}
1316
]
1417
}

‎acceptance/bundle/resources/grants/volumes/out.deploy2.requests.direct.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
"changes": [
66
{
77
"add": [
8-
"MANAGE"
8+
"MANAGE",
9+
"READ_VOLUME"
910
],
1011
"principal": "[email protected]",
1112
"remove": [
12-
"WRITE_VOLUME"
13+
"ALL_PRIVILEGES"
1314
]
1415
}
1516
]

0 commit comments

Comments
 (0)