Skip to content

Commit dc8240a

Browse files
committed
Fix band percentage math in fleet overview
Bands were counted per-slice as 'any VM in this band', so slices running multiple bands were double-counted and percentages could sum past 100% (e.g. 100% batch + 38% interactive). Assign each slice to a single dominant band based on task counts across its VMs, matching the slice-level 'in use' percentage so shares partition in-use slices.
1 parent 8580f5c commit dc8240a

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

lib/iris/dashboard/src/components/controller/AutoscalerTab.vue

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ function regionFromGroupName(name: string): string {
582582
583583
const fleetSummary = computed<FleetChipSummary[]>(() => {
584584
const now = Date.now()
585-
const chips = new Map<string, { total: number; inUse: number; uptimes: number[]; regions: Map<string, number> }>()
585+
const chips = new Map<string, { total: number; inUse: number; uptimes: number[]; regions: Map<string, number>; bands: Map<string, number>; capacityByRegion: Map<string, { statuses: string[]; failures: number }> }>()
586586
587587
for (const g of groups.value) {
588588
const chip = chipFromGroupName(g.name)
@@ -609,19 +609,29 @@ const fleetSummary = computed<FleetChipSummary[]>(() => {
609609
entry.capacityByRegion.set(region, capEntry)
610610
611611
// Collect band usage from scheduler running tasks via workerId join.
612-
// Count each slice once per band (a slice is "used by" a band if any of
613-
// its VMs has a running task in that band).
612+
// Assign each slice to a single dominant band (the band with the most
613+
// task-count across its VMs) so band shares partition in-use slices
614+
// rather than double-counting slices that host multiple bands.
614615
for (const slice of readySlices) {
615-
const sliceBands = new Set<string>()
616+
const sliceBandCounts = new Map<string, number>()
616617
for (const vm of slice.vms ?? []) {
617618
if (!vm.workerId) continue
618619
const bands = workerBands.value.get(vm.workerId)
619-
if (bands) {
620-
for (const band of bands.keys()) sliceBands.add(band)
620+
if (!bands) continue
621+
for (const [band, count] of bands) {
622+
sliceBandCounts.set(band, (sliceBandCounts.get(band) ?? 0) + count)
621623
}
622624
}
623-
for (const band of sliceBands) {
624-
entry.bands.set(band, (entry.bands.get(band) ?? 0) + 1)
625+
let topBand: string | null = null
626+
let topCount = 0
627+
for (const [band, count] of sliceBandCounts) {
628+
if (count > topCount) {
629+
topBand = band
630+
topCount = count
631+
}
632+
}
633+
if (topBand) {
634+
entry.bands.set(topBand, (entry.bands.get(topBand) ?? 0) + 1)
625635
}
626636
}
627637

0 commit comments

Comments
 (0)