Repository navigation
Re-key permissions when their parent's ID changes #7361
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d119521
acc: permissions keep a stale ID after their parent is recreated
denik 153fc87
Re-key permissions when their parent's ID changes
denik da31e5a
acc: normalize the deployer's owner entry across clouds
denik ecf1220
Link PR in changelog fragment
denik efab0cd
acc: permissions state follows the job created by the v1 state migration
denik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * Fix permissions of a recreated pipeline, app, dashboard, model serving endpoint or other resource staying recorded under the old ID, which made every later `bundle plan` propose to apply them again. ([#7361](https://github.com/databricks/cli/pull/7361)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
acceptance/bundle/resources/model_serving_endpoints/drift/recreated_same_name/test.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,2 @@ | ||
| Badness = "After deleting and recreating a model serving endpoint remotely with the same name but a different endpoint_id, bundle plan/deploy ends up with a permanent update on permissions because the V1 permissions API does not delete ACLs immediately when the parent is gone." | ||
|
|
||
| Cloud = true | ||
| RecordRequests = false |
20 changes: 20 additions & 0 deletions
20
acceptance/bundle/resources/permissions/pipelines/recreate/databricks.yml.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| bundle: | ||
| name: test-bundle-$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| pipelines: | ||
| foo: | ||
| name: test-pipeline-$UNIQUE_NAME | ||
| libraries: | ||
| - notebook: | ||
| path: ./nb.sql | ||
| catalog: main | ||
| target: ${resources.schemas.bar.name} | ||
| permissions: | ||
| - level: CAN_VIEW | ||
| group_name: users | ||
|
|
||
| schemas: | ||
| bar: | ||
| catalog_name: main | ||
| name: test-schema-$UNIQUE_NAME |
2 changes: 2 additions & 0 deletions
2
acceptance/bundle/resources/permissions/pipelines/recreate/nb.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -- Databricks notebook source | ||
| select 1 |
2 changes: 2 additions & 0 deletions
2
acceptance/bundle/resources/permissions/pipelines/recreate/out.test.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Cloud = true | ||
| EnvMatrix.DMS = ["", "true"] |
101 changes: 101 additions & 0 deletions
101
acceptance/bundle/resources/permissions/pipelines/recreate/output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
|
|
||
| === Deploy a pipeline with permissions | ||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/default/files... | ||
| Created pipelines.foo | ||
| Created pipelines.foo.permissions | ||
| Created schemas.bar | ||
| Files: 3 uploaded, 0 deleted | ||
| Resources: 3 created, 0 changed, 0 deleted, 0 unchanged | ||
|
|
||
| >>> print_requests.py //permissions | ||
| { | ||
| "method": "PUT", | ||
| "path": "/api/2.0/permissions/pipelines/[OLD_PIPELINE_ID]", | ||
| "body": { | ||
| "access_control_list": [ | ||
| { | ||
| "group_name": "users", | ||
| "permission_level": "CAN_VIEW" | ||
| }, | ||
| { | ||
| "permission_level": "IS_OWNER", | ||
| "service_principal_name": "[USERNAME]" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| >>> read_state.py pipelines foo.permissions id | ||
| pipelines foo.permissions id='/pipelines/[OLD_PIPELINE_ID]' | ||
|
|
||
| === Switch from catalog to storage: the pipeline is recreated with a new ID | ||
| >>> update_file.py databricks.yml catalog: main storage: dbfs:/my-storage | ||
|
|
||
| >>> update_file.py databricks.yml target: ${resources.schemas.bar.name} #target: ${resources.schemas.bar.name} | ||
|
|
||
| >>> [CLI] bundle plan --output json | ||
| { | ||
| "object_id": { | ||
| "action": "update_id", | ||
| "reason": "id_changes", | ||
| "old": "/pipelines/[OLD_PIPELINE_ID]", | ||
| "new": "", | ||
| "remote": "/pipelines/[OLD_PIPELINE_ID]" | ||
| } | ||
| } | ||
|
|
||
| === Deploy recreates the pipeline and applies the permissions to the new one | ||
| >>> [CLI] bundle deploy --auto-approve | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/default/files... | ||
|
|
||
| This action will result in the deletion or recreation of the following Lakeflow Spark Declarative Pipelines along with the | ||
| Streaming Tables (STs) and Materialized Views (MVs) managed by them. Recreating the pipelines will | ||
| restore the defined STs and MVs through full refresh. Note that recreation is necessary when pipeline | ||
| properties such as the 'catalog' or 'storage' are changed: | ||
| recreate resources.pipelines.foo | ||
| Recreated pipelines.foo | ||
| Updated pipelines.foo.permissions | ||
| Files: 1 uploaded, 0 deleted | ||
| Resources: 1 created, 1 changed, 1 deleted, 1 unchanged | ||
|
|
||
| >>> print_requests.py //permissions | ||
| { | ||
| "method": "PUT", | ||
| "path": "/api/2.0/permissions/pipelines/[NEW_PIPELINE_ID]", | ||
| "body": { | ||
| "access_control_list": [ | ||
| { | ||
| "group_name": "users", | ||
| "permission_level": "CAN_VIEW" | ||
| }, | ||
| { | ||
| "permission_level": "IS_OWNER", | ||
| "service_principal_name": "[USERNAME]" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| === The permissions are recorded under the new ID, so the next plan is a no-op | ||
| >>> read_state.py pipelines foo.permissions id | ||
| pipelines foo.permissions id='/pipelines/[NEW_PIPELINE_ID]' | ||
|
|
||
| >>> [CLI] bundle plan | ||
| Plan: 0 to add, 0 to change, 0 to delete, 3 unchanged | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.pipelines.foo | ||
| delete resources.schemas.bar | ||
|
|
||
| This action will result in the deletion of the following UC schemas. Any underlying data may be lost: | ||
| delete resources.schemas.bar | ||
|
|
||
| This action will result in the deletion of the following Lakeflow Spark Declarative Pipelines along with the | ||
| Streaming Tables (STs) and Materialized Views (MVs) managed by them. Set 'cascade_on_destroy: false' on a pipeline to retain datasets on pipeline deletion: | ||
| delete resources.pipelines.foo | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/default | ||
|
|
||
| Destroy: 2 deleted |
29 changes: 29 additions & 0 deletions
29
acceptance/bundle/resources/permissions/pipelines/recreate/script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
|
|
||
| # Consume the destroy's requests so none are left recorded. | ||
| print_requests.py //permissions &> LOG.destroy_requests | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| title "Deploy a pipeline with permissions" | ||
| trace $CLI bundle deploy | ||
| add_repl.py "$($CLI bundle summary -o json | jq -r .resources.pipelines.foo.id)" OLD_PIPELINE_ID | ||
| trace print_requests.py //permissions | ||
| trace read_state.py pipelines foo.permissions id | ||
|
|
||
| title "Switch from catalog to storage: the pipeline is recreated with a new ID" | ||
| trace update_file.py databricks.yml "catalog: main" "storage: dbfs:/my-storage" | ||
| trace update_file.py databricks.yml 'target: ${resources.schemas.bar.name}' '#target: ${resources.schemas.bar.name}' | ||
| trace $CLI bundle plan --output json | jq '.plan["resources.pipelines.foo.permissions"].changes' | ||
|
|
||
| title "Deploy recreates the pipeline and applies the permissions to the new one" | ||
| trace $CLI bundle deploy --auto-approve | ||
| add_repl.py "$($CLI bundle summary -o json | jq -r .resources.pipelines.foo.id)" NEW_PIPELINE_ID | ||
| trace print_requests.py //permissions | ||
|
|
||
| title "The permissions are recorded under the new ID, so the next plan is a no-op" | ||
| trace read_state.py pipelines foo.permissions id | ||
| trace $CLI bundle plan |
12 changes: 12 additions & 0 deletions
12
acceptance/bundle/resources/permissions/pipelines/recreate/test.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| Cloud = true | ||
|
|
||
| Ignore = [ | ||
| ".databricks", | ||
| ".gitignore", | ||
| "databricks.yml", | ||
| ] | ||
|
|
||
| # The deployer is added as IS_OWNER: a service principal on AWS and Azure, a user locally and on GCP. | ||
| [[Repls]] | ||
| Old = '"user_name": "\[USERNAME\]"' | ||
| New = '"service_principal_name": "[USERNAME]"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| updatable_id_fields: | ||
| # The ID is the parent's object ID, which changes when the parent is recreated. | ||
| # UpdateWithID records the new ID, so DoRead does not keep reading the permissions | ||
| # of the deleted object. | ||
| - field: object_id | ||
| reason: id_changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we use the
idargument here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly, these are equivalent.