Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of services: remove assertion on 'task' field being set into release/1.4.x #14865

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/14864.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
services: Fixed a regression where check task validation stopped allowing some configurations
```
4 changes: 0 additions & 4 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6681,10 +6681,6 @@ func (tg *TaskGroup) validateServices() error {

for _, check := range service.Checks {
if check.TaskName != "" {
if check.Type != ServiceCheckScript && check.Type != ServiceCheckGRPC {
mErr.Errors = append(mErr.Errors,
fmt.Errorf("Check %s invalid: only script and gRPC checks should have tasks", check.Name))
}
if check.AddressMode == AddressModeDriver {
mErr.Errors = append(mErr.Errors, fmt.Errorf("Check %q invalid: cannot use address_mode=\"driver\", only checks defined in a \"task\" service block can use this mode", service.Name))
}
Expand Down
3 changes: 0 additions & 3 deletions nomad/structs/structs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1278,9 +1278,6 @@ func TestTaskGroup_Validate(t *testing.T) {
expected = `Check check-a invalid: refers to non-existent task task-b`
require.Contains(t, err.Error(), expected)

expected = `Check check-a invalid: only script and gRPC checks should have tasks`
require.Contains(t, err.Error(), expected)

tg = &TaskGroup{
Name: "group-a",
Services: []*Service{
Expand Down
8 changes: 4 additions & 4 deletions website/content/docs/job-specification/check.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ job "example" {
- `protocol` `(string: "http")` - Specifies the protocol for the http-based
health checks. Valid options are `http` and `https`.

- `task` `(string: <required>)` - Specifies the task associated with this
- `task` `(string: "")` - Specifies the task associated with this
check. Scripts are executed within the task's environment, and
`check_restart` stanzas will apply to the specified task. For `checks` on group
level `services` only. Inherits the [`service.task`][service_task] value if not
set. May only be set for script or gRPC checks.
`check_restart` stanzas will apply to the specified task. Inherits
the [`service.task`][service_task] value if not set. Must be unset
or equivelent to `service.task` in task-level services.

- `timeout` `(string: <required>)` - Specifies how long to wait for a health check
query to succeed. This is specified using a label suffix like "30s" or "1h". This
Expand Down