system scheduler: correction to Test_computeCanaryNodes (#26707)

This commit is contained in:
Piotr Kazmierczak
2025-09-05 16:20:34 +02:00
committed by GitHub
parent 276ab8a4c6
commit a083495240
2 changed files with 22 additions and 1 deletions

View File

@@ -135,7 +135,7 @@ func (nr *NodeReconciler) findOldCanaryNodes(nodesList []*structs.Node, numberOf
a *structs.Allocation, tg *structs.TaskGroup, canaryNodes map[string]map[string]bool, nodeID string) ([]*structs.Node, int) {
if a.DeploymentStatus == nil || a.DeploymentStatus.Canary == false ||
nr.DeploymentCurrent == nil { // TODO: should we add this? || nr.DeploymentCurrent.ID != a.DeploymentID {
nr.DeploymentCurrent == nil {
return nodesList, numberOfCanaryNodes
}

View File

@@ -895,6 +895,7 @@ func Test_computeCanaryNodes(t *testing.T) {
DeploymentStatus: &structs.AllocDeploymentStatus{
Canary: true,
},
TaskGroup: "foo",
},
},
},
@@ -925,6 +926,26 @@ func Test_computeCanaryNodes(t *testing.T) {
fiveEligibleNodeNames[2]: "foo",
},
},
{
name: "task group with 100% canary deploy, 1 eligible node",
nodes: map[string]*structs.Node{"foo": mock.Node()},
liveAllocs: nil,
terminalAllocs: nil,
required: map[string]*structs.TaskGroup{
"foo": {
Name: "foo",
Update: &structs.UpdateStrategy{
Canary: 100,
MaxParallel: 1,
},
},
},
existingDeployment: nil,
expectedCanaryNodes: map[string]int{
"foo": 1,
},
expectedCanaryNodeID: nil,
},
}
for _, tc := range testCases {