import { useConsole } from "../context"; import { Card, Bar, DataListRaw } from "../components/ui"; import { workerAgeText, shortId } from "../api/client"; import { chvAvailability } from "../api/chv"; export default function WorkersSection() { const ctx = useConsole(); const chvAvail = chvAvailability(ctx.workers, ctx.workersSummary, ctx.workersError); return (
{chvAvail.state === "known" ? <>cloud-hypervisor worker 在线 {chvAvail.online} / 共 {chvAvail.total}(实验,默认关闭){chvAvail.online === 0 ? ":当前无 CHV worker 在线,CHV 任务将一直排队。" : ""} : "cloud-hypervisor worker 在线数未知:完整 worker 清单仅全局管理员可见,非管理员只能看到聚合数,无法按执行器分项。"}
{ctx.workersError ?
{ctx.workersError}
: ctx.workers === null ?
{ctx.workersSummary || "未加载"}
: ctx.workers.length === 0 ?
无 worker 注册
: ( {ctx.workers.map((w, i) => { const run = w.running === undefined || w.running === null ? "?" : w.running; const cap = w.capacity === undefined || w.capacity === null ? "?" : w.capacity; const info = workerAgeText(w); const alive = w.alive !== undefined && w.alive !== null ? !!w.alive : (info.age !== null && info.age <= 120); const live = alive ? " / 在线" : " / 离线(占用为上次上报值)"; return (
  • {w.worker_id || w.id || "?"} / {w.executor || ""} / 占用 {run}/{cap}{live} / 最后心跳 {info.text}
  • ); })}
    )}
    ); }