Quota "availableHeadroom" calculation:
is off when subroles are involved.
Specifically, in the formula
The "allocated resources" part is hierarchical-aware and aggregate that across all roles, thus allocations to subroles will be counted multiple times (in the case of "a/b", once for "a" and once for "a/b"). Looks like due to the presence of `INTERNAL` node, `roleSorter->allocationScalarQuantities(role)` is not hierarchical. Thus this is not an issue.
(If role `a/b` consumes 1cpu and `a` consumes 1cpu, if we query `roleSorter->allocationScalarQuantities("a");` It will return 1cpu, which is correct. In the sorter, there are four nodes, root, `a` (internal, 1cpu), `a/.` (leaf, 1cpu), `a/b` (leaf, 1cpu). Query `a` will return `a/.`)
The "total reservations" is correct, since today it is "flat" (reservations made to "a/b" are not counted to "a"). Thus all reservations are only counted once – which is the correct semantic here. However, once we fix
MESOS-9688 (which likely requires reservation tracking to be hierarchical-aware), we need to ensure that the accounting is still correct. The "allocated reservations" is hierarchical-aware, thus overlap accounting would occur. Similar to the `"allocated resources"` above, this is also not an issue at the moment.
Basically, when calculating the available headroom, we need to ensure "single-counting". Ideally, we only need to look at the root's consumptions.