diff --git a/src/runtime-policy.mjs b/src/runtime-policy.mjs index 760fc43c..67a20c6d 100644 --- a/src/runtime-policy.mjs +++ b/src/runtime-policy.mjs @@ -200,7 +200,9 @@ function runtimeRows(config, status, requestedRuntimeId, requesterNode) { return Object.entries(config.runtimes ?? {}).map(([runtimeId, runtime]) => { const runtimeStatus = status?.runtimes?.[runtimeId] ?? {}; const requested = runtimeId === requestedRuntimeId; - const loaded = isRuntimeLoaded(runtimeStatus); + // A disabled external runtime is not LLooM's; its last status says nothing about memory. + const retired = runtime.enabled !== true && runtime.management === 'external'; + const loaded = !retired && isRuntimeLoaded(runtimeStatus); const ownedByDistributedGroup = distributedMembers.has(runtimeId); const authority = runtimeAuthority(config, runtimeId); const memoryGb = ownedByDistributedGroup ? 0 : runtimeMemoryGb(runtime); diff --git a/test/runtime-policy.test.mjs b/test/runtime-policy.test.mjs index 21c259f6..4aebec7b 100644 --- a/test/runtime-policy.test.mjs +++ b/test/runtime-policy.test.mjs @@ -634,4 +634,30 @@ const applied = await applyRuntimePolicyPlan(unpinnedPolicyConfig, fakePolicyMan assert.equal(applied.dryRun, false); assert.deepEqual(policyOperations, ['stop:warm', 'start:big:unit-admit']); +// A disabled external runtime is not LLooM's: its stale status neither counts nor gets stopped. +// A disabled managed runtime that is still up keeps counting until LLooM stops it. +const retiredPlan = await createRuntimePolicyPlan( + { + runtimePolicy: { memoryBudgetGb: 40 }, + runtimes: { + retired: { enabled: false, management: 'external', memoryGb: 30 }, + draining: { enabled: false, memoryGb: 5 }, + requested: { enabled: true, memoryGb: 30 } + } + }, + { + requestedRuntimeId: 'requested', + status: { + runtimes: { + retired: { healthy: true, status: 'external' }, + draining: { healthy: true, status: 'running' }, + requested: { healthy: false, status: 'idle' } + } + } + } +); +assert.equal(retiredPlan.admission.projectedMemoryGb, 35); +assert.equal(retiredPlan.admission.allowed, true); +assert(!retiredPlan.actions.some((action) => action.runtimeId === 'retired')); + console.log('runtime-policy tests passed');