Skip to content

Commit fe8d39f

Browse files
committed
Fix over-counted site availability: exclude future advance reservations
occupied_node_capacity() now defaults to start=now, end=now when no time range is specified. Previously, all Ticketed reservations (including future advance reservations) were counted as currently occupied, causing cores_allocated to exceed cores_capacity at sites like UCSD (657 > 640). Calendar/scheduling callers that pass explicit start/end are unaffected.
1 parent 7276929 commit fe8d39f

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

fabric_cf/actor/fim/plugins/broker/aggregate_bqm_plugin.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from __future__ import annotations
2727

2828
import json
29-
from datetime import datetime
29+
from datetime import datetime, timezone
3030
from typing import Tuple, Dict, TYPE_CHECKING, List, Optional
3131
from collections import defaultdict
3232

@@ -167,6 +167,15 @@ def occupied_node_capacity(*, db: ABCDatabase, node_id: str, start: Optional[dat
167167
ReservationStates.Ticketed.value,
168168
ReservationStates.Nascent.value]
169169

170+
# When no time range is specified, default to "now" so that future
171+
# advance reservations (Ticketed state) are not counted as currently
172+
# occupied. Callers that need future availability (e.g. the calendar
173+
# endpoint) pass explicit start/end and are unaffected.
174+
if start is None and end is None:
175+
now = datetime.now(timezone.utc)
176+
start = now
177+
end = now
178+
170179
# get existing reservations for this node
171180
existing_reservations = db.get_reservations(graph_node_id=node_id, states=states, start=start, end=end)
172181
# node capacities

0 commit comments

Comments
 (0)