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

Fix service.check_restart stanza propagation #3718

Merged
merged 5 commits into from
Jan 17, 2018

Conversation

schmichael
Copy link
Member

@schmichael schmichael commented Jan 5, 2018

There was a bug in jobspec parsing, a bug in CheckRestart merging, and a
bug in CheckRestart canonicalization. All are now tested.

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)]
Copy link
Contributor

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.

Copy link
Member Author

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
Copy link
Contributor

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 {
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Member Author

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.

@schmichael schmichael changed the title [BLOCKED] Fix service.check_restart stanza propagation Fix service.check_restart stanza propagation Jan 9, 2018
There was a bug in jobspec parsing, a bug in CheckRestart merging, and a
bug in CheckRestart canonicalization. All are now tested.
It was never really implemented to begin with
@schmichael
Copy link
Member Author

Should be ready to review again.

}

service.Canonicalize(task, tg, job)
assert.Equal(t, service.Checks[0].CheckRestart.Limit, 22)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use "require" package

Copy link
Member Author

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.

@schmichael schmichael merged commit 96e00a5 into master Jan 17, 2018
@schmichael schmichael deleted the b-3713-fix-check-restart branch January 17, 2018 00:39
@github-actions
Copy link

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants