mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-05-02 23:50:10 -05:00
fix(scheduling): negative weigths ranks were not excluded from the candidate workers pool (#1941)
Co-authored-by: jbsouvestre <jean-baptiste@ubble.ai>
This commit is contained in:
committed by
GitHub
parent
2ccd434ebf
commit
f08c348710
@@ -169,6 +169,11 @@ func (r *rankedValidSlots) order() []*slot {
|
||||
for i := len(sortedRanks) - 1; i >= 0; i-- {
|
||||
rank := sortedRanks[i]
|
||||
|
||||
if rank < 0 {
|
||||
// skip negative ranks, as they are not valid for scheduling
|
||||
continue
|
||||
}
|
||||
|
||||
if r.ranksToSlots[rank] != nil {
|
||||
nonNegativeSlots = append(nonNegativeSlots, r.ranksToSlots[rank]...)
|
||||
}
|
||||
|
||||
@@ -96,6 +96,46 @@ func TestGetRankedSlots(t *testing.T) {
|
||||
},
|
||||
expectedWorker: []string{stableWorkerId2, stableWorkerId1},
|
||||
},
|
||||
{
|
||||
name: "Affinity labels with strict requirements",
|
||||
qi: &sqlcv1.V1QueueItem{},
|
||||
labels: []*sqlcv1.GetDesiredLabelsRow{
|
||||
{
|
||||
Key: "key1",
|
||||
Weight: 1,
|
||||
Required: true,
|
||||
Comparator: sqlcv1.WorkerLabelComparatorEQUAL,
|
||||
IntValue: pgtype.Int4{Int32: 1, Valid: true},
|
||||
},
|
||||
},
|
||||
slots: []*slot{
|
||||
newSlot(&worker{ListActiveWorkersResult: &v1.ListActiveWorkersResult{ID: (stableWorkerId1), Labels: []*sqlcv1.ListManyWorkerLabelsRow{{
|
||||
Key: "key1",
|
||||
IntValue: pgtype.Int4{Int32: 1, Valid: true},
|
||||
}}}}, []string{}),
|
||||
},
|
||||
expectedWorker: []string{stableWorkerId1},
|
||||
},
|
||||
{
|
||||
name: "Affinity labels with strict requirements and unsatisfiable conditions",
|
||||
qi: &sqlcv1.V1QueueItem{},
|
||||
labels: []*sqlcv1.GetDesiredLabelsRow{
|
||||
{
|
||||
Key: "key1",
|
||||
Weight: 1,
|
||||
Required: true,
|
||||
Comparator: sqlcv1.WorkerLabelComparatorEQUAL,
|
||||
IntValue: pgtype.Int4{Int32: 1, Valid: true},
|
||||
},
|
||||
},
|
||||
slots: []*slot{
|
||||
newSlot(&worker{ListActiveWorkersResult: &v1.ListActiveWorkersResult{ID: (stableWorkerId2), Labels: []*sqlcv1.ListManyWorkerLabelsRow{{
|
||||
Key: "key1",
|
||||
IntValue: pgtype.Int4{Int32: 2, Valid: true},
|
||||
}}}}, []string{}),
|
||||
},
|
||||
expectedWorker: []string{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user