-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
scheduler/reconcile: set FollowupEvalID on lost stop_after_client_disconnect #8105
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ccc0fe4
scheduler/reconcile: set FollowupEvalID on lost stop_after_client_dis…
langmartin 94c1926
scheduler/reconcile: thread follupEvalIDs through to results.stop
langmartin 1e6a1c4
scheduler/reconcile: comment typo
langmartin ee6936a
nomad/_test: correct arguments for plan.AppendStoppedAlloc
langmartin 314fffd
scheduler/reconcile: nil check, cleanup handleDelayed(Lost|Reschedules)
langmartin b51600f
scheduler/reconcile: yikes, return empty map instead
langmartin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -301,6 +301,19 @@ func (a *allocReconciler) markStop(allocs allocSet, clientStatus, statusDescript | |
} | ||
} | ||
|
||
// markDelayed does markStop, but included a FollowupEvalID so that we can update the | ||
// stopped alloc with it's delayed rescheduling evalID | ||
func (a *allocReconciler) markDelayed(allocs allocSet, clientStatus, statusDescription string, followupEvals map[string]string) { | ||
for _, alloc := range allocs { | ||
a.result.stop = append(a.result.stop, allocStopResult{ | ||
alloc: alloc, | ||
clientStatus: clientStatus, | ||
statusDescription: statusDescription, | ||
followupEvalID: followupEvals[alloc.ID], | ||
}) | ||
} | ||
} | ||
|
||
// computeGroup reconciles state for a particular task group. It returns whether | ||
// the deployment it is for is complete with regards to the task group. | ||
func (a *allocReconciler) computeGroup(group string, all allocSet) bool { | ||
|
@@ -355,7 +368,7 @@ func (a *allocReconciler) computeGroup(group string, all allocSet) bool { | |
|
||
// Find delays for any lost allocs that have stop_after_client_disconnect | ||
lostLater := lost.delayByStopAfterClientDisconnect() | ||
a.handleDelayedLost(lostLater, all, tg.Name) | ||
lostLaterEvals := a.handleDelayedLost(lostLater, all, tg.Name) | ||
|
||
// Create batched follow up evaluations for allocations that are | ||
// reschedulable later and mark the allocations for in place updating | ||
|
@@ -368,7 +381,7 @@ func (a *allocReconciler) computeGroup(group string, all allocSet) bool { | |
// Stop any unneeded allocations and update the untainted set to not | ||
// included stopped allocations. | ||
canaryState := dstate != nil && dstate.DesiredCanaries != 0 && !dstate.Promoted | ||
stop := a.computeStop(tg, nameIndex, untainted, migrate, lost, canaries, canaryState) | ||
stop := a.computeStop(tg, nameIndex, untainted, migrate, lost, canaries, canaryState, lostLaterEvals) | ||
desiredChanges.Stop += uint64(len(stop)) | ||
untainted = untainted.difference(stop) | ||
|
||
|
@@ -705,13 +718,13 @@ func (a *allocReconciler) computePlacements(group *structs.TaskGroup, | |
// the group definition, the set of allocations in various states and whether we | ||
// are canarying. | ||
func (a *allocReconciler) computeStop(group *structs.TaskGroup, nameIndex *allocNameIndex, | ||
untainted, migrate, lost, canaries allocSet, canaryState bool) allocSet { | ||
untainted, migrate, lost, canaries allocSet, canaryState bool, followupEvals map[string]string) allocSet { | ||
|
||
// Mark all lost allocations for stop. Previous allocation doesn't matter | ||
// here since it is on a lost node | ||
var stop allocSet | ||
stop = stop.union(lost) | ||
a.markStop(lost, structs.AllocClientStatusLost, allocLost) | ||
a.markDelayed(lost, structs.AllocClientStatusLost, allocLost, followupEvals) | ||
|
||
// If we are still deploying or creating canaries, don't stop them | ||
if canaryState { | ||
|
@@ -843,15 +856,15 @@ func (a *allocReconciler) handleDelayedReschedules(rescheduleLater []*delayedRes | |
} | ||
|
||
// handleDelayedLost creates batched followup evaluations with the WaitUntil field set for lost allocations | ||
func (a *allocReconciler) handleDelayedLost(rescheduleLater []*delayedRescheduleInfo, all allocSet, tgName string) { | ||
a.handleDelayedReschedulesImpl(rescheduleLater, all, tgName, false) | ||
func (a *allocReconciler) handleDelayedLost(rescheduleLater []*delayedRescheduleInfo, all allocSet, tgName string) map[string]string { | ||
return a.handleDelayedReschedulesImpl(rescheduleLater, all, tgName, false) | ||
} | ||
|
||
// handleDelayedReschedulesImpl creates batched followup evaluations with the WaitUntil field set | ||
func (a *allocReconciler) handleDelayedReschedulesImpl(rescheduleLater []*delayedRescheduleInfo, all allocSet, tgName string, | ||
createUpdates bool) { | ||
createUpdates bool) map[string]string { | ||
if len(rescheduleLater) == 0 { | ||
return | ||
return nil | ||
} | ||
|
||
// Sort by time | ||
|
@@ -910,17 +923,14 @@ func (a *allocReconciler) handleDelayedReschedulesImpl(rescheduleLater []*delaye | |
} | ||
|
||
// Create in-place updates for every alloc ID that needs to be updated with its follow up eval ID | ||
for allocID, evalID := range allocIDToFollowupEvalID { | ||
if createUpdates { | ||
if createUpdates { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change just reverts the previous commit |
||
for allocID, evalID := range allocIDToFollowupEvalID { | ||
existingAlloc := all[allocID] | ||
updatedAlloc := existingAlloc.Copy() | ||
updatedAlloc.FollowupEvalID = evalID | ||
a.result.attributeUpdates[updatedAlloc.ID] = updatedAlloc | ||
} else { | ||
// This alloc can just be modified in place. The lost alloc will be | ||
// sent to the planner in NodeUpdate, and the planner will commit | ||
// the alloc with it's FollowupEvalID as well as the lost status. | ||
all[allocID].FollowupEvalID = evalID | ||
} | ||
} | ||
|
||
return allocIDToFollowupEvalID | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Noticed that
handleDelayedReschedulesImpl
may return nil. Does function need to handle nilfollowupEvals
? Also, maybemarkDelayedStop
is a better descriptive name for this function?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.
Thanks, I do need a nil check there. I re(de?)factored
handleDelayedReschedulesImpl
, leaving just the two functions designed to be called:handleDelayedReschedules
andhandleDelayedLost
in 314fffd.