fix: 用 YAML 配置 HWLAB runtime store pool

This commit is contained in:
Codex
2026-06-20 00:02:08 +00:00
parent c9a5e2bede
commit 3533868a41
3 changed files with 31 additions and 0 deletions
+3
View File
@@ -139,6 +139,9 @@ lanes:
path: deploy/gitops/node/d601/runtime-v03
namespace: hwlab-v03
renderDir: runtime-v03
runtimeStore:
postgres:
poolMax: 20
tektonDir: tekton-v03
argoApplicationFile: application-v03.yaml
registryPrefix: 127.0.0.1:5000/hwlab
+6
View File
@@ -429,6 +429,7 @@ function nodeRuntimeExpected(spec: HwlabRuntimeLaneSpec): Record<string, unknown
valuesPrinted: false,
},
publicExposure: spec.publicExposure === null ? null : publicExposureSummary(spec.publicExposure),
runtimeStore: spec.runtimeStore ?? null,
downloadProfile: {
id: spec.downloadProfileId,
git: spec.downloadProfile.git,
@@ -3892,6 +3893,7 @@ function renderNodeRuntimeControlPlaneOnNode(spec: HwlabRuntimeLaneSpec, sourceC
" observability: overlay.observability,",
" envRecipe: { ...(lane.envRecipe || {}), downloadStack },",
"};",
"if (overlay.runtimeStore !== undefined) doc.lanes[overlay.lane].runtimeStore = overlay.runtimeStore;",
"fs.writeFileSync(path, YAML.stringify(doc));",
"NODE",
"if [ -f scripts/gitops-render.mjs ]; then render_script=scripts/gitops-render.mjs; else echo 'render script missing: scripts/gitops-render.mjs' >&2; exit 43; fi",
@@ -3974,6 +3976,7 @@ function renderNodeRuntimeControlPlaneLocal(spec: HwlabRuntimeLaneSpec, sourceCo
" observability: overlay.observability,",
" envRecipe: { ...(lane.envRecipe || {}), downloadStack },",
"};",
"if (overlay.runtimeStore !== undefined) doc.lanes[overlay.lane].runtimeStore = overlay.runtimeStore;",
"fs.writeFileSync(path, YAML.stringify(doc));",
"NODE",
"if [ -f scripts/gitops-render.mjs ]; then render_script=scripts/gitops-render.mjs; else echo 'render script missing: scripts/gitops-render.mjs' >&2; exit 43; fi",
@@ -4120,6 +4123,7 @@ function nodeRuntimePipelinePostprocessScript(): string[] {
" publicWebUrl: overlay.publicWebUrl,",
" publicApiUrl: overlay.publicApiUrl,",
" externalPostgres: overlay.externalPostgres,",
" runtimeStore: overlay.runtimeStore,",
" observability: overlay.observability,",
" runtimeImageRewrites: overlay.runtimeImageRewrites,",
" dockerProxyHttp: overlay.dockerProxyHttp,",
@@ -4168,6 +4172,7 @@ function nodeRuntimePipelinePostprocessScript(): string[] {
" observability: overlay.observability,",
" envRecipe: { ...envRecipe, downloadStack },",
"};",
"if (overlay.runtimeStore !== undefined) doc.lanes[overlay.lane].runtimeStore = overlay.runtimeStore;",
"fs.writeFileSync(file, YAML.stringify(doc));",
"console.error(JSON.stringify({ event: 'unidesk-deploy-yaml-overlay', ok: true, lane: overlay.lane, httpProxy: overlay.dockerProxyHttp, noProxyCount: overlay.dockerNoProxyList.length }));",
"NODE_UNIDESK_DEPLOY_YAML_OVERLAY`;",
@@ -4967,6 +4972,7 @@ function nodeRuntimeRenderOverlay(spec: HwlabRuntimeLaneSpec): Record<string, un
npmRetries: spec.downloadProfile.npm.retries,
stepEnv: spec.stepEnv,
observability: spec.observability,
runtimeStore: spec.runtimeStore,
runtimeImageRewrites: spec.runtimeImageRewrites,
registryPrefix: spec.registryPrefix,
buildkitSidecarImage: spec.buildkit?.sidecarImage,
+22
View File
@@ -79,6 +79,14 @@ export interface HwlabRuntimeExternalPostgresSpec {
readonly openfga: HwlabRuntimeExternalPostgresComponentSpec;
}
export interface HwlabRuntimePostgresStoreSpec {
readonly poolMax: number;
}
export interface HwlabRuntimeStoreSpec {
readonly postgres?: HwlabRuntimePostgresStoreSpec;
}
export interface HwlabRuntimeBuildkitSpec {
readonly sidecarImage: string;
}
@@ -216,6 +224,7 @@ export interface HwlabRuntimeLaneSpec {
readonly buildkit?: HwlabRuntimeBuildkitSpec;
readonly bootstrapAdmin?: HwlabRuntimeBootstrapAdminSpec;
readonly externalPostgres?: HwlabRuntimeExternalPostgresSpec;
readonly runtimeStore?: HwlabRuntimeStoreSpec;
readonly publicExposure: HwlabRuntimePublicExposureSpec | null;
readonly observability: HwlabRuntimeObservabilitySpec;
readonly runtimeImageRewrites: readonly HwlabRuntimeImageRewriteSpec[];
@@ -257,6 +266,7 @@ interface HwlabLaneConfig {
readonly buildkit?: HwlabRuntimeBuildkitSpec;
readonly bootstrapAdmin?: HwlabRuntimeBootstrapAdminSpec;
readonly externalPostgres?: HwlabRuntimeExternalPostgresSpec;
readonly runtimeStore?: HwlabRuntimeStoreSpec;
readonly publicExposure: HwlabRuntimePublicExposureSpec | null;
readonly observability: HwlabRuntimeObservabilitySpec;
readonly runtimeImageRewrites: readonly HwlabRuntimeImageRewriteSpec[];
@@ -474,6 +484,7 @@ function laneConfig(id: HwlabRuntimeLane, raw: Record<string, unknown>): HwlabLa
buildkit: buildkitConfig(raw.buildkit, `lanes.${id}.buildkit`),
bootstrapAdmin: bootstrapAdminConfig(raw.bootstrapAdmin, `lanes.${id}.bootstrapAdmin`),
externalPostgres: externalPostgresConfig(raw.externalPostgres, `lanes.${id}.externalPostgres`),
runtimeStore: runtimeStoreConfig(raw.runtimeStore, `lanes.${id}.runtimeStore`),
publicExposure: publicExposureConfig(raw.publicExposure, `lanes.${id}.publicExposure`),
observability: observabilityConfig(raw.observability, `lanes.${id}.observability`),
runtimeImageRewrites: runtimeImageRewritesConfig(raw.runtimeImageRewrites, `lanes.${id}.runtimeImageRewrites`),
@@ -493,6 +504,7 @@ function laneTargetConfig(id: HwlabRuntimeLane, nodeId: string, baseRaw: Record<
buildkit: mergeOptionalRecord(baseRaw.buildkit, targetRaw.buildkit),
bootstrapAdmin: mergeOptionalRecord(baseRaw.bootstrapAdmin, targetRaw.bootstrapAdmin),
externalPostgres: mergeOptionalRecord(baseRaw.externalPostgres, targetRaw.externalPostgres),
runtimeStore: mergeOptionalRecord(baseRaw.runtimeStore, targetRaw.runtimeStore),
publicExposure: mergeOptionalRecord(baseRaw.publicExposure, targetRaw.publicExposure),
observability: mergeOptionalRecord(baseRaw.observability, targetRaw.observability),
};
@@ -569,6 +581,15 @@ function externalPostgresConfig(value: unknown, path: string): HwlabRuntimeExter
};
}
function runtimeStoreConfig(value: unknown, path: string): HwlabRuntimeStoreSpec | undefined {
if (value === undefined) return undefined;
const raw = asRecord(value, path);
const postgres = raw.postgres === undefined ? undefined : asRecord(raw.postgres, `${path}.postgres`);
return {
...(postgres === undefined ? {} : { postgres: { poolMax: numberField(postgres, "poolMax", `${path}.postgres`) } }),
};
}
function publicExposureProxyConfig(value: unknown, path: string): HwlabRuntimePublicExposureFrpcProxySpec {
const raw = asRecord(value, path);
return {
@@ -823,6 +844,7 @@ function buildRuntimeLaneSpec(config: HwlabLaneConfig): HwlabRuntimeLaneSpec {
...(config.buildkit === undefined ? {} : { buildkit: config.buildkit }),
...(config.bootstrapAdmin === undefined ? {} : { bootstrapAdmin: config.bootstrapAdmin }),
...(config.externalPostgres === undefined ? {} : { externalPostgres: config.externalPostgres }),
...(config.runtimeStore === undefined ? {} : { runtimeStore: config.runtimeStore }),
publicExposure: config.publicExposure,
observability: config.observability,
runtimeImageRewrites: config.runtimeImageRewrites,