-
Notifications
You must be signed in to change notification settings - Fork 184
direct: Fix permanent drift on permissions after out-of-band parent recreate #5587
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
Draft
janniklasrose
wants to merge
6
commits into
main
Choose a base branch
from
janniklasrose/permissions-remote-id
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
713af9e
acceptance: add drift test for model_serving_endpoints recreated with…
janniklasrose b7ddd8f
direct/permissions: implement DoUpdateWithID to avoid permanent drift
janniklasrose 8dfaee1
direct: extend DoRead to receive planned newState
janniklasrose bb3f7ac
Merge remote-tracking branch 'origin/main' into permissions-remote-id
janniklasrose 7418948
Add NEXT_CHANGELOG.md entry for #5587
janniklasrose ee3d0b4
[WIP] add recreate_cascade badness test for registered_models
janniklasrose 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
13 changes: 13 additions & 0 deletions
13
...ce/bundle/resources/model_serving_endpoints/drift/recreated_same_name/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,13 @@ | ||
| bundle: | ||
| name: drift-mse-recreated-same-name-$UNIQUE_NAME | ||
|
|
||
| sync: | ||
| paths: [] | ||
|
|
||
| resources: | ||
| model_serving_endpoints: | ||
| my_endpoint: | ||
| name: mse-endpoint-$UNIQUE_NAME | ||
| permissions: | ||
| - level: CAN_VIEW | ||
| user_name: deco-test-user@databricks.com |
4 changes: 4 additions & 0 deletions
4
acceptance/bundle/resources/model_serving_endpoints/drift/recreated_same_name/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
acceptance/bundle/resources/model_serving_endpoints/drift/recreated_same_name/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,61 @@ | ||
|
|
||
| === Initial deployment | ||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/drift-mse-recreated-same-name-[UNIQUE_NAME]/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] serving-endpoints get mse-endpoint-[UNIQUE_NAME] | ||
| { | ||
| "name": "mse-endpoint-[UNIQUE_NAME]", | ||
| "creator": "[USERNAME]" | ||
| } | ||
|
|
||
| === Delete and recreate remotely with the same name | ||
| >>> [CLI] serving-endpoints delete mse-endpoint-[UNIQUE_NAME] | ||
|
|
||
| >>> [CLI] serving-endpoints create mse-endpoint-[UNIQUE_NAME] --no-wait | ||
| { | ||
| "name": "mse-endpoint-[UNIQUE_NAME]", | ||
| "creator": "[USERNAME]" | ||
| } | ||
|
|
||
| >>> [CLI] serving-endpoints get mse-endpoint-[UNIQUE_NAME] | ||
| { | ||
| "name": "mse-endpoint-[UNIQUE_NAME]", | ||
| "creator": "[USERNAME]" | ||
| } | ||
| Original endpoint id: [ORIGINAL_ENDPOINT_ID] | ||
| Remote recreated endpoint id: [REMOTE_RECREATED_ENDPOINT_ID] | ||
|
|
||
| === Plan after out-of-band recreate | ||
| >>> [CLI] bundle plan | ||
| update model_serving_endpoints.my_endpoint.permissions | ||
|
|
||
| Plan: 0 to add, 1 to change, 0 to delete, 1 unchanged | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/drift-mse-recreated-same-name-[UNIQUE_NAME]/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] serving-endpoints get mse-endpoint-[UNIQUE_NAME] | ||
| { | ||
| "name": "mse-endpoint-[UNIQUE_NAME]", | ||
| "creator": "[USERNAME]" | ||
| } | ||
|
|
||
| === Verify no permanent drift after deploy | ||
| >>> [CLI] bundle plan | ||
| Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.model_serving_endpoints.my_endpoint | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/drift-mse-recreated-same-name-[UNIQUE_NAME]/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! |
41 changes: 41 additions & 0 deletions
41
acceptance/bundle/resources/model_serving_endpoints/drift/recreated_same_name/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,41 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| rm -f out.requests.txt | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| endpoint_name="mse-endpoint-${UNIQUE_NAME}" | ||
|
|
||
| title "Initial deployment" | ||
| trace $CLI bundle deploy | ||
|
|
||
| original_endpoint_id=$($CLI serving-endpoints get "${endpoint_name}" | jq -r '.id') | ||
| add_repl.py "$original_endpoint_id" "ORIGINAL_ENDPOINT_ID" | ||
| trace $CLI serving-endpoints get "${endpoint_name}" | jq '{name, creator}' | ||
|
|
||
| title "Delete and recreate remotely with the same name" | ||
| trace $CLI serving-endpoints delete "${endpoint_name}" | ||
| trace $CLI serving-endpoints create "${endpoint_name}" --no-wait | jq '{name, creator}' | ||
|
|
||
| remote_recreated_endpoint_id=$($CLI serving-endpoints get "${endpoint_name}" | jq -r '.id') | ||
| add_repl.py "$remote_recreated_endpoint_id" "REMOTE_RECREATED_ENDPOINT_ID" | ||
| trace $CLI serving-endpoints get "${endpoint_name}" | jq '{name, creator}' | ||
|
|
||
| printf "Original endpoint id: %s\n" "$original_endpoint_id" | ||
| printf "Remote recreated endpoint id: %s\n" "$remote_recreated_endpoint_id" | ||
|
|
||
| if [ "$original_endpoint_id" = "$remote_recreated_endpoint_id" ]; then | ||
| echo "Expected remote recreation to assign a different endpoint id" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| title "Plan after out-of-band recreate" | ||
| trace $CLI bundle plan | ||
|
|
||
| trace $CLI bundle deploy | ||
| trace $CLI serving-endpoints get "${endpoint_name}" | jq '{name, creator}' | ||
|
|
||
| title "Verify no permanent drift after deploy" | ||
| trace $CLI bundle plan | contains.py "Plan: 0 to add, 0 to change, 0 to delete" |
8 changes: 8 additions & 0 deletions
8
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 |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| Badness = "After deleting and recreating a model serving endpoint remotely with the same name but a different endpoint_id, bundle plan shows an update on permissions (instead of create as in V2) because the V1 permissions API does not delete ACLs immediately when the parent is gone. UpdateWithID persists the new object_id in deployment state so subsequent plans do not show permanent drift." | ||
|
|
||
| Local = true | ||
| Cloud = true | ||
| RequiresUnityCatalog = true | ||
| RecordRequests = false | ||
|
|
||
| EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] |
17 changes: 17 additions & 0 deletions
17
acceptance/bundle/resources/registered_models/recreate_cascade/databricks.yml
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,17 @@ | ||
| bundle: | ||
| name: registered-model-cascade-recreate | ||
|
|
||
| resources: | ||
| schemas: | ||
| parent_schema: | ||
| name: myschema | ||
| catalog_name: main | ||
| storage_root: dbfs:/parent_storage_root_v1 | ||
| comment: parent schema | ||
|
|
||
| registered_models: | ||
| child_model: | ||
| name: mymodel | ||
| catalog_name: main | ||
| schema_name: ${resources.schemas.parent_schema.name} | ||
| comment: child model |
3 changes: 3 additions & 0 deletions
3
acceptance/bundle/resources/registered_models/recreate_cascade/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
126 changes: 126 additions & 0 deletions
126
acceptance/bundle/resources/registered_models/recreate_cascade/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,126 @@ | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/registered-model-cascade-recreate/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| === Change schema's storage_root to trigger schema recreate | ||
| >>> update_file.py databricks.yml dbfs:/parent_storage_root_v1 dbfs:/parent_storage_root_v2 | ||
|
|
||
| === Plan should recreate BOTH the schema and its dependent registered_model, but currently only the schema is recreated | ||
| >>> [CLI] bundle plan | ||
| recreate schemas.parent_schema | ||
|
|
||
| Plan: 1 to add, 0 to change, 1 to delete, 1 unchanged | ||
|
|
||
| >>> [CLI] bundle plan --output json | ||
| { | ||
| "plan_version": 2, | ||
| "cli_version": "[DEV_VERSION]", | ||
| "lineage": "[UUID]", | ||
| "serial": 1, | ||
| "plan": { | ||
| "resources.registered_models.child_model": { | ||
| "depends_on": [ | ||
| { | ||
| "node": "resources.schemas.parent_schema", | ||
| "label": "${resources.schemas.parent_schema.name}" | ||
| } | ||
| ], | ||
| "action": "skip", | ||
| "remote_state": { | ||
| "catalog_name": "main", | ||
| "comment": "child model", | ||
| "created_at": [UNIX_TIME_MILLIS][0], | ||
| "created_by": "[USERNAME]", | ||
| "full_name": "main.myschema.mymodel", | ||
| "metastore_id": "[UUID]", | ||
| "name": "mymodel", | ||
| "owner": "[USERNAME]", | ||
| "schema_name": "myschema", | ||
| "updated_at": [UNIX_TIME_MILLIS][0], | ||
| "updated_by": "[USERNAME]" | ||
| }, | ||
| "changes": { | ||
| "created_at": { | ||
| "action": "skip", | ||
| "reason": "empty", | ||
| "remote": 0 | ||
| }, | ||
| "created_by": { | ||
| "action": "skip", | ||
| "reason": "empty", | ||
| "remote": "" | ||
| }, | ||
| "full_name": { | ||
| "action": "skip", | ||
| "reason": "backend_default", | ||
| "remote": "main.myschema.mymodel" | ||
| }, | ||
| "metastore_id": { | ||
| "action": "skip", | ||
| "reason": "backend_default", | ||
| "remote": "[UUID]" | ||
| }, | ||
| "owner": { | ||
| "action": "skip", | ||
| "reason": "backend_default", | ||
| "remote": "[USERNAME]" | ||
| }, | ||
| "updated_at": { | ||
| "action": "skip", | ||
| "reason": "empty", | ||
| "remote": 0 | ||
| }, | ||
| "updated_by": { | ||
| "action": "skip", | ||
| "reason": "empty", | ||
| "remote": "" | ||
| } | ||
| } | ||
| }, | ||
| "resources.schemas.parent_schema": { | ||
| "action": "recreate", | ||
| "new_state": { | ||
| "value": { | ||
| "catalog_name": "main", | ||
| "comment": "parent schema", | ||
| "name": "myschema", | ||
| "storage_root": "dbfs:/parent_storage_root_v2" | ||
| } | ||
| }, | ||
| "remote_state": { | ||
| "browse_only": false, | ||
| "catalog_name": "main", | ||
| "catalog_type": "MANAGED_CATALOG", | ||
| "comment": "parent schema", | ||
| "created_at": [UNIX_TIME_MILLIS][1], | ||
| "created_by": "[USERNAME]", | ||
| "effective_predictive_optimization_flag": { | ||
| "inherited_from_name": "[METASTORE_NAME]", | ||
| "inherited_from_type": "METASTORE", | ||
| "value": "ENABLE" | ||
| }, | ||
| "enable_predictive_optimization": "INHERIT", | ||
| "full_name": "main.myschema", | ||
| "metastore_id": "[UUID]", | ||
| "name": "myschema", | ||
| "owner": "[USERNAME]", | ||
| "schema_id": "[UUID]", | ||
| "storage_root": "dbfs:/parent_storage_root_v1", | ||
| "updated_at": [UNIX_TIME_MILLIS][1], | ||
| "updated_by": "[USERNAME]" | ||
| }, | ||
| "changes": { | ||
| "storage_root": { | ||
| "action": "recreate", | ||
| "reason": "immutable", | ||
| "old": "dbfs:/parent_storage_root_v1", | ||
| "new": "dbfs:/parent_storage_root_v2", | ||
| "remote": "dbfs:/parent_storage_root_v1" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
acceptance/bundle/resources/registered_models/recreate_cascade/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,9 @@ | ||
| echo "*" > .gitignore | ||
| trace $CLI bundle deploy | ||
|
|
||
| title "Change schema's storage_root to trigger schema recreate" | ||
| trace update_file.py databricks.yml "dbfs:/parent_storage_root_v1" "dbfs:/parent_storage_root_v2" | ||
|
|
||
| title "Plan should recreate BOTH the schema and its dependent registered_model, but currently only the schema is recreated" | ||
| trace $CLI bundle plan | ||
| trace $CLI bundle plan --output json |
6 changes: 6 additions & 0 deletions
6
acceptance/bundle/resources/registered_models/recreate_cascade/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,6 @@ | ||
| Local = true | ||
| Cloud = false | ||
| RecordRequests = false | ||
| EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] | ||
|
|
||
| Badness = "Recreating a parent resource (schema) should propagate Recreate to dependents (registered_model) that reference it, but the planner does not. The dependent plans Skip while the parent is deleted underneath it. On a real workspace this either fails the parent delete (children still attached) or orphans the child. Tracked as a framework-level fix in bundle/direct/bundle_plan.go." | ||
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
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.
not permissions, but also recreate cascade issue