-
Notifications
You must be signed in to change notification settings - Fork 216
Add Cluster Policy support to bundle resources #6225
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
Changes from all commits
292eac2
577efbf
44b2393
f5a668f
bc3de96
2202fd0
d0aeb0e
368fbb8
ddd5bdb
8bcb462
cd13a39
61405c8
77de13b
e9c9eb4
896f47e
1c6ae4d
01928b4
46bcd67
ee55a15
98576cd
3aac44d
ffdd6df
43698b5
671f0e2
e5280fd
be7ccb2
e9aa452
60ede9e
780cbb8
2df7f3c
bfacfa3
d9f0ca0
aef7b32
4330dde
71f4f5e
dc91553
082450e
4a20bf5
4f467bf
f9e5526
f968569
53ccee4
c1da779
3cc0cb9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add support for the `cluster_policies` resource type in Declarative Automation Bundles. Cluster policies are only supported in direct deployment mode. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| bundle: | ||
| name: test-bundle-$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| cluster_policies: | ||
| foo: | ||
| name: test-cluster-policy-$UNIQUE_NAME | ||
| definition: '{"spark_version":{"type":"fixed","value":"13.3.x-scala2.12"}}' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| bundle: | ||
| name: cluster_policy_backend_normalization | ||
|
|
||
| workspace: | ||
| root_path: ~/.bundle/$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| cluster_policies: | ||
| # Definition as a compact JSON string. | ||
| json_string: | ||
| name: probe_json_string-$UNIQUE_NAME | ||
| definition: '{"spark_version":{"type":"fixed","value":"13.3.x-scala2.12"}}' | ||
|
|
||
| # Definition as a multiline block-scalar JSON string. | ||
| multiline: | ||
| name: probe_multiline-$UNIQUE_NAME | ||
| definition: |- | ||
| { | ||
| "spark_version": { | ||
| "type": "fixed", | ||
| "value": "13.3.x-scala2.12" | ||
| } | ||
| } | ||
|
|
||
| # Definition as native YAML (normalized to compact JSON by the mutator before deploy). | ||
| yaml: | ||
| name: probe_yaml-$UNIQUE_NAME | ||
| definition: | ||
| spark_version: | ||
| type: fixed | ||
| value: 13.3.x-scala2.12 | ||
| autotermination_minutes: | ||
| type: range | ||
| maxValue: 120 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... | ||
| Created cluster_policies.json_string | ||
| Created cluster_policies.multiline | ||
| Created cluster_policies.yaml | ||
| Files: 5 uploaded, 0 deleted | ||
| Resources: 3 created, 0 changed, 0 deleted, 0 unchanged | ||
|
|
||
| === [json_string] definition returned by the backend (GET) | ||
| >>> [CLI] cluster-policies get [JSON_STRING_ID] -o json | ||
| {"spark_version":{"type":"fixed","value":"13.3.x-scala2.12"}} | ||
|
|
||
| === [multiline] definition returned by the backend (GET) | ||
| >>> [CLI] cluster-policies get [MULTILINE_ID] -o json | ||
| { | ||
| "spark_version": { | ||
| "type": "fixed", | ||
| "value": "13.3.x-scala2.12" | ||
| } | ||
| } | ||
|
|
||
| === [yaml] definition returned by the backend (GET) | ||
| >>> [CLI] cluster-policies get [YAML_ID] -o json | ||
| {"autotermination_minutes":{"maxValue":120,"type":"range"},"spark_version":{"type":"fixed","value":"13.3.x-scala2.12"}} | ||
|
|
||
| === Plan after deploy: any drift means the backend reformatted a definition | ||
| >>> [CLI] bundle plan | ||
| Plan: 0 to add, 0 to change, 0 to delete, 3 unchanged | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.cluster_policies.json_string | ||
| delete resources.cluster_policies.multiline | ||
| delete resources.cluster_policies.yaml | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME] | ||
|
|
||
| Destroy: 3 deleted |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| trace $CLI bundle deploy | ||
|
|
||
| # For each authoring style, print the definition string the backend returns on GET. | ||
| # Compare it against what we sent to see whether the backend reformats the JSON. | ||
| for name in json_string multiline yaml; do | ||
| pol_id=$(read_id.py "$name") | ||
| title "[$name] definition returned by the backend (GET)" | ||
| trace $CLI cluster-policies get "$pol_id" -o json | jq -r '.definition' | ||
| done | ||
|
|
||
| # yaml is normalized to compact JSON by the mutator, matching the string the backend | ||
| # stores and returns, so it does not drift (plan below is a no-op). | ||
| title "Plan after deploy: any drift means the backend reformatted a definition" | ||
| trace $CLI bundle plan |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| RecordRequests = false | ||
| EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] | ||
| Ignore = [ | ||
| ".databricks", | ||
| "databricks.yml", | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| bundle: | ||
| name: test_cluster_policy | ||
|
|
||
| workspace: | ||
| root_path: ~/.bundle/$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| cluster_policies: | ||
| test_cluster_policy: | ||
| name: my_cluster_policy-$UNIQUE_NAME | ||
| definition: '{"spark_version":{"type":"fixed","value":"13.3.x-scala2.12"}}' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
|
|
||
| >>> [CLI] bundle validate | ||
| Name: test_cluster_policy | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME] | ||
|
|
||
| Validation OK! | ||
|
|
||
| >>> [CLI] bundle validate -o json | ||
| { | ||
| "test_cluster_policy": { | ||
| "definition": "{\"spark_version\":{\"type\":\"fixed\",\"value\":\"13.3.x-scala2.12\"}}", | ||
| "name": "my_cluster_policy-[UNIQUE_NAME]" | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: test_cluster_policy | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME] | ||
| Resources: | ||
| Cluster Policies: | ||
| test_cluster_policy: | ||
| Name: my_cluster_policy-[UNIQUE_NAME] | ||
| URL: (not deployed) | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... | ||
| Created cluster_policies.test_cluster_policy | ||
| Files: 5 uploaded, 0 deleted | ||
| Resources: 1 created, 0 changed, 0 deleted, 0 unchanged | ||
|
|
||
| === Verify the create request | ||
| >>> print_requests.py //policies/clusters/create | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/policies/clusters/create", | ||
| "body": { | ||
| "definition": "{\"spark_version\":{\"type\":\"fixed\",\"value\":\"13.3.x-scala2.12\"}}", | ||
| "name": "my_cluster_policy-[UNIQUE_NAME]" | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: test_cluster_policy | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME] | ||
| Resources: | ||
| Cluster Policies: | ||
| test_cluster_policy: | ||
| Name: my_cluster_policy-[UNIQUE_NAME] | ||
| URL: [DATABRICKS_URL]/compute/policies/[TEST_CLUSTER_POLICY_ID]?w=[NUMID] | ||
|
|
||
| === Update the cluster policy name | ||
| >>> update_file.py databricks.yml my_cluster_policy my_cluster_policy_2 | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... | ||
| Updated cluster_policies.test_cluster_policy | ||
| Files: 3 uploaded, 0 deleted | ||
| Resources: 0 created, 1 changed, 0 deleted, 0 unchanged | ||
|
|
||
| === Verify the update request | ||
| >>> print_requests.py //policies/clusters/edit | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/policies/clusters/edit", | ||
| "body": { | ||
| "definition": "{\"spark_version\":{\"type\":\"fixed\",\"value\":\"13.3.x-scala2.12\"}}", | ||
| "name": "my_cluster_policy_2-[UNIQUE_NAME]", | ||
| "policy_id": "[TEST_CLUSTER_POLICY_ID]" | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: test_cluster_policy | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME] | ||
| Resources: | ||
| Cluster Policies: | ||
| test_cluster_policy: | ||
| Name: my_cluster_policy_2-[UNIQUE_NAME] | ||
| URL: [DATABRICKS_URL]/compute/policies/[TEST_CLUSTER_POLICY_ID]?w=[NUMID] | ||
|
|
||
| === Destroy the cluster policy | ||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.cluster_policies.test_cluster_policy | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME] | ||
|
|
||
| Destroy: 1 deleted | ||
|
|
||
| === Verify the destroy request | ||
| >>> print_requests.py //policies/clusters/delete | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/policies/clusters/delete", | ||
| "body": { | ||
| "policy_id": "[TEST_CLUSTER_POLICY_ID]" | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: test_cluster_policy | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME] | ||
| Resources: | ||
| Cluster Policies: | ||
| test_cluster_policy: | ||
| Name: my_cluster_policy_2-[UNIQUE_NAME] | ||
| URL: (not deployed) | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| No active deployment found to destroy! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| trace $CLI bundle validate | ||
| trace $CLI bundle validate -o json | jq ".resources.cluster_policies" | ||
|
|
||
| trace $CLI bundle summary | ||
|
|
||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| rm -f out.requests.txt | ||
| } | ||
| trap cleanup EXIT | ||
| trace $CLI bundle deploy | ||
|
|
||
| # Mask the server-assigned policy id: the real backend returns a hex id that the | ||
| # built-in UUID replacement misses, so register it explicitly for cloud parity. | ||
| read_id.py test_cluster_policy > /dev/null | ||
|
|
||
| title "Verify the create request" | ||
| trace print_requests.py //policies/clusters/create | ||
|
|
||
| trace $CLI bundle summary | ||
|
|
||
| title "Update the cluster policy name" | ||
| trace update_file.py databricks.yml my_cluster_policy my_cluster_policy_2 | ||
| trace $CLI bundle deploy | ||
|
|
||
| title "Verify the update request" | ||
| trace print_requests.py //policies/clusters/edit | ||
|
|
||
| trace $CLI bundle summary | ||
|
|
||
| title "Destroy the cluster policy" | ||
| trace $CLI bundle destroy --auto-approve | ||
|
|
||
| title "Verify the destroy request" | ||
| trace print_requests.py //policies/clusters/delete | ||
|
|
||
| trace $CLI bundle summary | ||
Uh oh!
There was an error while loading. Please reload this page.