-
Notifications
You must be signed in to change notification settings - Fork 154
Fixed bundle deploy to not update permissions for unbound resources #3642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ba78878
a52e122
a2f9235
b8d4fcf
08bf120
11acdcc
c04d29b
1851e47
fc57794
cde762d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| bundle: | ||
| name: unbind_grants-$UNIQUE_NAME | ||
|
|
||
| workspace: | ||
| root_path: ~/.bundle/$UNIQUE_NAME | ||
|
|
||
| variables: | ||
| suffix: | ||
| default: "" | ||
| description: "Suffix for the schema name" | ||
|
|
||
| resources: | ||
| schemas: | ||
| schema_1: | ||
| name: "test-schema-$UNIQUE_NAME${var.suffix}" | ||
| catalog_name: "main" | ||
| grants: | ||
| - principal: "account users" | ||
| privileges: ["CREATE_VOLUME", "SELECT"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] grants get schema main.test-schema-[UNIQUE_NAME] --output json | ||
| { | ||
| "principal": "account users", | ||
| "privileges": [ | ||
| "CREATE_VOLUME", | ||
| "SELECT" | ||
| ] | ||
| } | ||
|
|
||
| >>> [CLI] bundle deployment unbind schema_1 | ||
| Updating deployment state... | ||
|
|
||
| >>> [CLI] bundle deploy --var suffix=another | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| === Grants should be the same as before unbind | ||
| >>> [CLI] grants get schema main.test-schema-[UNIQUE_NAME] --output json | ||
| { | ||
| "principal": "account users", | ||
| "privileges": [ | ||
| "CREATE_VOLUME", | ||
| "SELECT" | ||
| ] | ||
| } | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete schema schema_1 | ||
|
|
||
| This action will result in the deletion of the following UC schemas. Any underlying data may be lost: | ||
| delete schema schema_1 | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME] | ||
|
|
||
| Deleting files... | ||
| Destroy complete! | ||
|
|
||
| >>> [CLI] schemas delete main.test-schema-[UNIQUE_NAME] | ||
| 0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| if [[ -n "$schema_id" ]]; then | ||
| trace $CLI schemas delete $schema_id | ||
| fi | ||
| echo $? | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| trace $CLI bundle deploy | ||
| schema_id=$($CLI bundle summary --output json | jq -r '.resources.schemas.schema_1.id') | ||
| trace $CLI grants get schema $schema_id --output json | jq '.privilege_assignments[] | select(.principal == "account users")' | ||
|
|
||
| trace $CLI bundle deployment unbind schema_1 | ||
| trace $CLI bundle deploy --var "suffix=another" | ||
|
|
||
| title "Grants should be the same as before unbind" | ||
| trace $CLI grants get schema $schema_id --output json | jq '.privilege_assignments[] | select(.principal == "account users")' | ||
andrewnester marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| RequiresUnityCatalog = true | ||
|
|
||
| [EnvMatrix] | ||
| DATABRICKS_BUNDLE_ENGINE = ["terraform"] | ||
|
|
||
| Ignore = [ | ||
| ".databricks", | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| bundle: | ||
| name: unbind_permissions | ||
|
|
||
| workspace: | ||
| root_path: "~/.bundle/$UNIQUE_NAME" | ||
|
|
||
| resources: | ||
| jobs: | ||
| job_1: | ||
| name: "Job name" | ||
| permissions: | ||
| - group_name: users | ||
| level: CAN_MANAGE |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] bundle summary --output json | ||
|
|
||
| >>> [CLI] jobs get-permissions [NUMID] --output json | ||
| { | ||
| "all_permissions": [ | ||
| { | ||
| "inherited": false, | ||
| "permission_level": "CAN_MANAGE" | ||
| } | ||
| ], | ||
| "group_name": "users" | ||
| } | ||
|
|
||
| >>> [CLI] bundle deployment unbind job_1 | ||
| Updating deployment state... | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| === Permissions should be the same as before unbind | ||
| >>> [CLI] jobs get-permissions [NUMID] --output json | ||
andrewnester marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| "all_permissions": [ | ||
| { | ||
| "inherited": false, | ||
| "permission_level": "CAN_MANAGE" | ||
| } | ||
| ], | ||
| "group_name": "users" | ||
| } | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete job job_1 | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME] | ||
|
|
||
| Deleting files... | ||
| Destroy complete! | ||
|
|
||
| >>> [CLI] jobs delete [NUMID] | ||
| 0 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| trace $CLI jobs delete $job_id | ||
| echo $? | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| trace $CLI bundle deploy | ||
| job_id=$(trace $CLI bundle summary --output json | jq -r '.resources.jobs.job_1.id') | ||
| trace $CLI jobs get-permissions $job_id --output json | jq '.access_control_list[] | select(.group_name == "users")' | ||
|
|
||
| trace $CLI bundle deployment unbind job_1 | ||
| trace $CLI bundle deploy | ||
|
|
||
| title "Permissions should be the same as before unbind" | ||
| trace $CLI jobs get-permissions $job_id --output json | jq '.access_control_list[] | select(.group_name == "users")' | ||
andrewnester marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [EnvMatrix] | ||
| DATABRICKS_BUNDLE_ENGINE = ["terraform"] | ||
|
|
||
| Ignore = [ | ||
| ".databricks", | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,16 +60,17 @@ type FakeWorkspace struct { | |
| repoIdByPath map[string]int64 | ||
|
|
||
| // normally, ids are not sequential, but we make them sequential for deterministic diff | ||
| nextJobId int64 | ||
| nextJobRunId int64 | ||
| Jobs map[int64]jobs.Job | ||
| JobRuns map[int64]jobs.Run | ||
|
|
||
| nextJobId int64 | ||
| nextJobRunId int64 | ||
| Jobs map[int64]jobs.Job | ||
| JobRuns map[int64]jobs.Run | ||
| JobPermissions map[string][]jobs.JobAccessControlRequest | ||
| Pipelines map[string]pipelines.GetPipelineResponse | ||
| PipelineUpdates map[string]bool | ||
| Monitors map[string]catalog.MonitorInfo | ||
| Apps map[string]apps.App | ||
| Schemas map[string]catalog.SchemaInfo | ||
| SchemasGrants map[string][]catalog.PrivilegeAssignment | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: should also be singular, |
||
| Volumes map[string]catalog.VolumeInfo | ||
| Dashboards map[string]dashboards.Dashboard | ||
| SqlWarehouses map[string]sql.GetWarehouseResponse | ||
|
|
@@ -153,6 +154,8 @@ func NewFakeWorkspace(url, token string) *FakeWorkspace { | |
|
|
||
| Jobs: map[int64]jobs.Job{}, | ||
| JobRuns: map[int64]jobs.Run{}, | ||
| JobPermissions: map[string][]jobs.JobAccessControlRequest{}, | ||
| SchemasGrants: map[string][]catalog.PrivilegeAssignment{}, | ||
| nextJobId: TestJobID, | ||
| nextJobRunId: TestRunID, | ||
| Pipelines: map[string]pipelines.GetPipelineResponse{}, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.