From 9c31e7f90c7cfbefb3800f5c36ef37e00fe89210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B0=E6=9C=94?= <565183519@qq.com> Date: Fri, 11 Sep 2026 18:33:44 +0800 Subject: [PATCH] feat(pool): grant deterministic worker leases --- server-tools/persona-compute-pool/entry_service.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server-tools/persona-compute-pool/entry_service.py b/server-tools/persona-compute-pool/entry_service.py index f06bbe9..56d3b53 100644 --- a/server-tools/persona-compute-pool/entry_service.py +++ b/server-tools/persona-compute-pool/entry_service.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Loopback-first compute-pool entry with authenticated worker heartbeats.""" from __future__ import annotations -import json, os, secrets, ssl, threading +import json, os, secrets, ssl, threading, time, uuid from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from pathlib import Path @@ -50,7 +50,16 @@ class Handler(BaseHTTPRequestHandler): if node != peer: self.send_json(403,{'error':'WORKER_CERT_ID_MISMATCH'}); return state['workers'][node]={**payload,'last_seen':payload.get('observed_at'),'authority_granted':False}; state['registered_workers']=len(state['workers']); write_state(state); self.send_json(200,{'outcome':'HEARTBEAT_ACCEPTED','node_id':node,'authority_granted':False}); return if self.path=='/v1/lease/request': - self.send_json(200,{'outcome':'LEASE_QUEUED','state':'PENDING_DETERMINISTIC_SELECTION','authority_granted':False}); return + min_cpu=int(payload.get('min_cpu_cores',1)); min_mem=int(payload.get('min_memory_mb',256)); candidates=[] + for worker in state['workers'].values(): + metrics=worker.get('metrics') or {} + if worker.get('state')!='ACTIVE_WORKER': continue + if int(metrics.get('cpu_cores') or 0)