HomeClusterLabs Projects

Low: scheduler: calculate group promotion scores correctly

Description

Low: scheduler: calculate group promotion scores correctly

Previously, promotion_score() took a default_score argument, which was set to 0
by one caller and -1 by another caller.

For promotable cloned groups, the result was the sum of calling
promotion_score() for each group member, initializing score to the default and
using this for each child:

if (score == default_score) {
    score = c_score;
} else {
    score += c_score;
}

When the default is -1, and the first <N> members' scores were explicitly set
to -1, they would be ignored, because the next child would hit the = instead of
the +=. However when scores are explicit, they should be taken into account.

Also when the default is -1, a related issue is that if only some members of a
cloned group have promotion scores, members before that without scores would be
ignored, while members after that without scores would be added as -1 each.
However, in this case, all group members without scores should be ignored. In
other words, a group's score should be the sum of only those members that have
explicit scores, or the default value if no member does.

The fix is to always use 0 as the default, but have an output variable for
whether the returned value was explicit or the default, so the caller can
modify its behavior accordingly.

Details

Provenance
kgaillotAuthored on May 17 2022, 3:44 PM
Parents
rPb07159c26b7e: Refactor: scheduler: best practices for promotion_score()
Branches
Unknown
Tags
Unknown