-
Notifications
You must be signed in to change notification settings - Fork 146
Simulate app service principal and job permissions in test server #4644
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
pietern
wants to merge
4
commits into
main
Choose a base branch
from
issue-4309
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
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4ad94d3
Simulate app service principal and job permissions in test server
pietern 61a547a
Add acceptance test for app job permissions lifecycle
pietern 731dfdd
Replace fmt.Sprintf with string concatenation in upsertPermission call
pietern af2a258
Document direct engine Badness for app job permissions test
pietern 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 @@ | ||
| 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,30 @@ | ||
| bundle: | ||
| name: test-bundle | ||
|
|
||
| permissions: | ||
| - level: CAN_MANAGE | ||
| user_name: ${workspace.current_user.userName} | ||
|
|
||
| resources: | ||
| jobs: | ||
| my_job: | ||
| name: my-job | ||
| tasks: | ||
| - task_key: hello | ||
| environment_key: default | ||
| spark_python_task: | ||
| python_file: ./hello.py | ||
| environments: | ||
| - environment_key: default | ||
| spec: | ||
| client: "1" | ||
|
|
||
| apps: | ||
| my_app: | ||
| name: my-app | ||
| source_code_path: ./app | ||
| resources: | ||
| - name: my-job | ||
| job: | ||
| id: ${resources.jobs.my_job.id} | ||
| permission: CAN_MANAGE_RUN |
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,11 @@ | ||
| --- a/databricks.yml | ||
| +++ b/databricks.yml | ||
| @@ -10,6 +10,9 @@ | ||
| my_job: | ||
| name: my-job | ||
| + permissions: | ||
| + - level: CAN_MANAGE_RUN | ||
| + service_principal_name: ${resources.apps.my_app.service_principal_client_id} | ||
| tasks: | ||
| - task_key: hello | ||
| environment_key: default |
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") |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,40 @@ | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| === After first deploy | ||
| >>> has_manage_run | ||
| true | ||
|
|
||
| === After second deploy | ||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> has_manage_run | ||
| false | ||
|
|
||
| === Apply fix and redeploy | ||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> has_manage_run | ||
| true | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.apps.my_app | ||
| delete resources.jobs.my_job | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! |
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,26 @@ | ||
|
|
||
| # Test that app-granted permissions on a job survive a second deploy. | ||
| # Issue: https://github.com/databricks/cli/issues/4309 | ||
|
|
||
| trace $CLI bundle deploy | ||
|
|
||
| job_id=$(read_id.py my_job) | ||
|
|
||
| has_manage_run() { | ||
| MSYS_NO_PATHCONV=1 $CLI api get /api/2.0/permissions/jobs/$job_id \ | ||
| | jq 'any(.access_control_list[].all_permissions[]; .permission_level == "CAN_MANAGE_RUN")' | ||
| } | ||
|
|
||
| title "After first deploy" | ||
| trace has_manage_run | ||
|
|
||
| title "After second deploy" | ||
| trace $CLI bundle deploy | ||
| trace has_manage_run | ||
|
|
||
| title "Apply fix and redeploy" | ||
| patch -s --no-backup-if-mismatch databricks.yml < fix.patch | ||
| trace $CLI bundle deploy | ||
| trace has_manage_run | ||
|
|
||
| trace $CLI bundle destroy --auto-approve |
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,11 @@ | ||
| # Direct engine error: cannot plan resources.jobs.my_job.permissions: cannot update | ||
| # [0].service_principal_name: failed to navigate to parent [0]: [0]: cannot index struct. | ||
| # This is a bug in structaccess.Set() where it fails to index into a struct when | ||
| # setting permissions with service_principal_name. | ||
| # See https://github.com/databricks/cli/pull/4644 | ||
| Badness = "Direct engine fails to plan permissions with service_principal_name on jobs" | ||
| Cloud = true | ||
| RecordRequests = false | ||
|
|
||
| [EnvMatrix] | ||
| DATABRICKS_BUNDLE_ENGINE = ["terraform"] | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.