-
Notifications
You must be signed in to change notification settings - Fork 199
Create a new immutable snapshot when bundle permissions change #5957
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
Open
andrewnester
wants to merge
1
commit into
main
Choose a base branch
from
fix/immutable-snapshot-permissions
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.
Open
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions
19
acceptance/bundle/deploy/immutable-permissions-change/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: test-bundle-immutable-perms-$UNIQUE_NAME | ||
|
|
||
| experimental: | ||
| immutable_folder: true | ||
|
|
||
| resources: | ||
| jobs: | ||
| my_job: | ||
| name: my job | ||
| tasks: | ||
| - task_key: spark_python_task | ||
| spark_python_task: | ||
| python_file: ./src/main.py | ||
| environment_key: env | ||
| environments: | ||
| - environment_key: env | ||
| spec: | ||
| environment_version: "4" |
3 changes: 3 additions & 0 deletions
3
acceptance/bundle/deploy/immutable-permissions-change/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
acceptance/bundle/deploy/immutable-permissions-change/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,52 @@ | ||
|
|
||
| === Deploy without permissions | ||
| >>> [CLI] bundle deploy | ||
| Uploading immutable bundle snapshot... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
| First snapshot path: /Workspace/Users/[UUID]/.snapshots/[UUID]/[SNAPSHOT_HASH]/files/src/main.py | ||
|
|
||
| === Add permissions and redeploy | ||
| >>> [CLI] bundle deploy | ||
| 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:22:3 | ||
|
|
||
| Uploading immutable bundle snapshot... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
| Second snapshot path: /Workspace/Users/[UUID]/.snapshots/[UUID]/[SNAPSHOT_HASH]/files/src/main.py | ||
|
|
||
| === Verify snapshot path changed after permissions change | ||
| OK: snapshot path changed as expected | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| 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:22:3 | ||
|
|
||
| The following resources will be deleted: | ||
| delete resources.jobs.my_job | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-immutable-perms-[UNIQUE_NAME]/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! |
35 changes: 35 additions & 0 deletions
35
acceptance/bundle/deploy/immutable-permissions-change/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,35 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| title "Deploy without permissions" | ||
| trace $CLI bundle deploy | ||
|
|
||
| JOB_ID=$($CLI bundle summary -o json | jq -r '.resources.jobs.my_job.id') | ||
| SNAPSHOT_PATH_1=$($CLI jobs get "$JOB_ID" | jq -r '.settings.tasks[0].spark_python_task.python_file') | ||
| echo "First snapshot path: $SNAPSHOT_PATH_1" | ||
|
|
||
| title "Add permissions and redeploy" | ||
| cat >> databricks.yml <<'EOF' | ||
|
|
||
| permissions: | ||
| - level: CAN_VIEW | ||
| group_name: admins | ||
| EOF | ||
|
|
||
| trace $CLI bundle deploy | ||
|
|
||
| SNAPSHOT_PATH_2=$($CLI jobs get "$JOB_ID" | jq -r '.settings.tasks[0].spark_python_task.python_file') | ||
| echo "Second snapshot path: $SNAPSHOT_PATH_2" | ||
|
|
||
| title "Verify snapshot path changed after permissions change" | ||
| echo "" | ||
| if [ "$SNAPSHOT_PATH_1" = "$SNAPSHOT_PATH_2" ]; then | ||
| echo "ERROR: snapshot path did not change after permissions were added" | ||
| exit 1 | ||
| else | ||
| echo "OK: snapshot path changed as expected" | ||
| fi |
1 change: 1 addition & 0 deletions
1
acceptance/bundle/deploy/immutable-permissions-change/src/main.py
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 from Spark Python Task!") |
15 changes: 15 additions & 0 deletions
15
acceptance/bundle/deploy/immutable-permissions-change/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,15 @@ | ||
| Local = true | ||
| Cloud = false # Temporary disable cloud tests until the API is fully available | ||
|
|
||
| # immutable_folder only works with the direct engine. | ||
| EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] | ||
|
|
||
| Ignore = [ | ||
| "databricks.yml", | ||
| ".databricks", | ||
| ] | ||
|
|
||
| [[Repls]] | ||
| # Replace snapshot hash with SNAPSHOT_HASH | ||
| Old = "[0-9a-f]{64}" | ||
| New = "[SNAPSHOT_HASH]" | ||
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.
Can you add a Badness here so that we remember to flip this on at least? I think that's the convention we use in other tests