From 428e730c9eb87b687436223a7c7d27cecbd972f1 Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Wed, 26 Feb 2025 13:19:38 +0100 Subject: [PATCH] Set default data_security_mode to "SINGLE_USER" in bundle templates (#2372) ## Changes 1. Change the **default-python** bundle template to set `data_security_mode` of a cluster to SINGLE_USER 2. Change the **experimental-jobs-as-code** bundle template to set `data_security_mode` of a cluster to SINGLE_USER ## Why Explicitly adding this field saves experienced users from confusion onto what security mode is applied to the cluster ## Tests Changed existing unit and integration tests to pass with this change --- .../output/my_default_python/resources/my_default_python.job.yml | 1 + acceptance/bundle/templates/experimental-jobs-as-code/output.txt | 1 + .../output/my_jobs_as_code/resources/my_jobs_as_code_job.py | 1 + integration/bundle/testdata/default_python/bundle_summary.txt | 1 + .../{{.project_name}}/resources/{{.project_name}}.job.yml.tmpl | 1 + .../{{.project_name}}/resources/{{.project_name}}_job.py.tmpl | 1 + 6 files changed, 6 insertions(+) diff --git a/acceptance/bundle/templates/default-python/output/my_default_python/resources/my_default_python.job.yml b/acceptance/bundle/templates/default-python/output/my_default_python/resources/my_default_python.job.yml index d9e31691a..7c11e143f 100644 --- a/acceptance/bundle/templates/default-python/output/my_default_python/resources/my_default_python.job.yml +++ b/acceptance/bundle/templates/default-python/output/my_default_python/resources/my_default_python.job.yml @@ -44,6 +44,7 @@ resources: new_cluster: spark_version: 15.4.x-scala2.12 node_type_id: i3.xlarge + data_security_mode: SINGLE_USER autoscale: min_workers: 1 max_workers: 4 diff --git a/acceptance/bundle/templates/experimental-jobs-as-code/output.txt b/acceptance/bundle/templates/experimental-jobs-as-code/output.txt index 984dad604..2099dd498 100644 --- a/acceptance/bundle/templates/experimental-jobs-as-code/output.txt +++ b/acceptance/bundle/templates/experimental-jobs-as-code/output.txt @@ -34,6 +34,7 @@ Warning: Ignoring Databricks CLI version constraint for development build. Requi "max_workers": 4, "min_workers": 1 }, + "data_security_mode": "SINGLE_USER", "node_type_id": "i3.xlarge", "spark_version": "15.4.x-scala2.12" } diff --git a/acceptance/bundle/templates/experimental-jobs-as-code/output/my_jobs_as_code/resources/my_jobs_as_code_job.py b/acceptance/bundle/templates/experimental-jobs-as-code/output/my_jobs_as_code/resources/my_jobs_as_code_job.py index e8406fd7b..be7254b80 100644 --- a/acceptance/bundle/templates/experimental-jobs-as-code/output/my_jobs_as_code/resources/my_jobs_as_code_job.py +++ b/acceptance/bundle/templates/experimental-jobs-as-code/output/my_jobs_as_code/resources/my_jobs_as_code_job.py @@ -56,6 +56,7 @@ my_jobs_as_code_job = Job.from_dict( "new_cluster": { "spark_version": "15.4.x-scala2.12", "node_type_id": "i3.xlarge", + "data_security_mode": "SINGLE_USER", "autoscale": { "min_workers": 1, "max_workers": 4, diff --git a/integration/bundle/testdata/default_python/bundle_summary.txt b/integration/bundle/testdata/default_python/bundle_summary.txt index 450f01c46..968009759 100644 --- a/integration/bundle/testdata/default_python/bundle_summary.txt +++ b/integration/bundle/testdata/default_python/bundle_summary.txt @@ -82,6 +82,7 @@ "max_workers": 4, "min_workers": 1 }, + "data_security_mode": "SINGLE_USER", "node_type_id": "i3.xlarge", "spark_version": "15.4.x-scala2.12" } diff --git a/libs/template/templates/default-python/template/{{.project_name}}/resources/{{.project_name}}.job.yml.tmpl b/libs/template/templates/default-python/template/{{.project_name}}/resources/{{.project_name}}.job.yml.tmpl index 5211e3894..735a232be 100644 --- a/libs/template/templates/default-python/template/{{.project_name}}/resources/{{.project_name}}.job.yml.tmpl +++ b/libs/template/templates/default-python/template/{{.project_name}}/resources/{{.project_name}}.job.yml.tmpl @@ -69,6 +69,7 @@ resources: new_cluster: spark_version: {{template "latest_lts_dbr_version"}} node_type_id: {{smallest_node_type}} + data_security_mode: SINGLE_USER autoscale: min_workers: 1 max_workers: 4 diff --git a/libs/template/templates/experimental-jobs-as-code/template/{{.project_name}}/resources/{{.project_name}}_job.py.tmpl b/libs/template/templates/experimental-jobs-as-code/template/{{.project_name}}/resources/{{.project_name}}_job.py.tmpl index 7c7a0d33f..d9d248799 100644 --- a/libs/template/templates/experimental-jobs-as-code/template/{{.project_name}}/resources/{{.project_name}}_job.py.tmpl +++ b/libs/template/templates/experimental-jobs-as-code/template/{{.project_name}}/resources/{{.project_name}}_job.py.tmpl @@ -97,6 +97,7 @@ This job runs {{.project_name}}_pipeline on a schedule. "new_cluster": { "spark_version": "{{template "latest_lts_dbr_version"}}", "node_type_id": "{{smallest_node_type}}", + "data_security_mode": "SINGLE_USER", "autoscale": { "min_workers": 1, "max_workers": 4,