#4358 Fix min_avail calculation
Merged by mikem. Opened by mikem.
mikem/koji fix-min-avail  into  master

Download 4358.patch

The scheduler was incorrectly calculating min_avail (the amount of needed capacity) for tasks, in two different ways.

In the first task loop, using min instead of max is very wrong and causes the scheduler to miscalculate demand. This won't necessarily lead to obvious problems, but mostly defeats the code's attempt to rank hosts based on demand.

In the second task loop, the calculation is less wrong, but can be negative for tasks with weight less than the overcommit setting. This treats overcommit as "extra capacity" rather than the intention, which was to allow a single task to overshoot the capacity.

The added unit test demonstrates the problem from the second loop, and will fail without this fix.

Fixes https://pagure.io/koji/issue/4359

Currently Includes one of the fixes from #4357 to get tests to pass, but that presumably disappear in a future rebase

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-basic

Metadata Update from @mfilip:
- Pull-request tagged with: testing-done

rebased onto caeac8e7c7e6b40c0c78d915aa9eed91220d38ff

rebased to master, which dropped the already merged cherry-pick from #4357
unit tests still pass

Commit 4729cf86 fixes this pull-request

Pull-Request has been merged by mikem

Metadata