Skip to content

Commit 4291bcc

Browse files
authored
Fixed bundle deploy to not update permissions for unbound resources (#3642)
## Changes Fixed bundle deploy to not update permissions for unbound resources ## Why The original issue occurred because we hadn't removed the permissions section for the corresponding resources from the TF state. and therefore, permissions were continued to be managed by TF and, as a result, cleared out. ## Tests Added an acceptance test <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent bad56e3 commit 4291bcc

File tree

23 files changed

+361
-15
lines changed

23 files changed

+361
-15
lines changed

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Bundles
1212
* Add new Lakeflow Pipelines support for bundle generate ([#3568](https://github.com/databricks/cli/pull/3568))
13+
* Fix bundle deploy to not update permissions or grants for unbound resources ([#3642](https://github.com/databricks/cli/pull/3642))
1314
* Introduce new bundle variable: `${workspace.current_user.domain_friendly_name}` ([#3623](https://github.com/databricks/cli/pull/3623))
1415

1516
### API Changes

acceptance/bundle/deploy/experimental-python/output.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Deployment complete!
88
>>> [CLI] jobs list --output json
99
[
1010
{
11+
"creator_user_name": "[USERNAME]",
1112
"job_id": [NUMID],
1213
"settings": {
1314
"deployment": {

acceptance/bundle/deploy/python-notebook/output.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Deployment complete!
88
>>> [CLI] jobs list --output json
99
[
1010
{
11+
"creator_user_name": "[USERNAME]",
1112
"job_id": [NUMID],
1213
"settings": {
1314
"deployment": {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
bundle:
2+
name: unbind_grants-$UNIQUE_NAME
3+
4+
workspace:
5+
root_path: ~/.bundle/$UNIQUE_NAME
6+
7+
variables:
8+
suffix:
9+
default: ""
10+
description: "Suffix for the schema name"
11+
12+
resources:
13+
schemas:
14+
schema_1:
15+
name: "test-schema-$UNIQUE_NAME${var.suffix}"
16+
catalog_name: "main"
17+
grants:
18+
- principal: "account users"
19+
privileges: ["CREATE_VOLUME", "SELECT"]

acceptance/bundle/deployment/unbind/grants/out.test.toml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
>>> [CLI] bundle deploy
3+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files...
4+
Deploying resources...
5+
Updating deployment state...
6+
Deployment complete!
7+
8+
>>> [CLI] grants get schema main.test-schema-[UNIQUE_NAME] --output json
9+
{
10+
"principal": "account users",
11+
"privileges": [
12+
"CREATE_VOLUME",
13+
"SELECT"
14+
]
15+
}
16+
17+
>>> [CLI] bundle deployment unbind schema_1
18+
Updating deployment state...
19+
20+
>>> [CLI] bundle deploy --var suffix=another
21+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files...
22+
Deploying resources...
23+
Updating deployment state...
24+
Deployment complete!
25+
26+
=== Grants should be the same as before unbind
27+
>>> [CLI] grants get schema main.test-schema-[UNIQUE_NAME] --output json
28+
{
29+
"principal": "account users",
30+
"privileges": [
31+
"CREATE_VOLUME",
32+
"SELECT"
33+
]
34+
}
35+
36+
>>> [CLI] bundle destroy --auto-approve
37+
The following resources will be deleted:
38+
delete schema schema_1
39+
40+
This action will result in the deletion of the following UC schemas. Any underlying data may be lost:
41+
delete schema schema_1
42+
43+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]
44+
45+
Deleting files...
46+
Destroy complete!
47+
48+
>>> [CLI] schemas delete main.test-schema-[UNIQUE_NAME]
49+
0
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
envsubst < databricks.yml.tmpl > databricks.yml
2+
3+
cleanup() {
4+
trace $CLI bundle destroy --auto-approve
5+
if [[ -n "$schema_id" ]]; then
6+
trace $CLI schemas delete $schema_id
7+
fi
8+
echo $?
9+
}
10+
trap cleanup EXIT
11+
12+
trace $CLI bundle deploy
13+
schema_id=$($CLI bundle summary --output json | jq -r '.resources.schemas.schema_1.id')
14+
trace $CLI grants get schema $schema_id --output json | jq '.privilege_assignments[] | select(.principal == "account users")'
15+
16+
trace $CLI bundle deployment unbind schema_1
17+
trace $CLI bundle deploy --var "suffix=another"
18+
19+
title "Grants should be the same as before unbind"
20+
trace $CLI grants get schema $schema_id --output json | jq '.privilege_assignments[] | select(.principal == "account users")'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
RequiresUnityCatalog = true
2+
3+
[EnvMatrix]
4+
DATABRICKS_BUNDLE_ENGINE = ["terraform"]
5+
6+
Ignore = [
7+
".databricks",
8+
]

acceptance/bundle/deployment/unbind/job/output.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Deployment complete!
1818

1919
>>> [CLI] jobs get [NUMID] --output json
2020
{
21+
"creator_user_name":"[USERNAME]",
2122
"job_id":[NUMID],
2223
"settings": {
2324
"deployment": {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
bundle:
2+
name: unbind_permissions
3+
4+
workspace:
5+
root_path: "~/.bundle/$UNIQUE_NAME"
6+
7+
resources:
8+
jobs:
9+
job_1:
10+
name: "Job name"
11+
permissions:
12+
- group_name: users
13+
level: CAN_MANAGE

0 commit comments

Comments
 (0)