fix(workbench): bound runtime db pool from yaml (#1920)

This commit is contained in:
Lyon
2026-06-22 20:35:38 +08:00
committed by GitHub
parent bdca364391
commit a0b3d310d3
3 changed files with 48 additions and 4 deletions
+18
View File
@@ -391,10 +391,28 @@
"workbenchRuntime": {
"type": "object",
"properties": {
"client": { "$ref": "#/$defs/workbenchRuntimeClient" },
"postgres": { "$ref": "#/$defs/workbenchRuntimePostgres" },
"cache": { "$ref": "#/$defs/workbenchRuntimeCache" }
},
"additionalProperties": false
},
"workbenchRuntimeClient": {
"type": "object",
"properties": {
"timeoutMs": { "type": "integer", "minimum": 1 }
},
"additionalProperties": false
},
"workbenchRuntimePostgres": {
"type": "object",
"properties": {
"poolMax": { "type": "integer", "minimum": 1 },
"queryTimeoutMs": { "type": "integer", "minimum": 1 },
"readyTimeoutMs": { "type": "integer", "minimum": 1 }
},
"additionalProperties": false
},
"workbenchRuntimeCache": {
"type": "object",
"properties": {
+6 -4
View File
@@ -307,6 +307,12 @@ lanes:
queryRetryInitialDelayMs: 250
queryRetryMaxDelayMs: 5000
workbenchRuntime:
client:
timeoutMs: 4500
postgres:
poolMax: 4
queryTimeoutMs: 4500
readyTimeoutMs: 2000
cache:
redis:
enabled: true
@@ -557,7 +563,6 @@ lanes:
HWLAB_BOOTSTRAP_ADMIN_API_KEY: secretRef:hwlab-v03-master-server-admin-api-key/api-key
HWLAB_USER_BILLING_URL: http://hwlab-user-billing.hwlab-v03.svc.cluster.local:6670
HWLAB_WORKBENCH_RUNTIME_URL: http://hwlab-workbench-runtime.hwlab-v03.svc.cluster.local:6671
HWLAB_WORKBENCH_RUNTIME_TIMEOUT_MS: "1800"
HWLAB_WORKBENCH_FACTS_QUERY_MAX_ATTEMPTS: "2"
HWLAB_WORKBENCH_FACTS_QUERY_BACKOFF_BASE_MS: "120"
HWLAB_WORKBENCH_FACTS_QUERY_BACKOFF_MAX_MS: "250"
@@ -588,9 +593,6 @@ lanes:
env:
HWLAB_WORKBENCH_RUNTIME_DB_URL: secretRef:hwlab-cloud-api-v03-db/database-url
HWLAB_WORKBENCH_RUNTIME_PORT: "6671"
HWLAB_WORKBENCH_RUNTIME_DB_POOL_MAX: "32"
HWLAB_WORKBENCH_RUNTIME_QUERY_TIMEOUT_MS: "1500"
HWLAB_WORKBENCH_RUNTIME_READY_TIMEOUT_MS: "2000"
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: http://otel-collector.platform-infra.svc.cluster.local:4318/v1/traces
OTEL_SERVICE_NAME: hwlab-workbench-runtime
- serviceId: hwlab-user-billing
+24
View File
@@ -939,6 +939,8 @@ function deployServicesForProfile(deploy, profile) {
copy.env,
serviceDeclarationEnvForProfile(deploy, profile, service.serviceId),
runtimeStoreEnvForProfile(deploy, profile, service.serviceId),
workbenchRuntimeClientEnvForProfile(deploy, profile, service.serviceId),
workbenchRuntimePostgresEnvForProfile(deploy, profile, service.serviceId),
workbenchRuntimeRedisEnvForProfile(deploy, profile, service.serviceId)
);
return [service.serviceId, copy];
@@ -952,6 +954,8 @@ function deployServicesForProfile(deploy, profile) {
env: mergeEnvMaps(
serviceDeclarationEnvForProfile(deploy, profile, override.serviceId),
runtimeStoreEnvForProfile(deploy, profile, override.serviceId),
workbenchRuntimeClientEnvForProfile(deploy, profile, override.serviceId),
workbenchRuntimePostgresEnvForProfile(deploy, profile, override.serviceId),
workbenchRuntimeRedisEnvForProfile(deploy, profile, override.serviceId)
)
};
@@ -1049,6 +1053,26 @@ function workbenchRuntimeRedisEnvForProfile(deploy, profile, serviceId) {
return env;
}
function workbenchRuntimeClientEnvForProfile(deploy, profile, serviceId) {
if (!isRuntimeLane(profile) || serviceId !== "hwlab-cloud-api") return {};
const client = runtimeLaneConfig(deploy, profile)?.workbenchRuntime?.client;
if (!client || typeof client !== "object" || Array.isArray(client)) return {};
const env = {};
if (Number.isInteger(client.timeoutMs)) env.HWLAB_WORKBENCH_RUNTIME_TIMEOUT_MS = String(client.timeoutMs);
return env;
}
function workbenchRuntimePostgresEnvForProfile(deploy, profile, serviceId) {
if (!isRuntimeLane(profile) || serviceId !== "hwlab-workbench-runtime") return {};
const postgres = runtimeLaneConfig(deploy, profile)?.workbenchRuntime?.postgres;
if (!postgres || typeof postgres !== "object" || Array.isArray(postgres)) return {};
const env = {};
if (Number.isInteger(postgres.poolMax)) env.HWLAB_WORKBENCH_RUNTIME_DB_POOL_MAX = String(postgres.poolMax);
if (Number.isInteger(postgres.queryTimeoutMs)) env.HWLAB_WORKBENCH_RUNTIME_QUERY_TIMEOUT_MS = String(postgres.queryTimeoutMs);
if (Number.isInteger(postgres.readyTimeoutMs)) env.HWLAB_WORKBENCH_RUNTIME_READY_TIMEOUT_MS = String(postgres.readyTimeoutMs);
return env;
}
function workbenchRuntimeRedisConfigForProfile(deploy, profile) {
if (!isRuntimeLane(profile)) return null;
const label = `deploy.lanes.${profile}.workbenchRuntime.cache.redis`;