Improve messages

This commit is contained in:
Gleb Kanterov 2024-09-24 15:55:32 +02:00
parent d7da8f146e
commit d3032c493c
No known key found for this signature in database
GPG Key ID: 4D87C640DBD00176
2 changed files with 7 additions and 5 deletions

View File

@ -83,7 +83,7 @@ func validateJobTask(rb bundle.ReadOnlyBundle, task jobs.Task, taskPath dyn.Path
// notebook tasks without cluster spec will use notebook environment
} else {
// path might be not very helpful, adding user-specified task key clarifies the context
detail := fmt.Sprintf("Task %q has a task type that requires a cluster, but no cluster is specified", task.TaskKey)
detail := fmt.Sprintf("Task %q has a task type that requires a cluster or environment, but neither is specified", task.TaskKey)
diags = diags.Append(diag.Diagnostic{
Severity: diag.Error,
@ -98,13 +98,15 @@ func validateJobTask(rb bundle.ReadOnlyBundle, task jobs.Task, taskPath dyn.Path
return diags
}
// isComputeTask returns true if the task requires a cluster
// isComputeTask returns true if the task runs on a cluster or serverless GC
func isComputeTask(task jobs.Task) bool {
if task.NotebookTask != nil {
// if warehouse_id is set, it's SQL notebook that doesn't need cluster
// if warehouse_id is set, it's SQL notebook that doesn't need cluster or serverless GC
if task.NotebookTask.WarehouseId != "" {
return false
} else {
// task settings don't require specifying a cluster/serverless GC, but task itself can run on one
// we handle that case separately in validateJobTask
return true
}
}

View File

@ -144,7 +144,7 @@ func TestJobTaskClusterSpec(t *testing.T) {
TaskKey: "my_task",
},
errorPath: "resources.jobs.job1.tasks[0]",
errorDetail: "Task \"my_task\" has a task type that requires a cluster, but no cluster is specified",
errorDetail: "Task \"my_task\" has a task type that requires a cluster or environment, but neither is specified",
errorSummary: expectedSummary,
},
{
@ -158,7 +158,7 @@ func TestJobTaskClusterSpec(t *testing.T) {
},
},
errorPath: "resources.jobs.job1.tasks[0].for_each_task.task",
errorDetail: "Task \"my_task\" has a task type that requires a cluster, but no cluster is specified",
errorDetail: "Task \"my_task\" has a task type that requires a cluster or environment, but neither is specified",
errorSummary: expectedSummary,
},
}