Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
bundle:
name: test-bundle-$UNIQUE_NAME

workspace:
root_path: /Workspace/Users/$TEST_SP_APPLICATION_ID/.bundle/test-bundle-$UNIQUE_NAME

resources:
jobs:
my_job:
name: test-job-$UNIQUE_NAME
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Cloud = true
RunsOnDbr = false
GOOS.windows = false
CloudEnvs.azure = false
EnvMatrix.DMS = ["", "true"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

=== The service principal deploys a job that declares no permissions

>>> as-test-sp [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[TEST_SP_APPLICATION_ID]/.bundle/test-bundle-[UNIQUE_NAME]/files...
Created jobs.my_job
Files: 2 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged

=== The current identity is granted CAN_MANAGE on the job, outside the bundle

CAN_MANAGE [USERNAME]
IS_OWNER [TEST_SP_APPLICATION_ID]

=== The current identity runs config-remote-sync

>>> [CLI] bundle config-remote-sync --save
Detected changes in 1 resource(s):

Resource: resources.jobs.my_job
permissions: add



>>> diff.py databricks.yml.backup databricks.yml
--- databricks.yml.backup
+++ databricks.yml
@@ -9,2 +9,5 @@
my_job:
name: test-job-[UNIQUE_NAME]
+ permissions:
+ - level: IS_OWNER
+ service_principal_name: [TEST_SP_APPLICATION_ID]

=== The service principal deploys the synced config

>>> as-test-sp [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[TEST_SP_APPLICATION_ID]/.bundle/test-bundle-[UNIQUE_NAME]/files...
Created jobs.my_job.permissions
Files: 1 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 1 unchanged

=== The job's ACL after the deploy

IS_OWNER [TEST_SP_APPLICATION_ID]

>>> as-test-sp [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.jobs.my_job

All files and directories at the following location will be deleted: /Workspace/Users/[TEST_SP_APPLICATION_ID]/.bundle/test-bundle-[UNIQUE_NAME]

Destroy: 1 deleted
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
envsubst < databricks.yml.tmpl > databricks.yml

cleanup() {
trace as-test-sp $CLI bundle destroy --auto-approve
}
trap cleanup EXIT

title "The service principal deploys a job that declares no permissions"
trace as-test-sp $CLI bundle deploy
job_id=$(as-test-sp $CLI bundle summary -o json | jq -r '.resources.jobs.my_job.id')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nice to have] testing.md asks for the acceptance/bin/ helpers instead of inline jq pipelines, and read_id.py my_job prints the ID from state and registers the [MY_JOB_ID] replacement. Could this be job_id=$(as-test-sp read_id.py my_job)? In owner/script and handover/script (lines 10–11) that would also replace the hand-written jq plus add_repl "$job_id" MY_JOB_ID pair. The same pipeline appears in every other new script, and other_target would use read_id.py -t staging / -t prod.


title "The current identity is granted CAN_MANAGE on the job, outside the bundle\n"
$CLI permissions set jobs $job_id --json '{"access_control_list":[
{"permission_level":"IS_OWNER","service_principal_name":"'"$TEST_SP_APPLICATION_ID"'"},
{"permission_level":"CAN_MANAGE","'"$CURRENT_USER_FIELD"'":"'"$CURRENT_USER_NAME"'"}
]}' > /dev/null

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nice to have] testing.md says to send noisy output to LOG.<name>, not to /dev/null. Here the response of permissions set is thrown away, so if a grant fails or comes back different on a cloud run, nothing records what the backend returned. Can these go to something like > LOG.permissions_set? The same applies to declared, experiment, handover, no_grants, owner, syncer_home, undeployed, and both calls in other_target.

print_acl jobs $job_id

title "The current identity runs config-remote-sync"
sync_and_show_diff

title "The service principal deploys the synced config"
trace as-test-sp $CLI bundle deploy

title "The job's ACL after the deploy\n"
print_acl jobs $job_id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Badness = "Run by an identity other than the deployer, config-remote-sync leaves that identity's own CAN_MANAGE out of the permissions it imports (it assumes the syncing identity is the one that deploys), so the deployer's next deploy revokes it. The job declared no permissions, so before the sync that deploy left the ACL alone."
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bundle:
name: test-bundle-$UNIQUE_NAME

workspace:
root_path: /Workspace/Users/$TEST_SP_APPLICATION_ID/.bundle/test-bundle-$UNIQUE_NAME

resources:
jobs:
my_job:
name: test-job-$UNIQUE_NAME
permissions:
- level: CAN_VIEW
group_name: users
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Cloud = true
RunsOnDbr = false
GOOS.windows = false
CloudEnvs.azure = false
EnvMatrix.DMS = ["", "true"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

=== The service principal deploys a job that declares permissions

>>> as-test-sp [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[TEST_SP_APPLICATION_ID]/.bundle/test-bundle-[UNIQUE_NAME]/files...
Created jobs.my_job
Created jobs.my_job.permissions
Files: 2 uploaded, 0 deleted
Resources: 2 created, 0 changed, 0 deleted, 0 unchanged

=== The job's ACL after the deploy

CAN_VIEW users
IS_OWNER [TEST_SP_APPLICATION_ID]

=== The current identity runs config-remote-sync without any remote change

>>> [CLI] bundle config-remote-sync --save
Detected changes in 1 resource(s):

Resource: resources.jobs.my_job
permissions[service_principal_name='[TEST_SP_APPLICATION_ID]']: add



>>> diff.py databricks.yml.backup databricks.yml
--- databricks.yml.backup
+++ databricks.yml
@@ -12,2 +12,4 @@
- level: CAN_VIEW
group_name: users
+ - level: IS_OWNER
+ service_principal_name: [TEST_SP_APPLICATION_ID]

=== The current identity is granted CAN_MANAGE on the job, outside the bundle

CAN_MANAGE [USERNAME]
CAN_VIEW users
IS_OWNER [TEST_SP_APPLICATION_ID]

=== The current identity runs config-remote-sync

>>> [CLI] bundle config-remote-sync --save
No changes detected.


>>> diff.py databricks.yml.backup databricks.yml

=== The service principal deploys the synced config

>>> as-test-sp [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[TEST_SP_APPLICATION_ID]/.bundle/test-bundle-[UNIQUE_NAME]/files...
Updated jobs.my_job.permissions
Files: 1 uploaded, 0 deleted
Resources: 0 created, 1 changed, 0 deleted, 1 unchanged

=== The job's ACL after the deploy

CAN_VIEW users
IS_OWNER [TEST_SP_APPLICATION_ID]

>>> as-test-sp [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.jobs.my_job

All files and directories at the following location will be deleted: /Workspace/Users/[TEST_SP_APPLICATION_ID]/.bundle/test-bundle-[UNIQUE_NAME]

Destroy: 1 deleted
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
envsubst < databricks.yml.tmpl > databricks.yml

cleanup() {
trace as-test-sp $CLI bundle destroy --auto-approve
}
trap cleanup EXIT

title "The service principal deploys a job that declares permissions"
trace as-test-sp $CLI bundle deploy
job_id=$(as-test-sp $CLI bundle summary -o json | jq -r '.resources.jobs.my_job.id')

title "The job's ACL after the deploy\n"
print_acl jobs $job_id

title "The current identity runs config-remote-sync without any remote change"
sync_and_show_diff

title "The current identity is granted CAN_MANAGE on the job, outside the bundle\n"
$CLI permissions set jobs $job_id --json '{"access_control_list":[
{"permission_level":"IS_OWNER","service_principal_name":"'"$TEST_SP_APPLICATION_ID"'"},
{"permission_level":"CAN_MANAGE","'"$CURRENT_USER_FIELD"'":"'"$CURRENT_USER_NAME"'"},
{"permission_level":"CAN_VIEW","group_name":"users"}
]}' > /dev/null
print_acl jobs $job_id

title "The current identity runs config-remote-sync"
sync_and_show_diff

title "The service principal deploys the synced config"
trace as-test-sp $CLI bundle deploy

title "The job's ACL after the deploy\n"
print_acl jobs $job_id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Badness = "Run by an identity other than the deployer, config-remote-sync adds the deployer's IS_OWNER to the declared permissions although nobody changed the ACL. It also reports no change for a grant made to the syncing identity itself, so the deployer's next deploy revokes that grant (the revoke predates the permissions sync, which was meant to prevent it)."
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
bundle:
name: test-bundle-$UNIQUE_NAME

workspace:
root_path: /Workspace/Users/$TEST_SP_APPLICATION_ID/.bundle/test-bundle-$UNIQUE_NAME

resources:
experiments:
my_experiment:
name: /Users/$TEST_SP_APPLICATION_ID/test-experiment-$UNIQUE_NAME
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Cloud = true
RunsOnDbr = false
GOOS.windows = false
CloudEnvs.azure = false
EnvMatrix.DMS = ["", "true"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

=== The service principal deploys an experiment that declares no permissions

>>> as-test-sp [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[TEST_SP_APPLICATION_ID]/.bundle/test-bundle-[UNIQUE_NAME]/files...
Created experiments.my_experiment
Files: 2 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 0 unchanged

=== The current identity is granted CAN_MANAGE on the experiment, outside the bundle

CAN_MANAGE [TEST_SP_APPLICATION_ID]
CAN_MANAGE [USERNAME]

=== The current identity runs config-remote-sync

>>> [CLI] bundle config-remote-sync --save
Detected changes in 1 resource(s):

Resource: resources.experiments.my_experiment
permissions: add



>>> diff.py databricks.yml.backup databricks.yml
--- databricks.yml.backup
+++ databricks.yml
@@ -9,2 +9,5 @@
my_experiment:
name: /Users/[TEST_SP_APPLICATION_ID]/test-experiment-[UNIQUE_NAME]
+ permissions:
+ - level: CAN_MANAGE
+ service_principal_name: [TEST_SP_APPLICATION_ID]

=== The service principal deploys the synced config

>>> as-test-sp [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[TEST_SP_APPLICATION_ID]/.bundle/test-bundle-[UNIQUE_NAME]/files...
Created experiments.my_experiment.permissions
Files: 1 uploaded, 0 deleted
Resources: 1 created, 0 changed, 0 deleted, 1 unchanged

=== The experiment's ACL after the deploy

CAN_MANAGE [TEST_SP_APPLICATION_ID]

>>> as-test-sp [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.experiments.my_experiment

All files and directories at the following location will be deleted: /Workspace/Users/[TEST_SP_APPLICATION_ID]/.bundle/test-bundle-[UNIQUE_NAME]

Destroy: 1 deleted
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
envsubst < databricks.yml.tmpl > databricks.yml

cleanup() {
trace as-test-sp $CLI bundle destroy --auto-approve
}
trap cleanup EXIT

title "The service principal deploys an experiment that declares no permissions"
trace as-test-sp $CLI bundle deploy
experiment_id=$(as-test-sp $CLI bundle summary -o json | jq -r '.resources.experiments.my_experiment.id')

title "The current identity is granted CAN_MANAGE on the experiment, outside the bundle\n"
$CLI permissions set experiments $experiment_id --json '{"access_control_list":[
{"permission_level":"CAN_MANAGE","service_principal_name":"'"$TEST_SP_APPLICATION_ID"'"},
{"permission_level":"CAN_MANAGE","'"$CURRENT_USER_FIELD"'":"'"$CURRENT_USER_NAME"'"}
]}' > /dev/null
print_acl experiments $experiment_id

title "The current identity runs config-remote-sync"
sync_and_show_diff

title "The service principal deploys the synced config"
trace as-test-sp $CLI bundle deploy

title "The experiment's ACL after the deploy\n"
print_acl experiments $experiment_id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Badness = "Same as ../can_manage for a resource type without IS_OWNER: the syncing identity's own CAN_MANAGE is left out of the imported permissions, so the deployer's next deploy revokes it."
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
bundle:
name: test-bundle-$UNIQUE_NAME

workspace:
root_path: /Workspace/Users/$TEST_SP_APPLICATION_ID/.bundle/test-bundle-$UNIQUE_NAME

resources:
jobs:
my_job:
name: test-job-$UNIQUE_NAME
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Cloud = true
RunsOnDbr = false
GOOS.windows = false
CloudEnvs.azure = false
EnvMatrix.DMS = ["", "true"]
Loading
Loading