Skip to content

Commit b085615

Browse files
authored
[Databricks DJM install] Use job name in resource id (#45570)
### What does this PR do? ### Motivation ### Describe how you validated your changes ### Additional Notes Co-authored-by: adrien.boitreaud <[email protected]>
1 parent ea4045b commit b085615

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pkg/fleet/installer/setup/djm/databricks.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,11 @@ func setupCommonHostTags(s *common.Setup) {
227227
setClearIfExists(s, "DB_IS_JOB_CLUSTER", "databricks_is_job_cluster", nil)
228228
setClearIfExists(s, "DATABRICKS_RUNTIME_VERSION", "databricks_runtime", nil)
229229
setClearIfExists(s, "SPARK_SCALA_VERSION", "scala_version", nil)
230-
setIfExists(s, "DD_JOB_NAME", "job_name", func(v string) string {
231-
return jobNameRegex.ReplaceAllString(v, "_")
232-
})
230+
var sanitizedJobName string
231+
if jobName, ok := os.LookupEnv("DD_JOB_NAME"); ok {
232+
sanitizedJobName = jobNameRegex.ReplaceAllString(jobName, "_")
233+
setHostTag(s, "job_name", sanitizedJobName)
234+
}
233235

234236
// duplicated for backward compatibility
235237
setIfExists(s, "DB_CLUSTER_NAME", "databricks_cluster_name", func(v string) string {
@@ -255,7 +257,11 @@ func setupCommonHostTags(s *common.Setup) {
255257
if ok {
256258
setHostTag(s, "jobid", jobID)
257259
setHostTag(s, "runid", runID)
258-
setHostTag(s, "dd.internal.resource:databricks_job", prefixWithWorkspace(normalizedWorkspace, jobID))
260+
if sanitizedJobName != "" {
261+
setHostTag(s, "dd.internal.resource:databricks_job", prefixWithWorkspace(normalizedWorkspace, sanitizedJobName))
262+
} else {
263+
setHostTag(s, "dd.internal.resource:databricks_job", prefixWithWorkspace(normalizedWorkspace, jobID))
264+
}
259265
}
260266
setHostTag(s, "data_workload_monitoring_trial", "true")
261267

0 commit comments

Comments
 (0)