-
Notifications
You must be signed in to change notification settings - Fork 211
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
base: main
Are you sure you want to change the base?
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
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,8 @@ | ||
| bundle: | ||
| name: test_cluster_policy | ||
|
|
||
| resources: | ||
| cluster_policies: | ||
| test_cluster_policy: | ||
| name: my_cluster_policy | ||
| 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/test_cluster_policy/default | ||
|
|
||
| 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" | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: test_cluster_policy | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/test_cluster_policy/default | ||
| Resources: | ||
| Cluster Policies: | ||
| test_cluster_policy: | ||
| Name: my_cluster_policy | ||
| URL: (not deployed) | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test_cluster_policy/default/files... | ||
| Created cluster_policies.test_cluster_policy | ||
| Files: 4 uploaded, 0 deleted | ||
| Resources: 1 created, 0 changed, 0 deleted, 0 unchanged | ||
|
|
||
| === Verify the create request | ||
| >>> jq select(.method == "POST" and (.path | contains("/policies/clusters/create"))) out.requests.txt | ||
| { | ||
| "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" | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: test_cluster_policy | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/test_cluster_policy/default | ||
| Resources: | ||
| Cluster Policies: | ||
| test_cluster_policy: | ||
| Name: my_cluster_policy | ||
| URL: [DATABRICKS_URL]/compute/policies/[UUID]?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/test_cluster_policy/default/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 | ||
| >>> jq select(.method == "POST" and (.path | contains("/policies/clusters/edit"))) out.requests.txt | ||
| { | ||
| "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", | ||
| "policy_id": "[UUID]" | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: test_cluster_policy | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/test_cluster_policy/default | ||
| Resources: | ||
| Cluster Policies: | ||
| test_cluster_policy: | ||
| Name: my_cluster_policy_2 | ||
| URL: [DATABRICKS_URL]/compute/policies/[UUID]?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/test_cluster_policy/default | ||
|
|
||
| Destroy: 1 deleted | ||
|
|
||
| === Verify the destroy request | ||
| >>> jq select(.method == "POST" and (.path | contains("/policies/clusters/delete"))) out.requests.txt | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/policies/clusters/delete", | ||
| "body": { | ||
| "policy_id": "[UUID]" | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: test_cluster_policy | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/test_cluster_policy/default | ||
| Resources: | ||
| Cluster Policies: | ||
| test_cluster_policy: | ||
| Name: my_cluster_policy_2 | ||
| 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,33 @@ | ||
| 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 out.requests.txt | ||
| } | ||
| trap cleanup EXIT | ||
| trace $CLI bundle deploy | ||
|
|
||
| title "Verify the create request" | ||
| trace jq 'select(.method == "POST" and (.path | contains("/policies/clusters/create")))' out.requests.txt | ||
|
|
||
| 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 jq 'select(.method == "POST" and (.path | contains("/policies/clusters/edit")))' out.requests.txt | ||
|
|
||
| trace $CLI bundle summary | ||
|
|
||
| title "Destroy the cluster policy" | ||
| trace $CLI bundle destroy --auto-approve | ||
|
|
||
| title "Verify the destroy request" | ||
| trace jq 'select(.method == "POST" and (.path | contains("/policies/clusters/delete")))' out.requests.txt | ||
|
|
||
| trace $CLI bundle summary | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| bundle: | ||
| name: cluster_policy_definition_multiline | ||
|
|
||
| resources: | ||
| cluster_policies: | ||
| pol: | ||
| name: my_policy | ||
| 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,33 @@ | ||
|
|
||
| >>> [CLI] bundle validate -o json | ||
| { | ||
| "pol": { | ||
| "definition": "{\n \"spark_version\": {\n \"type\": \"fixed\",\n \"value\": \"13.3.x-scala2.12\"\n }\n}", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be interested to see if the backend normalises/formats this json |
||
| "name": "my_policy" | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/cluster_policy_definition_multiline/default/files... | ||
| Created cluster_policies.pol | ||
| Files: 4 uploaded, 0 deleted | ||
| Resources: 1 created, 0 changed, 0 deleted, 0 unchanged | ||
|
|
||
| === Create body preserves the block-scalar definition as a newline-escaped string | ||
| >>> print_requests.py //policies/clusters | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/policies/clusters/create", | ||
| "body": { | ||
| "definition": "{\n \"spark_version\": {\n \"type\": \"fixed\",\n \"value\": \"13.3.x-scala2.12\"\n }\n}", | ||
| "name": "my_policy" | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.cluster_policies.pol | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/cluster_policy_definition_multiline/default | ||
|
|
||
| Destroy: 1 deleted | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| trace $CLI bundle validate -o json | jq ".resources.cluster_policies" | ||
|
|
||
| trace $CLI bundle deploy | ||
|
|
||
| title "Create body preserves the block-scalar definition as a newline-escaped string" | ||
| trace print_requests.py //policies/clusters | ||
|
|
||
| trace $CLI bundle destroy --auto-approve | ||
| rm out.requests.txt |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| bundle: | ||
| name: cluster_policy_definition_yaml | ||
|
|
||
| resources: | ||
| cluster_policies: | ||
| pol: | ||
| name: my_policy | ||
| definition: | ||
|
Sankalp-Mittal marked this conversation as resolved.
|
||
| spark_version: | ||
| type: fixed | ||
| value: 13.3.x-scala2.12 | ||
| autotermination_minutes: | ||
| type: range | ||
| minValue: 10 | ||
| maxValue: 120 | ||
| enable_elastic_disk: | ||
| type: fixed | ||
| value: true | ||
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,33 @@ | ||
|
|
||
| >>> [CLI] bundle validate -o json | ||
| { | ||
| "pol": { | ||
| "definition": "{\"autotermination_minutes\":{\"maxValue\":120,\"minValue\":10,\"type\":\"range\"},\"enable_elastic_disk\":{\"type\":\"fixed\",\"value\":true},\"spark_version\":{\"type\":\"fixed\",\"value\":\"13.3.x-scala2.12\"}}", | ||
| "name": "my_policy" | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/cluster_policy_definition_yaml/default/files... | ||
| Created cluster_policies.pol | ||
| Files: 4 uploaded, 0 deleted | ||
| Resources: 1 created, 0 changed, 0 deleted, 0 unchanged | ||
|
|
||
| === Native YAML definition serializes to compact JSON, preserving numbers and booleans as JSON types (not quoted strings) | ||
| >>> print_requests.py //policies/clusters | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/policies/clusters/create", | ||
| "body": { | ||
| "definition": "{\"autotermination_minutes\":{\"maxValue\":120,\"minValue\":10,\"type\":\"range\"},\"enable_elastic_disk\":{\"type\":\"fixed\",\"value\":true},\"spark_version\":{\"type\":\"fixed\",\"value\":\"13.3.x-scala2.12\"}}", | ||
| "name": "my_policy" | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.cluster_policies.pol | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/cluster_policy_definition_yaml/default | ||
|
|
||
| Destroy: 1 deleted |
Uh oh!
There was an error while loading. Please reload this page.