Add safe manual instance rebalancing

This commit is contained in:
2026-10-08 12:37:56 -04:00
parent 26de43639f
commit 012cd51a66
45 changed files with 2006 additions and 154 deletions
+2 -1
View File
@@ -11,6 +11,7 @@ const CPU_USABLE_FRACTION = 0.95;
export class CapacityError extends Error {}
export interface PlacementOptions {
hostId?: string; libraryId: string; image: string; bindAddress?: string;
excludeHostIds?: string[];
thorough?: boolean; excludeInstanceId?: string;
// Execution only: not-yet-submitted launches wait their turn instead of
// requiring their entire backlog to fit before any one can start.
@@ -100,7 +101,7 @@ function projectedLoad(host: Host, options: PlacementOptions): number {
export function choosePlacement(options: PlacementOptions): { host: Host; port: number; load: number } {
const candidates: { host: Host; port: number; load: number }[] = [];
const reasons: string[] = [];
for (const host of listHosts().filter(host => !options.hostId || host.id === options.hostId)) {
for (const host of listHosts().filter(host => (!options.hostId || host.id === options.hostId) && !options.excludeHostIds?.includes(host.id))) {
try {
requireReadyHost(host.id, { image: options.image, requiredBytes: INSTANCE_STORAGE_BYTES });
assertReadyLibrary(host.id, options.libraryId);