Nomad should throw an error if script check is used in a group-level service and no task argument is set.
- Dominant language
- Go
- Stars
- 17k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 105
Description
### Nomad version
Nomad v0.12.0-beta2 (5b80d4e638f1a27eee3ca245f8babb115e4c098d)
### Operating system and Environment details
Ubuntu 18.04 on AMD64
Consul v1.8.0
### Issue
Script checks on group-level services require the `task` argument to be set per the [docs](https://www.nomadproject.io/docs/job-specification/service#task-2). However, if no task name is provided, Nomad does not inform the user, and the allocation will just quietly become unhealthy after the `progress_deadline` has passed.
Instead, Nomad should inform the user of a missing task name as part of the jobspec validation/planning. This could be similar to the task specification for a group-level service with connect native enabled, where if no task name (or an invalid task name) is given, an error is thrown:
`Plan Error
error in job mutator connect: native task named by group_name->service_name does not exist`
### Reproduction steps
Run the below job
### Job file (if appropriate)
```hcl
job "ubuntu" {
datacenters = ["dc1"]
group "ubuntu" {
task "ubuntu" {
config {
image = "ubuntu:latest"
command = "bash"
tty = true
}
driver = "docker"
}
network {
mode = "bridge"
mbits = 10
}
service {
name = "test-service"
port = 8080
address_mode = "auto"
connect {
sidecar_service {
}
}
check {
name = "test-service-health"
type = "script"
command = "ls"
interval = "5s"
timeout = "3s"
}
}
}
}
```
With that jobspec, the allocation will become unhealthy. If the line `task = "ubuntu"` is added to the check stanza, the check passes and the allocation becomes healthy as expected.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the supplied jobspec and comparing planning behavior with and without task = "ubuntu" in the script check. Read the jobspec validation/planning path and the existing connect native task validation mentioned in the issue; done means a missing task produces a plan error while a valid task still allows the check to pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100