Repository navigation
feat: add Helm chart for Kubernetes deployment - #1854
Conversation
|
@AlexStocks, could you take an initial look at the chart scope and the current The added CI job installs Helm, runs strict lint for the default and acceptance profiles, and runs quick rendering/configuration and acceptance-script unit tests. It does not run a real cluster. The workflow runs are currently awaiting maintainer approval ( This remains a draft because the concurrent DDL and authorization initialization fixes need to land separately. Feedback on the deployment design and scope would be helpful while that dependency is being prepared. |
AlexStocks
left a comment
There was a problem hiding this comment.
评审结论:修改后合入(未批准)
本轮为独立代码评审,不提交 APPROVE:存在三项待闭合项,其中两项属文档/测试层面的窄改动。
Chart 的工程质量高于同类贡献的平均水平:模板体积小且职责单一,所有失败路径都用 required/fail 快速失败,Secret 不进入 values,values.schema.json 严格,文档对限制的披露异常诚实。tests/test_helm_chart.py 把渲染出的 env 灌回真实 ServerSettings 复核,这一手法能真正拦住 env 拼写错误。
我实际复核过的内容
- 隔离镜像(
refs/pull/1854/head,15e62caf)解包后逐文件审读;base1f0afd6b对照。 pytest tests/test_helm_chart.py tests/test_helm_acceptance.py -q→ 22 passed(与正文一致);tests/test_ci_changes.py→ 50 passed;scripts/release_version.py --check→ exit 0。- 本机 Helm 3.17.3(正文用 3.19.0)跑默认与 acceptance 两套 values 的
--strictlint →0 chart(s) failed。 - 模板中 16 个环境变量逐个溯源到
ServerSettings(env_nested_delimiter="_")→ 16/16 可解析;曾怀疑的CURSOR_SIGNING_SECRET/SUPERVISOR_MODE/MAX_WORKERS/EXTERNAL_SKILLS都是派生名,不是拼写错误。 - 镜像契约:
docker/Dockerfile的 ENTRYPOINT/CMD、uid/gid 10001、/data、--extra cli --extra server与 Chart 完全一致。 - 就绪语义:
factory.py中 NOT_READY 返回 503,/health/live、/health/ready在 skip_paths 内免鉴权 → 探针可用。 db-migrate status/verify/plan/apply与文档所用全部旗标(--lock-coordination single-host、--shared-database、--plan-id、--backup-confirmed、--maintenance-confirmed、--yes)经 Typer 反射确认存在。
起决定作用的三点
- P1 集群验收证据不覆盖当前代码。 正文与
README.md的 Historical cluster evidence 都说明验收镜像是86537e4f+ 未提交的运行时补丁,而 Chart 的契约目标是1f0afd6b;README 自己写明该证据「predates the Atomic Memory and managed Server schemas……does not certify it」。K8s 层面真正新增的语义(1 个 API Pod 播种静态 Bearer 绑定、Recreate分阶段恢复、global 租约接管)在当前代码上没有集群证据。建议正文口径与 README 对齐,或补做一次针对本 head 的验收。 - P2
FASTMCP_STATELESS_HTTP是无效配置,而模板注释、README 与测试都建立了它不存在的因果(详见行内评论)。 - P2 跨副本游标签名键零验收覆盖——这是本 PR 的头号多副本主张,验收脚本却只做建/读 Scope、MCP initialize/ping 与租约查询,从不触发分页(详见行内评论)。
另有几条 P3(values.schema.json 封死 labels/annotations/securityContext 逃生口、无 PDB 与拓扑分布、Ingress tls 无 schema 约束、验收脚本缺确认门、无 NOTES.txt/.helmignore),不影响正确性但影响可运维性。
状态说明
52 个 check 当前 6 passed / 1 in progress / 45 queued,尚无失败结论;本评审不对 CI 绿红作任何断言,上述结论均来自本地可复现证据。master 已前进到 bf2ac1fcd(#1564),与本 PR 在 .github/ci-paths.toml、master.yml、tests/test_ci_changes.py 上有文件重叠,GitHub 判定 MERGEABLE。
AI 参与声明:本评审由 AI 辅助完成;每条结论均附可核查的文件与行号,未核实项已在正文与行内评论中标注。完整报告另存于本地隔离目录,未改动仓库任何文件。
| - name: POWERCONTEXT_SERVER_LOGGING_FORMAT | ||
| value: json | ||
| # Avoid process-local MCP sessions when traffic crosses API replicas. | ||
| - name: FASTMCP_STATELESS_HTTP |
There was a problem hiding this comment.
这个环境变量对 PowerContext 的 MCP 挂载点没有作用。
src/powercontext/server/mcp.py:602 已经硬编码:
mcp_app = mcp_server.http_app(path="/", stateless_http=True)显式传参优先于 fastmcp 的 Settings.stateless_http(fastmcp 3.4.4 settings.py:140,前缀 FASTMCP_),所以 FASTMCP_STATELESS_HTTP=true 无法改变行为——真正保证无进程内会话的是上面那行硬编码。
建议删除该 env 与对应的测试断言,把注释改为「MCP 由运行时以 stateless Streamable HTTP 挂载」;若希望 Chart 真正 pin 住该属性,需要运行时改为读配置(stateless_http=resolved.mcp.stateless),那属于另一个改动面。
功能上当前无故障:tests/e2e/helm_probe.py:67 确实断言了响应头里没有 mcp-session-id。问题在于注释、README 第 154 行与 tests/test_helm_chart.py:87 三方共同建立了一个错误的因果模型。
There was a problem hiding this comment.
Confirmed at 15e62caf7: mount_mcp explicitly passes stateless_http=True to http_app, so this environment variable does not control the mounted MCP transport. The transport currently works, but the template comment and README attribute that behavior to the wrong setting. Please remove the redundant environment entry and its environment-echo assertion, and document that the runtime mounts stateless Streamable HTTP. The existing probe that checks the absence of Mcp-Session-Id remains a meaningful behavioral check.
There was a problem hiding this comment.
已在 0518869 删除模板中的 FASTMCP_STATELESS_HTTP,并同步修正 README 与中英文部署说明。MCP 的 stateless Streamable HTTP 由运行时 http_app(..., stateless_http=True) 保证,Chart 不再把它描述为环境变量的效果。两位指出的因果问题均已覆盖;验收探针对 Mcp-Session-Id 响应头的行为检查仍保留。
| assert settings.cursor_signing_secret is not None | ||
| assert settings.cursor_signing_secret.get_secret_value() == secrets["cursor-signing-secret"] | ||
| assert settings.external_skills.targets == () | ||
| assert os.environ["FASTMCP_STATELESS_HTTP"] == "true" |
There was a problem hiding this comment.
这条断言是重言式:它只证明「测试进程里设置了这个变量」,不证明任何运行时行为,也无法在 FASTMCP_STATELESS_HTTP 变成无效配置时失败(src/powercontext/server/mcp.py:602 已硬编码 stateless_http=True)。
同文件 72-86 行把渲染出的 env 灌回 ServerSettings 的做法是本 PR 最有价值的测试设计,建议在这里沿用同一标准:要么删掉这条断言,要么改为断言真正可观察的属性。跨副本 MCP 的 stateless 性已经由 tests/e2e/helm_probe.py:67 在真实 Pod 内验证,不必在渲染测试里重复一个无法证伪的检查。
There was a problem hiding this comment.
已在 0518869 删除 os.environ["FASTMCP_STATELESS_HTTP"] == "true" 这条断言及对应的模板环境变量。渲染测试继续将真实环境配置加载到 ServerSettings;MCP 的 stateless 行为由现有 HTTP/MCP 探针检查,不再用环境变量回显代替运行时行为。
| kubectl("delete", "pods", "-l", selector + ",app.kubernetes.io/component=api", "--wait=true") | ||
| rollout("api") | ||
| execute({"base": base, "action": "read", "scope": scope["scope_id"]}) | ||
| for pod in ready_api_pods(): |
There was a problem hiding this comment.
这里按 Pod 逐个读回 Scope 是很好的设计,但它没有覆盖 Chart 的头号多副本主张:跨副本共享 cursor 签名键(values.yaml 的 cursorSigningSecret、README 第 33/154 行、PR 正文「share the cursor key across API replicas」)。
现状:helm_probe.py 的全部动作是 create / read / lease,没有任何一次分页调用;tests/test_helm_chart.py:84-85 只断言该 secret 能被解析。也就是说,一个把 cursor-signing-secret 配错的部署(src/powercontext/server/cursor_secret.py:39-51 在未配置时走持久化或随机密钥路径)当前验收脚本仍会全绿,而分页在多副本下已经坏了——builtin/persistence/tags.py:299-308 的 HMAC 校验会在另一个 Pod 上拒绝该游标。
建议的最小改动:在 helm_probe.py 增加 page 动作,以 limit=1 列出 Scope 取 next_cursor,然后在另一个 API Pod 上用该游标继续(本函数 130-131 行的循环已经提供了按 Pod 执行的能力,openapi/powercontext.yaml 中 /v1/scopes 等端点已带 cursor 参数)。这能把文档承诺变成可验证属性,且不增加集群依赖。
There was a problem hiding this comment.
已在 0518869 增加 page 探针和跨 Pod 游标验收:先创建一个独立父 Scope 与两个子 Scope,替换 API Pods 后,在第一个 API Pod 的 loopback 接口按 parent_scope_id、limit=1 获取 next_cursor,再将同一游标交给其余各 API Pod 续页,检查结果没有遗漏或重复。
本地测试还实际启动两个 Server 实例共用 SQLite 数据库,验证共享签名键可续页、不同签名键会让探针失败;kubectl 编排测试保证签发与消费游标的 Pod 不同。这里没有将这些本地测试视为集群证据:更新后的探针尚未在真实 Kubernetes/OceanBase 环境执行,PR 正文已明确该限制。
|
|
||
| `api.replicas` and `background.replicas` default to one. More background replicas are standby | ||
| candidates for the **global** database lease, not extra active supervisors. Each active supervisor | ||
| starts local workers, bounded by `background.maxWorkers`. Size memory for those child processes. |
There was a problem hiding this comment.
「bounded by background.maxWorkers」低估了活跃 supervisor 的子进程上限。
该值只映射到 POWERCONTEXT_SERVER_RUNTIME_ARTIFACT_PROCESSING_MAX_WORKERS(templates/deployments.yaml:106-107),并且在运行时还会通过别名同时改写 topic_memory_max_workers(builtin/runtime/config.py:105)。其余六个配额完全不受该值影响,保持默认(config.py:269-275):memory_max_workers=1、experience_max_workers=1、skill_max_workers=1、handoff_max_workers=1、prompt_max_workers=1、profile_max_workers=4。
因此默认 maxWorkers=2 时,上限估计约为 2 + 2 + 1 + 1 + 1 + 1 + 1 + 4 ≈ 13,而不是 2。按 2 估算内存会低估子进程数;resources.limits.memory: 2Gi 会以 OOMKilled 的形式暴露,排障成本较高。
建议改为「该值只设置 artifact-processing 与 topic-memory 两组配额,其余配额保持默认(合计约 13 个子进程上限)」。注:各配额是否并发占满取决于调度,上述是上限估计而非实测并发。
There was a problem hiding this comment.
Confirmed at 15e62caf7, with one correction to the proposed count: artifact_processing_max_workers is an alias of topic_memory_max_workers, not an additional worker pool. Rendering the chart with background.maxWorkers=2 and loading its environment into ServerSettings gives enabled-family quota sums of 8 for generation_model=test, and 11 for openai:gpt-4.1-mini (memory=1, topic-memory=2, experience=1, skill=1, handoff=1, prompt=1, profile=4). Without a generation model, no processing families are enabled.
ArtifactProcessingSupervisor._dispatch enforces each binding's quota independently, so the README's claim that all local workers are bounded by this chart value is incorrect. Please describe it as the Topic Memory quota and base sizing guidance on all enabled families. These are configured admission budgets, not observed simultaneous processes; this probe does not demonstrate an OOM.
There was a problem hiding this comment.
已在 0518869 将资源说明改为按启用的 family 配额估算,明确 background.maxWorkers 不是全局进程上限。
补充核实:artifact_processing_max_workers 是 topic_memory_max_workers 的兼容别名,运行时按 family 读取配额,因此不能将二者计为两个池。实际加载配置后,未配置生成模型时默认启用 0 个 family;test 模型启用四个 family、配额合计 8;openai:gpt-4.1-mini 启用七个 family、配额合计 11(maxWorkers=2)。README 与中英文说明已写明这些条件,并区分配置配额、实际并发和内存容量;未声称已观察到 OOM。
| { | ||
| "$schema": "https://json-schema.org/draft-07/schema#", | ||
| "type": "object", | ||
| "additionalProperties": false, |
There was a problem hiding this comment.
顶层 additionalProperties: false 与各子对象的同类约束一起封死了所有运维逃生口:无法注入额外 labels/annotations(成本分摊、GitOps 工具链)、podAnnotations(如 prometheus.io/scrape)、securityContext 覆盖或 PDB。
具体阻塞场景在 templates/deployments.yaml:46-52:runAsUser/runAsGroup/fsGroup 硬编码为 10001。OpenShift 一类由 SCC 分配随机 UID 的集群会直接拒绝该 Pod,而 Chart 没有任何覆盖入口,只能 fork。
另外此处强度不一致:ingress 被声明为裸 {"type": "object"}(106-108 行),而其它段都有字段级约束,ingress.tls 因此完全没有校验(畸形输入要等到 kubectl apply 才报错)。
建议至少提供 commonLabels、podAnnotations、securityContext/podSecurityContext 三个受 schema 约束的可选覆盖,并把 ingress.tls 约束为 array<{secretName: string, hosts?: string[]}>;若明确不打算支持,请在 README 中声明该边界。
There was a problem hiding this comment.
已在 0518869 增加受 schema 约束的 commonLabels、podAnnotations、podSecurityContext 和容器 securityContext。默认安全配置保持在 values 中,可用 Helm 的 null 覆盖移除固定 runAsUser/runAsGroup/fsGroup,让集群准入分配身份。额外标签不会进入 selector,Chart 自身的身份标签禁止覆盖。
同时补齐 Ingress 字段、字符串 annotations 和 tls: array<{secretName: string, hosts?: string[]}> 的校验,并加入合法渲染、固定 UID/GID 移除及畸形输入拒绝测试。README 明确 PDB 与 topology-spread constraints 的外部管理边界;OpenShift 实际准入与卷权限仍需由目标集群验证。
移除无效 MCP 环境变量及对应断言,补充跨 Pod 游标续页验收和显式测试确认。增加标签、注解、安全上下文与 Ingress TLS 校验,修正 worker 配额及历史集群证据说明。
|
已推送修复提交 0518869,并逐一回复五个行内评审线程。 关于总评中的集群证据问题,PR 正文现已与 README 对齐:2026-10-05 的镜像基于旧运行时和未发布补丁,该结果不证明当前 managed Server/Atomic Memory 初始化、单 API 播种 Access 绑定、分阶段恢复或新增跨 Pod 分页验收通过。当前版本的目标镜像仍需单独执行真实集群验收,本次没有补跑或将本地测试计作集群证据。 本地已完成相关测试、Helm 3.19.0 严格 lint、完整 make check 与 make docs-test。新增验收脚本要求显式 --confirm-disposable;worker 配额说明也已区分未配置模型、test 模型和七个 family 全启用的情况。正在检查新 head 的 CI。 |
|
Re-reviewed The remaining merge gate is the failed The documented distinction between local tests and outstanding real-cluster acceptance is appropriate; the historical patched image does not validate the current deployment sequence. |
合并最新 master,补齐 evaluation 锁文件中缺失的 resource-build 元数据,保持 130 个包的版本不变。验证 uv 0.10.12 锁定检查、make check、evaluation 与 Helm 相关回归测试。
|
evaluation 锁文件阻塞已通过 f092154 同步修复。最新 master 已用 CI 固定的 uv 0.10.12 / Python 3.12 复现旧锁文件失败,并确认同步后 新 head 的 Main CI 已触发,目前仍在等待执行,尚未宣称远端 CI 全绿。 |
Which issue or RFC does this PR close?
Related to #1609.
Rationale for this change
PowerContext supports separate API and background processes with OceanBase. This PR adds a Helm chart and deployment guide for those roles against an externally managed OceanBase database.
What changes are included in this PR?
Are there any user-facing changes?
Chart version 0.1.0 targets the role/configuration and managed Server contracts inspected at application revision
1f0afd6b. Operators must build and supply the exact application image they intend to deploy; no public image is assumed. SQLite and embedded seekdb are outside this chart's scope.Background replicas are standby candidates for one active supervisor.
background.maxWorkerssets the Topic Memory quota through a legacy alias; it is not a global process limit. With maxWorkers=2, all seven enabled built-in family quotas sum to 11 workers; the acceptance profile's test model enables four families with quotas totaling eight. Without a generation model, no families are enabled by default. Actual occupancy depends on capabilities and scheduling. Background health requires lease renewal, logs and durable processing progress.Current initialization, staged startup, Pod replacement and lease takeover still require real-cluster validation with the target application image. The historical cluster run below does not establish that acceptance.
How was this change tested?
Local verification of commit
0518869ff3c5f97e8da8f3fa983a20ebadb12accon Python 3.12.13:uv run --locked --extra server pytest tests/test_helm_chart.py tests/test_helm_acceptance.py tests/test_ci_changes.py -q— 85 passed: 35 Helm/acceptance tests and 50 CI path-selection tests.ServerSettings. They cover metadata, fixed UID/GID removal, security overrides, TLS rendering and malformed configuration rejection.make checkpassed, including all pre-commit hooks, type checks, release/API consistency checks, upgrade policy and integration checks.git diff --checkpassed.make docs-testpassed: website lint, tests, static build and verification of 997 public pages and internal links. No new real-cluster acceptance run was performed.Historical evidence only: on 2026-10-05, an isolated RKE2/OceanBase run checked authenticated HTTP/MCP, unauthenticated 401 responses, Scope readback from replacement API Pods and background lease takeover. It used Kubernetes
v1.35.7+rke2r1, Helm 3.19.0, OceanBase CE 4.4.2.1 and the local test generation model. The application base was86537e4fbe2f3bec2d0a93c73caea4ec8ebaec24with an unpublished local concurrent-startup patch. That image predates Atomic Memory and managed Server schemas, and did not test cross-Pod pagination. It does not certify current initialization, staged startup, coordinated upgrades or the target image.AI usage statement
OpenAI Codex assisted with the implementation, review-comment investigation, documentation and local verification. The validation scope and outstanding real-cluster acceptance are stated above.