Skip to content

Commit 527f6d2

Browse files
committed
Add defaults on jobs that terraform applies
1 parent 95b7139 commit 527f6d2

File tree

21 files changed

+73
-10
lines changed

21 files changed

+73
-10
lines changed

acceptance/bundle/includes/yml_outside_root/output.txt

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Validation OK!
1616
},
1717
"edit_mode": "UI_LOCKED",
1818
"format": "MULTI_TASK",
19+
"max_concurrent_runs": 1,
1920
"name": "include_outside_root",
2021
"permissions": [],
2122
"queue": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export PYTHONDONTWRITEBYTECODE=1
2+
3+
uv venv -q .venv
4+
venv_activate
5+
uv pip install -q setuptools

acceptance/bundle/override/job_cluster/output.txt

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
}
1919
}
2020
],
21+
"max_concurrent_runs": 1,
2122
"name": "job",
2223
"permissions": [],
2324
"queue": {
@@ -45,6 +46,7 @@
4546
}
4647
}
4748
],
49+
"max_concurrent_runs": 1,
4850
"name": "job",
4951
"permissions": [],
5052
"queue": {

acceptance/bundle/override/job_cluster_var/output.txt

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
}
1919
}
2020
],
21+
"max_concurrent_runs": 1,
2122
"name": "job",
2223
"permissions": [],
2324
"queue": {
@@ -54,6 +55,7 @@ Validation OK!
5455
}
5556
}
5657
],
58+
"max_concurrent_runs": 1,
5759
"name": "job",
5860
"permissions": [],
5961
"queue": {

acceptance/bundle/override/job_tasks/output.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"max_concurrent_runs": 1,
23
"name": "job",
34
"permissions": [],
45
"queue": {
@@ -34,6 +35,7 @@ Error: file test1.py not found
3435

3536
Exit code: 1
3637
{
38+
"max_concurrent_runs": 1,
3739
"name": "job",
3840
"permissions": [],
3941
"queue": {

acceptance/bundle/paths/git_source_jobs/output.txt

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"git_provider": "gitHub",
1414
"git_url": "https://github.com/foo"
1515
},
16+
"max_concurrent_runs": 1,
1617
"name": "my_job",
1718
"permissions": [],
1819
"queue": {

acceptance/bundle/paths/relative_path_outside_root/output.txt

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"edit_mode": "UI_LOCKED",
1212
"format": "MULTI_TASK",
13+
"max_concurrent_runs": 1,
1314
"name": "include_outside_root",
1415
"permissions": [],
1516
"queue": {

acceptance/bundle/python/mutator-ordering/output.txt

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
},
1919
"edit_mode": "UI_LOCKED",
2020
"format": "MULTI_TASK",
21+
"max_concurrent_runs": 1,
22+
"name": "Untitled",
2123
"permissions": [],
2224
"queue": {
2325
"enabled": true

acceptance/bundle/python/resolve-variable/output.txt

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
},
1818
"edit_mode": "UI_LOCKED",
1919
"format": "MULTI_TASK",
20+
"max_concurrent_runs": 1,
2021
"name": "abc",
2122
"permissions": [],
2223
"queue": {

acceptance/bundle/python/resource-loading/output.txt

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
},
1919
"edit_mode": "UI_LOCKED",
2020
"format": "MULTI_TASK",
21+
"max_concurrent_runs": 1,
2122
"name": "Job 1",
2223
"permissions": [],
2324
"queue": {
@@ -31,6 +32,7 @@
3132
},
3233
"edit_mode": "UI_LOCKED",
3334
"format": "MULTI_TASK",
35+
"max_concurrent_runs": 1,
3436
"name": "Job 2",
3537
"permissions": [],
3638
"queue": {
@@ -44,6 +46,7 @@
4446
},
4547
"edit_mode": "UI_LOCKED",
4648
"format": "MULTI_TASK",
49+
"max_concurrent_runs": 1,
4750
"name": "Job 3",
4851
"permissions": [],
4952
"queue": {

acceptance/bundle/templates/default-python/integration_classic/output.txt

+14-10
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,12 @@ Validation OK!
168168
+ "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/prod/state/metadata.json"
169169
},
170170
"edit_mode": "UI_LOCKED",
171-
@@ -59,12 +51,8 @@
171+
@@ -59,12 +51,9 @@
172172
}
173173
],
174174
- "max_concurrent_runs": 4,
175175
- "name": "[dev [USERNAME]] project_name_[UNIQUE_NAME]_job",
176+
+ "max_concurrent_runs": 1,
176177
+ "name": "project_name_[UNIQUE_NAME]_job",
177178
"permissions": [],
178179
"queue": {
@@ -182,20 +183,21 @@ Validation OK!
182183
- "dev": "[USERNAME]"
183184
},
184185
"tasks": [
185-
@@ -72,5 +60,5 @@
186+
@@ -72,5 +61,5 @@
186187
"job_cluster_key": "job_cluster",
187188
"notebook_task": {
188189
- "notebook_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/files/src/notebook"
189190
+ "notebook_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/prod/files/src/notebook"
190191
},
191192
"task_key": "notebook_task"
192-
@@ -107,5 +95,4 @@
193+
@@ -107,5 +96,5 @@
193194
],
194195
"trigger": {
195196
- "pause_status": "PAUSED",
197+
+ "pause_status": "UNPAUSED",
196198
"periodic": {
197199
"interval": 1,
198-
@@ -118,21 +105,20 @@
200+
@@ -118,21 +107,20 @@
199201
"project_name_[UNIQUE_NAME]_pipeline": {
200202
"configuration": {
201203
- "bundle.sourcePath": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/files/src"
@@ -222,7 +224,7 @@ Validation OK!
222224
+ "schema": "project_name_[UNIQUE_NAME]_prod"
223225
}
224226
}
225-
@@ -145,10 +131,10 @@
227+
@@ -145,10 +133,10 @@
226228
"targets": null,
227229
"workspace": {
228230
- "artifact_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/artifacts",
@@ -317,11 +319,12 @@ Resources:
317319
+ "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/prod/state/metadata.json"
318320
},
319321
"edit_mode": "UI_LOCKED",
320-
@@ -60,11 +56,7 @@
322+
@@ -60,11 +56,8 @@
321323
}
322324
],
323325
- "max_concurrent_runs": 4,
324326
- "name": "[dev [USERNAME]] project_name_[UNIQUE_NAME]_job",
327+
+ "max_concurrent_runs": 1,
325328
+ "name": "project_name_[UNIQUE_NAME]_job",
326329
"queue": {
327330
"enabled": true
@@ -330,20 +333,21 @@ Resources:
330333
- "dev": "[USERNAME]"
331334
},
332335
"tasks": [
333-
@@ -72,5 +64,5 @@
336+
@@ -72,5 +65,5 @@
334337
"job_cluster_key": "job_cluster",
335338
"notebook_task": {
336339
- "notebook_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/files/src/notebook"
337340
+ "notebook_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/prod/files/src/notebook"
338341
},
339342
"task_key": "notebook_task"
340-
@@ -107,5 +99,4 @@
343+
@@ -107,5 +100,5 @@
341344
],
342345
"trigger": {
343346
- "pause_status": "PAUSED",
347+
+ "pause_status": "UNPAUSED",
344348
"periodic": {
345349
"interval": 1,
346-
@@ -119,21 +110,20 @@
350+
@@ -119,21 +112,20 @@
347351
"project_name_[UNIQUE_NAME]_pipeline": {
348352
"configuration": {
349353
- "bundle.sourcePath": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/files/src"
@@ -370,7 +374,7 @@ Resources:
370374
+ "schema": "project_name_[UNIQUE_NAME]_prod",
371375
"url": "[DATABRICKS_URL]/pipelines/[UUID]"
372376
}
373-
@@ -146,10 +136,10 @@
377+
@@ -146,10 +138,10 @@
374378
},
375379
"workspace": {
376380
- "artifact_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/artifacts",

acceptance/bundle/validate/empty_resources/empty_dict/output.txt

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
},
1010
"edit_mode": "UI_LOCKED",
1111
"format": "MULTI_TASK",
12+
"max_concurrent_runs": 1,
13+
"name": "Untitled",
1214
"permissions": [],
1315
"queue": {
1416
"enabled": true

acceptance/bundle/validate/empty_resources/with_grants/output.txt

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Warning: unknown field: grants
1313
},
1414
"edit_mode": "UI_LOCKED",
1515
"format": "MULTI_TASK",
16+
"max_concurrent_runs": 1,
17+
"name": "Untitled",
1618
"permissions": [],
1719
"queue": {
1820
"enabled": true

acceptance/bundle/validate/empty_resources/with_permissions/output.txt

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
},
1010
"edit_mode": "UI_LOCKED",
1111
"format": "MULTI_TASK",
12+
"max_concurrent_runs": 1,
13+
"name": "Untitled",
1214
"permissions": [],
1315
"queue": {
1416
"enabled": true

acceptance/bundle/validate/presets_name_prefix/output.txt

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"edit_mode": "UI_LOCKED",
1414
"format": "MULTI_TASK",
15+
"max_concurrent_runs": 1,
1516
"name": "prefix-job1",
1617
"permissions": [],
1718
"queue": {
@@ -47,6 +48,7 @@
4748
},
4849
"edit_mode": "UI_LOCKED",
4950
"format": "MULTI_TASK",
51+
"max_concurrent_runs": 1,
5052
"name": "[prefix]job1",
5153
"permissions": [],
5254
"queue": {
@@ -82,6 +84,7 @@
8284
},
8385
"edit_mode": "UI_LOCKED",
8486
"format": "MULTI_TASK",
87+
"max_concurrent_runs": 1,
8588
"name": "job1",
8689
"permissions": [],
8790
"queue": {

acceptance/bundle/variables/complex/out.default.json

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
}
2525
}
2626
],
27+
"max_concurrent_runs": 1,
28+
"name": "Untitled",
2729
"permissions": [],
2830
"queue": {
2931
"enabled": true

acceptance/bundle/variables/complex/out.dev.json

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
}
2323
}
2424
],
25+
"max_concurrent_runs": 1,
26+
"name": "Untitled",
2527
"permissions": [],
2628
"queue": {
2729
"enabled": true

acceptance/bundle/variables/complex_multiple_files/output.txt

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
}
5959
}
6060
],
61+
"max_concurrent_runs": 1,
62+
"name": "Untitled",
6163
"permissions": [],
6264
"queue": {
6365
"enabled": true

acceptance/bundle/variables/prepend-workspace-var/output.txt

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
},
2020
"edit_mode": "UI_LOCKED",
2121
"format": "MULTI_TASK",
22+
"max_concurrent_runs": 1,
23+
"name": "Untitled",
2224
"permissions": [],
2325
"queue": {
2426
"enabled": true

acceptance/bundle/variables/resolve-nonstrings/output.txt

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
},
2525
"edit_mode": "UI_LOCKED",
2626
"format": "MULTI_TASK",
27+
"max_concurrent_runs": 1,
28+
"name": "Untitled",
2729
"notification_settings": {
2830
"no_alert_for_canceled_runs": true,
2931
"no_alert_for_skipped_runs": false

bundle/config/mutator/resourcemutator/resource_mutator.go

+20
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@ func applyInitializeMutators(ctx context.Context, b *bundle.Bundle) diag.Diagnos
5151
{"resources.dashboards.*.parent_path", b.Config.Workspace.ResourcePath},
5252
{"resources.dashboards.*.embed_credentials", false},
5353
{"resources.volumes.*.volume_type", "MANAGED"},
54+
55+
// Jobs:
56+
57+
// The defaults are the same as for terraform provider latest version (v1.75.0)
58+
// https://github.com/databricks/terraform-provider-databricks/blob/v1.75.0/jobs/resource_job.go#L532
59+
{"resources.jobs.*.name", "Untitled"},
60+
{"resources.jobs.*.max_concurrent_runs", 1},
61+
{"resources.jobs.*.schedule.pause_status", "UNPAUSED"},
62+
{"resources.jobs.*.trigger.pause_status", "UNPAUSED"},
63+
{"resources.jobs.*.continuous.pause_status", "UNPAUSED"},
64+
65+
// This is converted from single-task to multi-task
66+
{"resources.jobs.*.task[*].dbt_task.schema", "default"},
67+
{"resources.jobs.*.task[*].for_each_task.task.dbt_task.schema", "default"},
68+
69+
// https://github.com/databricks/terraform-provider-databricks/blob/v1.75.0/clusters/resource_cluster.go
70+
// This triggers SingleNodeCluster() cluster validator. It needs to be run before applying defaults.
71+
//{"resources.jobs.*.job_clusters[*].new_cluster.num_workers", 0},
72+
{"resources.jobs.*.job_clusters[*].new_cluster.workload_type.clients.notebooks", true},
73+
{"resources.jobs.*.job_clusters[*].new_cluster.workload_type.clients.jobs", true},
5474
}
5575

5676
for _, defaultDef := range defaults {

0 commit comments

Comments
 (0)