为 complex 增加独立 BgFilter 熔断
为 flat 与 complex 分别维护熔断状态并补充双模式指标。 将统一熔断冷却默认值从五分钟降为两分钟。 为部署和 Provision 增加旧默认值定向迁移及门禁测试。 补充熔断状态隔离测试并同步架构、运维与项目决策文档。
This commit is contained in:
@@ -57,6 +57,7 @@ function main() {
|
||||
assertDeployRejectsNonLoopbackBgFilterListener();
|
||||
assertDeployRejectsMissingBgFilterWorkerCapacity();
|
||||
assertDeployMigratesOldDefaultBgFilterAdmissionLimit();
|
||||
assertDeployMigratesOldDefaultBgFilterCircuitCooldown();
|
||||
assertDeployRejectsInvalidBgFilterWorkerCapacity();
|
||||
assertDeployRejectsInlineBgFilterInternalToken();
|
||||
assertDeployRejectsEmptyBgFilterInternalToken();
|
||||
@@ -395,7 +396,12 @@ function assertDeployCopiesPingoraDirectReleaseDependencies() {
|
||||
assertIncludes(
|
||||
bgfilterEnvExample,
|
||||
'GENARRATIVE_EDITOR_BGFILTER_CIRCUIT_FAILURE_THRESHOLD=3',
|
||||
'BgFilter 专属 env 必须提供 flat 熔断阈值。',
|
||||
'BgFilter 专属 env 必须提供 flat / complex 统一熔断阈值。',
|
||||
);
|
||||
assertIncludes(
|
||||
bgfilterEnvExample,
|
||||
'GENARRATIVE_EDITOR_BGFILTER_CIRCUIT_COOLDOWN_SECONDS=120',
|
||||
'BgFilter 专属 env 必须提供 flat / complex 统一的 120 秒熔断冷却时间。',
|
||||
);
|
||||
for (const sharedKey of [
|
||||
'GENARRATIVE_BGFILTER_WORKER_CONCURRENCY=',
|
||||
@@ -1292,6 +1298,44 @@ function assertDeployMigratesOldDefaultBgFilterAdmissionLimit() {
|
||||
}
|
||||
}
|
||||
|
||||
function assertDeployMigratesOldDefaultBgFilterCircuitCooldown() {
|
||||
const fixture = prepareFixture('bgfilter-worker-migrate-old-default-circuit-cooldown');
|
||||
writeFileSync(
|
||||
fixture.bgfilterWorkerEnvFile,
|
||||
`${readFileSync(fixture.bgfilterWorkerEnvFile, 'utf8')}GENARRATIVE_EDITOR_BGFILTER_CIRCUIT_COOLDOWN_SECONDS=300\n`,
|
||||
'utf8',
|
||||
);
|
||||
|
||||
const result = runDeploy(fixture);
|
||||
if (result.status !== 0) {
|
||||
failures.push(`历史默认熔断 cooldown=300 迁移到 120 时部署不应失败:${result.stderr}`);
|
||||
return;
|
||||
}
|
||||
const migrated = readFileSync(fixture.bgfilterWorkerEnvFile, 'utf8');
|
||||
if (!/^GENARRATIVE_EDITOR_BGFILTER_CIRCUIT_COOLDOWN_SECONDS=120$/mu.test(migrated)) {
|
||||
failures.push('部署必须把历史模板默认熔断 cooldown=300 定向迁移为 120。');
|
||||
}
|
||||
if (/^GENARRATIVE_EDITOR_BGFILTER_CIRCUIT_COOLDOWN_SECONDS=300$/mu.test(migrated)) {
|
||||
failures.push('部署完成后不得继续保留历史模板默认熔断 cooldown=300。');
|
||||
}
|
||||
|
||||
const custom = prepareFixture('bgfilter-worker-preserve-custom-circuit-cooldown');
|
||||
writeFileSync(
|
||||
custom.bgfilterWorkerEnvFile,
|
||||
`${readFileSync(custom.bgfilterWorkerEnvFile, 'utf8')}GENARRATIVE_EDITOR_BGFILTER_CIRCUIT_COOLDOWN_SECONDS=90\n`,
|
||||
'utf8',
|
||||
);
|
||||
const customResult = runDeploy(custom);
|
||||
if (customResult.status !== 0) {
|
||||
failures.push(`自定义熔断 cooldown=90 时部署不应失败:${customResult.stderr}`);
|
||||
return;
|
||||
}
|
||||
const preserved = readFileSync(custom.bgfilterWorkerEnvFile, 'utf8');
|
||||
if (!/^GENARRATIVE_EDITOR_BGFILTER_CIRCUIT_COOLDOWN_SECONDS=90$/mu.test(preserved)) {
|
||||
failures.push('部署只能迁移历史默认熔断 cooldown=300,必须保留其它显式自定义值。');
|
||||
}
|
||||
}
|
||||
|
||||
function assertMissingReleaseManifestFails() {
|
||||
const fixture = prepareFixture('missing-release-manifest');
|
||||
rmSync(path.join(fixture.sourceDir, 'release-manifest.json'));
|
||||
|
||||
@@ -1691,6 +1691,13 @@ const checks = [
|
||||
reason:
|
||||
'Server-Provision 迁移历史默认值时必须读取最后一次有效赋值,不能覆盖后写的自定义运行态值。',
|
||||
},
|
||||
{
|
||||
file: 'scripts/jenkins-server-provision.sh',
|
||||
includes:
|
||||
'ensure_env_value_migrates_old_default "${BGFILTER_WORKER_ENV_FILE}" "GENARRATIVE_EDITOR_BGFILTER_CIRCUIT_COOLDOWN_SECONDS" "300" "120"',
|
||||
reason:
|
||||
'Server-Provision 必须把 BgFilter 熔断 cooldown 历史模板默认 300 定向迁移为 120,并保留其它显式定制值。',
|
||||
},
|
||||
{
|
||||
file: 'scripts/jenkins-server-provision.sh',
|
||||
includes: "root:genarrative:440",
|
||||
|
||||
@@ -497,7 +497,7 @@ ensure_bgfilter_worker_runtime_env_defaults() {
|
||||
# 其它显式定制值继续保留。
|
||||
ensure_env_value_migrates_old_default "${bgfilter_env_file}" "GENARRATIVE_BGFILTER_WORKER_MAX_REQUESTS" "128" "2048"
|
||||
ensure_env_value "${bgfilter_env_file}" "GENARRATIVE_EDITOR_BGFILTER_CIRCUIT_FAILURE_THRESHOLD" "3"
|
||||
ensure_env_value "${bgfilter_env_file}" "GENARRATIVE_EDITOR_BGFILTER_CIRCUIT_COOLDOWN_SECONDS" "300"
|
||||
ensure_env_value_migrates_old_default "${bgfilter_env_file}" "GENARRATIVE_EDITOR_BGFILTER_CIRCUIT_COOLDOWN_SECONDS" "300" "120"
|
||||
# N 已迁入共享 API env;worker 专属文件中的旧值会与共享值形成双写风险,直接移除。
|
||||
remove_env_key_if_present "${bgfilter_env_file}" "GENARRATIVE_BGFILTER_WORKER_CONCURRENCY"
|
||||
}
|
||||
|
||||
@@ -806,7 +806,7 @@ ensure_bgfilter_worker_runtime_env_defaults() {
|
||||
# 其它显式定制值继续保留。
|
||||
ensure_env_value_migrates_old_default "${BGFILTER_WORKER_ENV_FILE}" "GENARRATIVE_BGFILTER_WORKER_MAX_REQUESTS" "128" "2048"
|
||||
ensure_env_value "${BGFILTER_WORKER_ENV_FILE}" "GENARRATIVE_EDITOR_BGFILTER_CIRCUIT_FAILURE_THRESHOLD" "3"
|
||||
ensure_env_value "${BGFILTER_WORKER_ENV_FILE}" "GENARRATIVE_EDITOR_BGFILTER_CIRCUIT_COOLDOWN_SECONDS" "300"
|
||||
ensure_env_value_migrates_old_default "${BGFILTER_WORKER_ENV_FILE}" "GENARRATIVE_EDITOR_BGFILTER_CIRCUIT_COOLDOWN_SECONDS" "300" "120"
|
||||
}
|
||||
|
||||
bgfilter_internal_token_file_is_single_segment() {
|
||||
|
||||
Reference in New Issue
Block a user