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

deployment watcher: Reuse allocsCh if allocIndex remains the same #10756

Merged
merged 2 commits into from
Jun 14, 2021
Merged
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion nomad/deploymentwatcher/deployment_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ func (w *deploymentWatcher) watch() {
}

allocIndex := uint64(1)
allocsCh := w.getAllocsCh(allocIndex)
var updates *allocUpdates

rollback, deadlineHit := false, false
Expand Down Expand Up @@ -487,7 +488,7 @@ FAIL:
break FAIL
}

case updates = <-w.getAllocsCh(allocIndex):
case updates = <-allocsCh:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure how to effectively test the side-effects of this change :(.

if err := updates.err; err != nil {
if err == context.Canceled || w.ctx.Err() == context.Canceled {
return
Expand Down Expand Up @@ -531,6 +532,8 @@ FAIL:
if res.createEval || len(res.allowReplacements) != 0 {
w.createBatchedUpdate(res.allowReplacements, allocIndex)
}

allocsCh = w.getAllocsCh(allocIndex)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally this line is immediately after the allocIndex but I wanted to avoid creating a query in error or failure conditions. Though, given that those conditions are relatively rare, I can be persuaded to move it if it improves readability.

notnoop marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down