Skip to content

Commit 3aca357

Browse files
committed
fix(warm-pool): a waiter's boot is held back under the device's spec (#774)
1 parent f3ec4a9 commit 3aca357

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎src/core/warm-pool/policy.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,16 @@ describe("warm pool policy", () => {
306306
{ action: "boot", deviceId: "lse_15", reason: "waiting-request" },
307307
]);
308308
expect(evaluate(view([released], { waiting, blocked: [spec("iPhone 15")] }))).toEqual([]);
309+
310+
// why: the converger records the failure under the device's spec, which a class waiter's may differ from.
311+
const other = device("lse_17", "shutdown", {
312+
endedAgo: 90 * minute,
313+
spec: spec("iPhone 17"),
314+
});
315+
expect(evaluate(view([other], { waiting }))).toEqual([
316+
{ action: "boot", deviceId: "lse_17", reason: "waiting-request" },
317+
]);
318+
expect(evaluate(view([other], { waiting, blocked: [spec("iPhone 17")] }))).toEqual([]);
309319
});
310320

311321
it("proposes a boot, not a shutdown, for a released iPhone 15 that serves a waiting class request at the running cap", () => {

‎src/core/warm-pool/policy.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,14 @@ function bootsOpen(state: QueueState): boolean {
370370
}
371371

372372
function bootForWaiter(state: QueueState, demand: WaitingDemand): boolean {
373-
if (!bootsOpen(state) || !state.view.retry.mayAttempt(demand.spec, state.view.now)) return false;
373+
if (!bootsOpen(state)) return false;
374374
const device = state.bootable.find(
375375
(candidate) =>
376376
!state.taken.has(candidate.id) &&
377377
hasRoom(state.room, candidate) &&
378378
serves(candidate, demand) &&
379+
// why: the converger records a failed boot under the device's spec, not the waiter's.
380+
state.view.retry.mayAttempt(candidate.spec, state.view.now) &&
379381
state.view.admit.boot(candidate) === undefined,
380382
);
381383
if (device === undefined) return false;

0 commit comments

Comments
 (0)