Compare commits

..

1 Commits

Author SHA1 Message Date
Zhero & 助理 00154aafe6 fix(appconfig): 内嵌 tzdata,修 worker 在 alpine 镜像启动即退出
build / build (push) Successful in 2m13s
RECONCILIATION_TIMEZONE 默认 Asia/Shanghai,appconfig.Load 用 time.LoadLocation
校验具名时区;运行镜像 alpine 不带 /usr/share/zoneinfo,只有 api 因
internal/httpapi 顺带空白导入 time/tzdata 才通过,worker 与 release-worker
在候选/发布容器里启动即退出(unknown time zone Asia/Shanghai)。

在真正调用 LoadLocation 的包内嵌 time/tzdata,让校验不依赖基础镜像。
2026-12-01 17:16:15 +08:00
2 changed files with 7 additions and 22 deletions
+6
View File
@@ -8,6 +8,12 @@ import (
"strconv"
"strings"
"time"
// 运行镜像是 alpine,不带 /usr/share/zoneinfo;而本包在 Load 时就用
// time.LoadLocation 校验具名时区(RECONCILIATION_TIMEZONE 等)。只有嵌进
// 二进制才不依赖基础镜像:api 之前能过,纯粹是因为 internal/httpapi 顺带了
// 这个空白导入,worker / release-worker 没有,于是候选与发布容器的 worker
// 在启动时直接退出(unknown time zone Asia/Shanghai)。
_ "time/tzdata"
"knowledge-governance/internal/governance"
)
+1 -22
View File
@@ -366,30 +366,9 @@ def image_inspect(image):
return json.loads(run(['docker', 'image', 'inspect', image], 'read image identity'))[0]
def container_log_tail(name, lines=5, limit=400):
"""Give the failure text a symptom, not just a verdict.
A non-running container used to surface only as "expected container is not
running"; the actual cause (missing zoneinfo, refused DSN, bad bind) lives in
the container log and was thrown away with the container.
"""
try:
result = subprocess.run(['docker', 'logs', '--tail', str(lines), name], capture_output=True, timeout=15)
except (OSError, subprocess.TimeoutExpired):
return 'no container log'
# docker CLI forwards the container's stderr to its own stderr; keep both.
text = ' '.join((result.stdout + result.stderr).decode('utf-8', 'replace').split())
return text[-limit:] if text else 'no container log'
def inspect(name):
obj = json.loads(run(['docker', 'container', 'inspect', name], 'read running container'))[0]
state = obj.get('State') or {}
if state.get('Status') != 'running':
raise CDError(f'{name}: container is {state.get("Status") or "unknown"} '
f'(exit {state.get("ExitCode")}); log: {container_log_tail(name)}')
require(matches(IMAGE, obj.get('Image')),
f'{name}: running image {obj.get("Image")!r} is not an approved image ID')
require(obj['State']['Status'] == 'running' and matches(IMAGE, obj.get('Image')), 'expected container is not running')
return obj