-
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
Placing allocs counts towards placement limit #3070
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,7 @@ Update stanza Tests: | |
√ Finished deployment gets marked as complete | ||
√ The stagger is correctly calculated when it is applied across multiple task groups. | ||
√ Change job change while scaling up | ||
√ Update the job when all allocations from the previous job haven't been placed yet. | ||
*/ | ||
|
||
var ( | ||
|
@@ -2468,9 +2469,9 @@ func TestReconciler_TaintedNode_RollingUpgrade(t *testing.T) { | |
PlacedAllocs: 7, | ||
} | ||
|
||
// Create 3 allocations from the old job | ||
// Create 2 allocations from the old job | ||
var allocs []*structs.Allocation | ||
for i := 7; i < 10; i++ { | ||
for i := 8; i < 10; i++ { | ||
alloc := mock.Alloc() | ||
alloc.Job = job | ||
alloc.JobID = job.ID | ||
|
@@ -2482,7 +2483,7 @@ func TestReconciler_TaintedNode_RollingUpgrade(t *testing.T) { | |
|
||
// Create the healthy replacements | ||
handled := make(map[string]allocUpdateType) | ||
for i := 0; i < 7; i++ { | ||
for i := 0; i < 8; i++ { | ||
new := mock.Alloc() | ||
new.Job = job | ||
new.JobID = job.ID | ||
|
@@ -2501,7 +2502,7 @@ func TestReconciler_TaintedNode_RollingUpgrade(t *testing.T) { | |
tainted := make(map[string]*structs.Node, 3) | ||
for i := 0; i < 3; i++ { | ||
n := mock.Node() | ||
n.ID = allocs[3+i].NodeID | ||
n.ID = allocs[2+i].NodeID | ||
if i == 0 { | ||
n.Status = structs.NodeStatusDown | ||
} else { | ||
|
@@ -2519,21 +2520,21 @@ func TestReconciler_TaintedNode_RollingUpgrade(t *testing.T) { | |
createDeployment: nil, | ||
deploymentUpdates: nil, | ||
place: 2, | ||
destructive: 3, | ||
destructive: 2, | ||
stop: 2, | ||
followupEvalWait: 31 * time.Second, | ||
desiredTGUpdates: map[string]*structs.DesiredUpdates{ | ||
job.TaskGroups[0].Name: { | ||
Place: 1, // Place the lost | ||
Stop: 1, // Stop the lost | ||
Migrate: 1, // Migrate the tainted | ||
DestructiveUpdate: 3, | ||
Ignore: 5, | ||
DestructiveUpdate: 2, | ||
Ignore: 6, | ||
}, | ||
}, | ||
}) | ||
|
||
assertNamesHaveIndexes(t, intRange(7, 9), destructiveResultsToNames(r.destructiveUpdate)) | ||
assertNamesHaveIndexes(t, intRange(8, 9), destructiveResultsToNames(r.destructiveUpdate)) | ||
assertNamesHaveIndexes(t, intRange(0, 1), placeResultsToNames(r.place)) | ||
assertNamesHaveIndexes(t, intRange(0, 1), stopResultsToNames(r.stop)) | ||
} | ||
|
@@ -3012,3 +3013,48 @@ func TestReconciler_JobChange_ScaleUp_SecondEval(t *testing.T) { | |
}, | ||
}) | ||
} | ||
|
||
// Tests the reconciler doesn't stop allocations when doing a rolling upgrade | ||
// where the count of the old job allocs is < desired count. | ||
func TestReconciler_RollingUpgrade_MissingAllocs(t *testing.T) { | ||
job := mock.Job() | ||
job.TaskGroups[0].Update = noCanaryUpdate | ||
|
||
// Create 7 allocations from the old job | ||
var allocs []*structs.Allocation | ||
for i := 0; i < 7; i++ { | ||
alloc := mock.Alloc() | ||
alloc.Job = job | ||
alloc.JobID = job.ID | ||
alloc.NodeID = structs.GenerateUUID() | ||
alloc.Name = structs.AllocName(job.ID, job.TaskGroups[0].Name, uint(i)) | ||
alloc.TaskGroup = job.TaskGroups[0].Name | ||
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. It looks like this happens in a couple other tests (assigning field values)- you could create a test helper function for this. |
||
allocs = append(allocs, alloc) | ||
} | ||
|
||
reconciler := NewAllocReconciler(testLogger(), allocUpdateFnDestructive, false, job.ID, job, nil, allocs, nil) | ||
r := reconciler.Compute() | ||
|
||
d := structs.NewDeployment(job) | ||
d.TaskGroups[job.TaskGroups[0].Name] = &structs.DeploymentState{ | ||
DesiredTotal: 10, | ||
} | ||
|
||
// Assert the correct results | ||
assertResults(t, r, &resultExpectation{ | ||
createDeployment: d, | ||
deploymentUpdates: nil, | ||
place: 3, | ||
destructive: 1, | ||
desiredTGUpdates: map[string]*structs.DesiredUpdates{ | ||
job.TaskGroups[0].Name: { | ||
Place: 3, | ||
DestructiveUpdate: 1, | ||
Ignore: 6, | ||
}, | ||
}, | ||
}) | ||
|
||
assertNamesHaveIndexes(t, intRange(7, 9), placeResultsToNames(r.place)) | ||
assertNamesHaveIndexes(t, intRange(0, 0), destructiveResultsToNames(r.destructiveUpdate)) | ||
} |
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.
Maybe not as part of this PR, but it would be good to limit the length of this function, and start introducing smaller functions to encompass some of this logic.
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.
Haha yeah it definitely needs a refactoring!