Repository navigation
Fixed immutable folder failing with DMS or top level permissions #7001
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
+280
−53
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 @@ | ||
| * Fixed `experimental.immutable_folder` failing with `experimental.deployment_history` ("workspace_info.file_path must be an absolute workspace path") and failing `bundle validate` when top-level `permissions` are set. ([#7001](https://github.com/databricks/cli/pull/7001)) |
19 changes: 19 additions & 0 deletions
19
acceptance/bundle/dms/immutable-folder/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,19 @@ | ||
| bundle: | ||
| name: dms-immutable-folder-$UNIQUE_NAME | ||
| experimental: | ||
| immutable_folder: true | ||
| deployment_history: true | ||
|
|
||
| resources: | ||
| jobs: | ||
| foo: | ||
| name: foo | ||
| tasks: | ||
| - task_key: main | ||
| spark_python_task: | ||
| python_file: ./src/main.py | ||
| environment_key: env | ||
| environments: | ||
| - environment_key: env | ||
| spec: | ||
| environment_version: "4" |
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,3 @@ | ||
| Cloud = false | ||
| EnvMatrix.DMS = ["true"] | ||
| EnvMatrix.READPLAN = ["", "1"] |
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,43 @@ | ||
|
|
||
| === Deploying with an immutable folder records the resolved snapshot path as the deployment's file_path | ||
| >>> [CLI] bundle deploy | ||
| Created internal_immutable_snapshots.immutable | ||
| Created jobs.foo | ||
| Files: 0 uploaded, 0 deleted | ||
| Resources: 2 created, 0 changed, 0 deleted, 0 unchanged | ||
|
|
||
| >>> MSYS_NO_PATHCONV=1 [CLI] api get /api/2.0/bundle/deployments/[DEPLOYMENT_ID] | ||
| { | ||
| "workspace_info": { | ||
| "root_path": "/Workspace/Users/[USERNAME]/.bundle/dms-immutable-folder-[UNIQUE_NAME]/default", | ||
| "file_path": "/Workspace/Users/[UUID]/.snapshots/[SNAPSHOT_HASH]/[SNAPSHOT_HASH]/files" | ||
| } | ||
| } | ||
|
|
||
| === A new snapshot moves file_path, which is then updated on the deployment | ||
| >>> [CLI] bundle deploy | ||
| Recreated internal_immutable_snapshots.immutable | ||
| Updated jobs.foo | ||
| Files: 0 uploaded, 0 deleted | ||
| Resources: 1 created, 1 changed, 1 deleted, 0 unchanged | ||
|
|
||
| >>> MSYS_NO_PATHCONV=1 [CLI] api get /api/2.0/bundle/deployments/[DEPLOYMENT_ID] | ||
| { | ||
| "workspace_info": { | ||
| "root_path": "/Workspace/Users/[USERNAME]/.bundle/dms-immutable-folder-[UNIQUE_NAME]/default", | ||
| "file_path": "/Workspace/Users/[UUID]/.snapshots/[SNAPSHOT_HASH]/[SNAPSHOT_HASH]/files" | ||
| } | ||
| } | ||
|
|
||
| === An unchanged snapshot keeps the recorded file_path | ||
| >>> [CLI] bundle deploy | ||
| Files: 0 uploaded, 0 deleted | ||
| Resources: 0 created, 0 changed, 0 deleted, 2 unchanged | ||
|
|
||
| >>> MSYS_NO_PATHCONV=1 [CLI] api get /api/2.0/bundle/deployments/[DEPLOYMENT_ID] | ||
| { | ||
| "workspace_info": { | ||
| "root_path": "/Workspace/Users/[USERNAME]/.bundle/dms-immutable-folder-[UNIQUE_NAME]/default", | ||
| "file_path": "/Workspace/Users/[UUID]/.snapshots/[SNAPSHOT_HASH]/[SNAPSHOT_HASH]/files" | ||
| } | ||
| } |
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,30 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| deployment_workspace_info() { | ||
| deployment_id=$(MSYS_NO_PATHCONV=1 $CLI workspace get-status "/Workspace/Users/${CURRENT_USER_NAME}/.bundle/dms-immutable-folder-${UNIQUE_NAME}/default/state/resources.deployment.json" -o json | python3 -c 'import sys,json; print(json.load(sys.stdin)["object_id"])') | ||
| add_repl "$deployment_id" DEPLOYMENT_ID | ||
| # MSYS_NO_PATHCONV: Git Bash on Windows would rewrite the leading-'/' API path. | ||
| trace MSYS_NO_PATHCONV=1 $CLI api get "/api/2.0/bundle/deployments/${deployment_id}" | jq '{workspace_info}' | ||
| } | ||
|
|
||
| deploy() { | ||
| mkdir -p .databricks | ||
| $CLI bundle plan -o json > .databricks/plan.json | ||
| trace $CLI bundle deploy $(readplanarg .databricks/plan.json) | ||
| rm .databricks/plan.json | ||
| } | ||
|
|
||
| title "Deploying with an immutable folder records the resolved snapshot path as the deployment's file_path" | ||
| deploy | ||
| deployment_workspace_info | ||
|
|
||
| title "A new snapshot moves file_path, which is then updated on the deployment" | ||
| echo 'print("changed")' > src/main.py | ||
| deploy | ||
| deployment_workspace_info | ||
|
|
||
| title "An unchanged snapshot keeps the recorded file_path" | ||
| deploy | ||
| deployment_workspace_info | ||
|
|
||
| rm -f "$OUT_REQUESTS" |
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 @@ | ||
| print("hello") |
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 @@ | ||
| # The immutable folder API is not available against a real workspace yet. | ||
| Cloud = false | ||
|
|
||
| EnvMatrix.READPLAN = ["", "1"] | ||
|
|
||
| Ignore = [ | ||
| '.databricks', | ||
| 'databricks.yml', | ||
| ] | ||
|
|
||
| # The snapshot path is content-addressed. | ||
| [[Repls]] | ||
| Old = '[0-9a-f]{64}' | ||
| New = '[SNAPSHOT_HASH]' | ||
|
|
||
| # When READPLAN=1, "bundle deploy" is called as "bundle deploy --plan .databricks/plan.json". | ||
| # Normalize so both variants produce identical output. | ||
| [[Repls]] | ||
| Old = ' --plan .databricks/plan.json' | ||
| New = '' | ||
9 changes: 9 additions & 0 deletions
9
acceptance/bundle/validate/immutable_folder_permissions/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,9 @@ | ||
| bundle: | ||
| name: my-bundle | ||
|
|
||
| experimental: | ||
| immutable_folder: true | ||
|
|
||
| permissions: | ||
| - level: CAN_VIEW | ||
| user_name: viewer@example.com |
2 changes: 2 additions & 0 deletions
2
acceptance/bundle/validate/immutable_folder_permissions/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 = false | ||
| EnvMatrix.DMS = ["", "true"] |
21 changes: 21 additions & 0 deletions
21
acceptance/bundle/validate/immutable_folder_permissions/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,21 @@ | ||
|
|
||
| >>> [CLI] bundle validate | ||
| Recommendation: permissions section should explicitly include the current deployment identity '[USERNAME]' or one of its groups | ||
| If it is not included, CAN_MANAGE permissions are only applied if the present identity is used to deploy. | ||
|
|
||
| Consider using a adding a top-level permissions section such as the following: | ||
|
|
||
| permissions: | ||
| - user_name: [USERNAME] | ||
| level: CAN_MANAGE | ||
|
|
||
| See https://docs.databricks.com/dev-tools/bundles/permissions.html to learn more about permission configuration. | ||
| in databricks.yml:8:3 | ||
|
|
||
| Name: my-bundle | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/my-bundle/default | ||
|
|
||
| Found 1 recommendation |
3 changes: 3 additions & 0 deletions
3
acceptance/bundle/validate/immutable_folder_permissions/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,3 @@ | ||
| # file_path and artifact_path point into the snapshot, which does not exist until deploy, | ||
| # so validate must not check their folder permissions. | ||
| trace $CLI bundle validate |
2 changes: 2 additions & 0 deletions
2
acceptance/bundle/validate/immutable_folder_permissions/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 = false | ||
| Ignore = [".databricks"] |
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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| { | ||
| "artifact_path": "TestResolveVariableReferences/bar/artifacts", | ||
| "file_path": "TestResolveVariableReferences/bar/baz", | ||
| "resource_path": "TestResolveVariableReferences/bar/resources", | ||
| "root_path": "TestResolveVariableReferences/bar", | ||
| "state_path": "TestResolveVariableReferences/bar/state" | ||
| "artifact_path": "/Workspace/TestResolveVariableReferences/bar/artifacts", | ||
| "file_path": "/Workspace/TestResolveVariableReferences/bar/baz", | ||
| "resource_path": "/Workspace/TestResolveVariableReferences/bar/resources", | ||
| "root_path": "/Workspace/TestResolveVariableReferences/bar", | ||
| "state_path": "/Workspace/TestResolveVariableReferences/bar/state" | ||
| } |
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
10 changes: 5 additions & 5 deletions
10
acceptance/bundle/variables/resolve-vars-in-root-path/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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| { | ||
| "artifact_path": "TestResolveVariableReferencesToBundleVariables/bar/artifacts", | ||
| "file_path": "TestResolveVariableReferencesToBundleVariables/bar/files", | ||
| "resource_path": "TestResolveVariableReferencesToBundleVariables/bar/resources", | ||
| "root_path": "TestResolveVariableReferencesToBundleVariables/bar", | ||
| "state_path": "TestResolveVariableReferencesToBundleVariables/bar/state" | ||
| "artifact_path": "/Workspace/TestResolveVariableReferencesToBundleVariables/bar/artifacts", | ||
| "file_path": "/Workspace/TestResolveVariableReferencesToBundleVariables/bar/files", | ||
| "resource_path": "/Workspace/TestResolveVariableReferencesToBundleVariables/bar/resources", | ||
| "root_path": "/Workspace/TestResolveVariableReferencesToBundleVariables/bar", | ||
| "state_path": "/Workspace/TestResolveVariableReferencesToBundleVariables/bar/state" | ||
| } |
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.
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.
if the hash is deterministic, should we consider removing this repl? Helps assert the metadata being recorded is indeed the right path.
If this causes issues across operating systems, we can limit this test to just linux. WDYT?
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.
I'd prefer to run it on all OS but then the hash is not the same across OS. I think having REPL like this is good enough for assertion