Compare commits

...

4 Commits

Author SHA1 Message Date
Gleb Kanterov 434aa17bde
Fix tests 2024-09-25 13:20:47 +02:00
Gleb Kanterov 3b49d5e89d
Update bundle/config/validate/job_task_cluster_spec.go
Co-authored-by: Pieter Noordhuis <pcnoordhuis@gmail.com>
2024-09-25 13:19:04 +02:00
Gleb Kanterov 3a28d20d04
Fix lint 2024-09-25 10:28:46 +02:00
Gleb Kanterov 3a3569e1a7
Better messages 2024-09-25 10:26:17 +02:00
2 changed files with 13 additions and 7 deletions

View File

@ -83,11 +83,15 @@ 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 or environment, but neither is specified", task.TaskKey)
detail := fmt.Sprintf(
"Task %q requires a cluster or an environment to run.\nSpecify one of the following fields: %s.",
task.TaskKey,
strings.Join(unspecified, ", "),
)
diags = diags.Append(diag.Diagnostic{
Severity: diag.Error,
Summary: fmt.Sprintf("One of the following fields must be set: %s", strings.Join(unspecified, ", ")),
Summary: "Missing required cluster or environment settings",
Detail: detail,
Locations: rb.Config().GetLocations(taskPath.String()),
Paths: []dyn.Path{taskPath},

View File

@ -13,7 +13,7 @@ import (
)
func TestJobTaskClusterSpec(t *testing.T) {
expectedSummary := "One of the following fields must be set: job_cluster_key, environment_key, existing_cluster_id, new_cluster"
expectedSummary := "Missing required cluster or environment settings"
type testCase struct {
name string
@ -144,7 +144,8 @@ 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 or environment, but neither is specified",
errorDetail: `Task "my_task" requires a cluster or an environment to run.
Specify one of the following fields: job_cluster_key, environment_key, existing_cluster_id, new_cluster.`,
errorSummary: expectedSummary,
},
{
@ -158,7 +159,8 @@ 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 or environment, but neither is specified",
errorDetail: `Task "my_task" requires a cluster or an environment to run.
Specify one of the following fields: job_cluster_key, environment_key, existing_cluster_id, new_cluster.`,
errorSummary: expectedSummary,
},
}