fix: configure HWPOD desktop apply budget

This commit is contained in:
pikastech
2026-07-21 10:28:01 +02:00
parent 49b88038e4
commit d21cb35430
2 changed files with 11 additions and 1 deletions
+2
View File
@@ -43,6 +43,7 @@ targets:
configPath: "C:\\Users\\liang\\.hwlab\\config.json"
credentialPath: "C:\\Users\\liang\\.hwlab\\hwpod-node.token"
logPath: "C:\\Users\\liang\\.hwlab\\logs\\hwlab-node.log"
applyTimeoutMs: 90000
artifact:
metadataUrl: https://lab-dev.hwpod.com/v1/hwlab-node/update
channel: stable
@@ -94,6 +95,7 @@ targets:
configPath: "C:\\Users\\lyon\\.hwlab\\config.json"
credentialPath: "C:\\Users\\lyon\\.hwlab\\hwpod-node.token"
logPath: "C:\\Users\\lyon\\.hwlab\\logs\\hwlab-node.log"
applyTimeoutMs: 90000
artifact:
metadataUrl: https://lab-dev.hwpod.com/v1/hwlab-node/update
channel: stable
+9 -1
View File
@@ -63,6 +63,7 @@ interface HwpodNodeSpec {
configPath: string;
credentialPath: string;
logPath: string;
applyTimeoutMs: number;
};
artifact: { metadataUrl: string; channel: string; platform: string; localPath: string | null; localVersion: string | null };
workspace: { allowedRoots: string[]; defaultRoot: string };
@@ -242,6 +243,7 @@ function readSpec(node: string, lane: string): HwpodNodeSpec {
configPath: text(runtime.configPath, `targets.${node}.runtime.configPath`),
credentialPath: text(runtime.credentialPath, `targets.${node}.runtime.credentialPath`),
logPath: text(runtime.logPath, `targets.${node}.runtime.logPath`),
applyTimeoutMs: positiveInteger(runtime.applyTimeoutMs, `targets.${node}.runtime.applyTimeoutMs`),
},
artifact: {
metadataUrl: text(artifact.metadataUrl, `targets.${node}.artifact.metadataUrl`),
@@ -482,7 +484,7 @@ function applyDesktop(spec: HwpodNodeSpec, artifact: ArtifactBundle, credential:
configSha256: sha256Hex(`${JSON.stringify(config, null, 2)}\n`),
credentialBase64: Buffer.from(`${credential}\n`, "utf8").toString("base64"),
};
const result = runPowerShell(spec.windowsRoute, desktopApplyScript(payload), 55000);
const result = runPowerShell(spec.windowsRoute, desktopApplyScript(payload), spec.runtime.applyTimeoutMs);
if (!commandSucceeded(result)) throw new Error(`部署 Windows HWPOD 节点失败:${compactFailure(result)}`);
const parsed = parseJsonRecord(result.stdout);
if (parsed?.ok !== true) throw new Error(`Windows HWPOD 节点部署未就绪:${JSON.stringify(parsed ?? { stdout: result.stdout.slice(-600) })}`);
@@ -730,6 +732,12 @@ function bool(value: unknown, path: string): boolean {
return value;
}
function positiveInteger(value: unknown, path: string): number {
const parsed = Number(value);
if (!Number.isInteger(parsed) || parsed < 1) throw new Error(`${path} 必须是正整数`);
return parsed;
}
function secretPath(sourceRef: string): string {
if (isAbsolute(sourceRef) || sourceRef.includes("..")) throw new Error(`Secret sourceRef 必须是相对路径且不能包含 ..:${sourceRef}`);
return join(SECRET_ROOT, sourceRef);