Add a test showing bug in merge if variables are used for keys (#2101)

Since merge happens first, before variable resolution, the two jobs are
seen as different.

I also updated override/job_cluster/script to include more of the
output.
This commit is contained in:
Denis Bilenko 2025-01-09 11:14:47 +01:00 committed by GitHub
parent b808d4d6f1
commit 2a4fdd911e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 173 additions and 22 deletions

View File

@ -1,7 +1,13 @@
>>> $CLI bundle validate -o json -t development >>> $CLI bundle validate -o json -t development
{ {
"name": "job", "foo": {
"deployment": {
"kind": "BUNDLE",
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/override_job_cluster/development/state/metadata.json"
},
"edit_mode": "UI_LOCKED",
"format": "MULTI_TASK",
"job_clusters": [ "job_clusters": [
{ {
"job_cluster_key": "key", "job_cluster_key": "key",
@ -11,12 +17,25 @@
"spark_version": "13.3.x-scala2.12" "spark_version": "13.3.x-scala2.12"
} }
} }
] ],
"name": "job",
"permissions": [],
"queue": {
"enabled": true
},
"tags": {}
}
} }
>>> $CLI bundle validate -o json -t staging >>> $CLI bundle validate -o json -t staging
{ {
"name": "job", "foo": {
"deployment": {
"kind": "BUNDLE",
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/override_job_cluster/staging/state/metadata.json"
},
"edit_mode": "UI_LOCKED",
"format": "MULTI_TASK",
"job_clusters": [ "job_clusters": [
{ {
"job_cluster_key": "key", "job_cluster_key": "key",
@ -26,5 +45,12 @@
"spark_version": "13.3.x-scala2.12" "spark_version": "13.3.x-scala2.12"
} }
} }
] ],
"name": "job",
"permissions": [],
"queue": {
"enabled": true
},
"tags": {}
}
} }

View File

@ -1,2 +1,2 @@
trace $CLI bundle validate -o json -t development | jq '.resources.jobs.foo | {name,job_clusters}' trace $CLI bundle validate -o json -t development | jq '.resources.jobs'
trace $CLI bundle validate -o json -t staging | jq '.resources.jobs.foo | {name,job_clusters}' trace $CLI bundle validate -o json -t staging | jq '.resources.jobs'

View File

@ -0,0 +1,37 @@
bundle:
name: override_job_cluster
variables:
mykey:
default: key
resources:
jobs:
foo:
name: job
job_clusters:
- job_cluster_key: key
new_cluster:
spark_version: 13.3.x-scala2.12
targets:
development:
resources:
jobs:
foo:
job_clusters:
# This does not work because merging is done before resolution
- job_cluster_key: "${var.mykey}"
new_cluster:
node_type_id: i3.xlarge
num_workers: 1
staging:
resources:
jobs:
foo:
job_clusters:
- job_cluster_key: "${var.mykey}"
new_cluster:
node_type_id: i3.2xlarge
num_workers: 4

View File

@ -0,0 +1,84 @@
>>> $CLI bundle validate -o json -t development
{
"foo": {
"deployment": {
"kind": "BUNDLE",
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/override_job_cluster/development/state/metadata.json"
},
"edit_mode": "UI_LOCKED",
"format": "MULTI_TASK",
"job_clusters": [
{
"job_cluster_key": "key",
"new_cluster": {
"spark_version": "13.3.x-scala2.12"
}
},
{
"job_cluster_key": "key",
"new_cluster": {
"node_type_id": "i3.xlarge",
"num_workers": 1
}
}
],
"name": "job",
"permissions": [],
"queue": {
"enabled": true
},
"tags": {}
}
}
>>> $CLI bundle validate -t development
Name: override_job_cluster
Target: development
Workspace:
User: tester@databricks.com
Path: /Workspace/Users/tester@databricks.com/.bundle/override_job_cluster/development
Validation OK!
>>> $CLI bundle validate -o json -t staging
{
"foo": {
"deployment": {
"kind": "BUNDLE",
"metadata_file_path": "/Workspace/Users/tester@databricks.com/.bundle/override_job_cluster/staging/state/metadata.json"
},
"edit_mode": "UI_LOCKED",
"format": "MULTI_TASK",
"job_clusters": [
{
"job_cluster_key": "key",
"new_cluster": {
"spark_version": "13.3.x-scala2.12"
}
},
{
"job_cluster_key": "key",
"new_cluster": {
"node_type_id": "i3.2xlarge",
"num_workers": 4
}
}
],
"name": "job",
"permissions": [],
"queue": {
"enabled": true
},
"tags": {}
}
}
>>> $CLI bundle validate -t staging
Name: override_job_cluster
Target: staging
Workspace:
User: tester@databricks.com
Path: /Workspace/Users/tester@databricks.com/.bundle/override_job_cluster/staging
Validation OK!

View File

@ -0,0 +1,4 @@
trace $CLI bundle validate -o json -t development | jq '.resources.jobs'
trace $CLI bundle validate -t development
trace $CLI bundle validate -o json -t staging | jq '.resources.jobs'
trace $CLI bundle validate -t staging