feat(ha): add production scaling signals and graceful gateway redistribution
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- helm, kubernetes, postgresql, rust
调研方向
Start with PR #1868 and its linked discussions on graceful redistribution, scaling metrics, advisory-lock serialization, and WatchSandbox polling. Trace the gateway lifecycle, supported metrics endpoint, Helm documentation, mutation locking, and cross-replica watch synchronization. Done means the acceptance criteria and load or integration tests cover all four production-scale behaviors.
由索引模型根据 Issue 内容生成。
描述
User Story
As an OpenShell cluster operator, I want multi-replica gateways to expose actionable capacity signals and redistribute supervisor ownership during planned changes, so that scaling and rolling upgrades do not leave one replica overloaded while new replicas remain idle.
Problem Statement
PR #1868 makes multi-replica gateway routing possible, but several production-scale behaviors remain incomplete:
- Supervisor ownership stays with the original connection. Rolling restarts and failover can leave the last surviving replica holding most sessions until sandboxes naturally reconnect.
- The gateway does not expose held-session, pending-relay, or peer-relay rate and latency metrics suitable for capacity planning or autoscaling.
- Cross-object mutations use one fleet-wide PostgreSQL advisory-lock key, so unrelated sandbox and provider mutations serialize across all replicas.
WatchSandboxperforms one database lookup per actively watched sandbox, per polling interval, per replica.
Impact / Why This Matters
Operators can add gateway replicas, but cannot tell when capacity is exhausted or rely on replicas receiving a balanced share of established supervisor sessions. The current workaround is to overprovision, manually inspect logs, and wait for sandbox churn or force reconnects after a rollout. That does not prevent pending-relay exhaustion, database amplification, or fleet-wide mutation contention at larger scale.
Proposed Design
Provide an observable, documented HA lifecycle with graceful draining and bounded shared-database load:
- A terminating gateway stops accepting new ownership, releases or transfers existing ownership, and prompts affected supervisors to reconnect before the termination grace period expires.
- Gateway metrics expose held supervisor sessions, pending relays versus capacity, and peer-relay request rate, failure rate, and latency.
- The Helm chart documents those signals and provides an optional autoscaling configuration, or a documented integration contract for a Kubernetes metrics adapter.
- Unrelated object mutations do not share one fleet-wide serialization point when their invariants cannot overlap.
- Cross-replica sandbox watches use a batched or notification-based mechanism whose database work does not grow as one query per watched sandbox on every replica.
Acceptance Criteria
- During a graceful gateway rollout, established supervisor ownership redistributes without waiting for natural sandbox churn, within the configured termination grace period.
- Operators can observe per-replica held sessions, pending relays/capacity, and peer-relay rate, failures, and latency through the supported metrics endpoint.
- The Helm documentation explains how to use these signals for horizontal scaling; any chart-provided HPA behavior is optional and configurable.
- Mutations for unrelated sandboxes or providers can proceed concurrently across replicas unless they share a documented cross-object invariant.
- Cross-replica watch synchronization avoids one database query per watched sandbox per interval per replica.
- Load or integration tests cover rollout redistribution, relay saturation signals, concurrent unrelated mutations, and large watch sets.
- HA architecture and Kubernetes operator documentation describe the lifecycle, capacity signals, and database-scaling behavior.
Alternatives Considered
Keeping ownership sticky is simple and preserves correctness, but leaves rollout skew entirely dependent on sandbox churn. Relying only on logs does not provide stable autoscaling inputs. Increasing the PostgreSQL connection pool masks neither fleet-wide lock serialization nor query amplification.
Agent Investigation
This groups the remaining production-scale review discussions from PR #1868:
- Graceful redistribution and sticky ownership: https://github.com/NVIDIA/OpenShell/pull/1868#discussion_r3945390329
- Scaling metrics and HPA signals: https://github.com/NVIDIA/OpenShell/pull/1868#discussion_r3945372631
- Fleet-wide advisory-lock serialization: https://github.com/NVIDIA/OpenShell/pull/1868#discussion_r3946935300
- Watch-poller query amplification: https://github.com/NVIDIA/OpenShell/pull/1868#discussion_r3952505962
Related umbrella issue: #1021.
- 主要语言
- Rust
- 星标
- 8.7k
- 派生
- 1.3k
- 平均合并
- 2 天 6 小时
- 30 天内合并 PR
- 297
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NVIDIA/OpenShell 的其他 Issue
-
area:docs
难度 1/5 1 小时以内 新手友好度 88/100
-
state:triage-needed
难度 2/5 1-3 小时 新手友好度 82/100
-
area:cli state:validated
难度 2/5 1-3 小时 新手友好度 72/100
-
state:triage-needed
难度 1/5 1 小时以内 新手友好度 90/100
-
area:build spike state:review-ready state:stale
难度 2/5 半天 新手友好度 68/100
相似的 Issue
-
bug github_actions
难度 2/5 1-3 小时 新手友好度 75/100
registrystack/registry-stack#1393 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
longbridge/gpui-kit#3223 ·
-
bug engine
难度 2/5 1-3 小时 新手友好度 65/100
rocky-data/rocky#2181 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
oasisprotocol/oasis-sdk#2523 ·
-
bot:ai-assisted component:indexer QA-roadmap status:untriaged
难度 2/5 1-3 小时 新手友好度 75/100
midnightntwrk/midnight-indexer#1557 ·