-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix service.check_restart stanza propagation #3718
Conversation
1810ff9
to
dff64ef
Compare
CHANGELOG.md
Outdated
@@ -3,6 +3,7 @@ | |||
BUG FIXES: | |||
* core: Fix search endpoint forwarding for multi-region clusters [[GH-3680](https://github.com/hashicorp/nomad/issues/3680)] | |||
* config: Revert minimum CPU limit back to 20 from 100. | |||
* discovery: Fix handling of `service.check_restart` [[GH-3718](https://github.com/hashicorp/nomad/issues/3718)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow check_restart
to be specified in the service
stanza.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to Feature or leave as Bug Fix?
I'm going to move to Feature since we removed it from the docs and it never worked but let me know if Bug Fix is preferred.
@@ -136,7 +136,7 @@ func (c *CheckRestart) Merge(o *CheckRestart) *CheckRestart { | |||
nc.Grace = o.Grace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This merge seems backwards. Usually we prefer the passed in object's values. https://github.com/hashicorp/nomad/blob/master/api/jobs.go#L389
api/tasks.go
Outdated
@@ -136,7 +136,7 @@ func (c *CheckRestart) Merge(o *CheckRestart) *CheckRestart { | |||
nc.Grace = o.Grace | |||
} | |||
|
|||
if nc.IgnoreWarnings { | |||
if !nc.IgnoreWarnings { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if o.IgnoreWarnings { nc.IgnoreWarnings = o.IgnoreWarnings }
api/tasks.go
Outdated
@@ -189,9 +189,9 @@ func (s *Service) Canonicalize(t *Task, tg *TaskGroup, job *Job) { | |||
|
|||
// Canonicallize CheckRestart on Checks and merge Service.CheckRestart | |||
// into each check. | |||
for _, c := range s.Checks { | |||
for i, c := range s.Checks { | |||
s.Checks[i].CheckRestart = c.CheckRestart.Merge(s.CheckRestart) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make sure the merge is correct for check restart too
jobspec/parse.go
Outdated
@@ -1042,7 +1043,7 @@ func parseChecks(service *api.Service, checkObjs *ast.ObjectList) error { | |||
if ot, ok := co.Val.(*ast.ObjectType); ok { | |||
checkRestartList = ot.List | |||
} else { | |||
return fmt.Errorf("check_restart '%s': should be an object", check.Name) | |||
return fmt.Errorf("check '%s': should be an object", check.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I get why you changed this? It is the check restart object that is failing the cast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argh, I think the check.Name
interpolation confused me. Fixing.
dff64ef
to
84a1013
Compare
84a1013
to
b658ac3
Compare
Should be ready to review again. |
} | ||
|
||
service.Canonicalize(task, tg, job) | ||
assert.Equal(t, service.Checks[0].CheckRestart.Limit, 22) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use "require" package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case I want it to continue checking in case it's just one field off.
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
There was a bug in jobspec parsing, a bug in CheckRestart merging, and a
bug in CheckRestart canonicalization. All are now tested.