支持自动故障转移的原子化非交互恢复 - #401
Draft
wplct wants to merge 2 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
非交互环境中没有安全的单命令方式同时启动 proxy worker 和自动故障转移。若脚本先执行
proxy enable、再执行failover enable,worker 第一次接管发生在auto_failover_enabled落库之前,存在按手动模式处理 live 配置的中间窗口。同时,
failover enable在需要 bootstrap proxy 时会显示交互确认,无法直接用于 systemdExecStartPost或自动化脚本。修复
failover enable增加--yes,仅跳过 proxy bootstrap 确认;默认交互行为保持不变。(enabled=true, auto_failover_enabled=true),使 worker 第一次 takeover 就按自动故障转移语义运行。EnsureWorker返回错误后先对账 daemon worker 与 live takeover 状态:DropTakeover补偿;测试
failover enable默认yes=false。failover enable --yes正确解析为非交互确认。部署说明
本 PR 不提交任何 systemd unit。部署方可以在 binary 更新后使用:
ExecStartPost=/path/to/cc-switch --app codex failover enable --yesProblem
There is no safe single-command path for starting both the proxy worker and automatic failover in a non-interactive environment. Running
proxy enablefollowed byfailover enablecreates an intermediate window where the worker performs its first takeover beforeauto_failover_enabledis persisted, so the live configuration may be handled with manual-takeover semantics.In addition,
failover enableprompts for confirmation when proxy bootstrap is required, preventing direct use from systemdExecStartPostand automation scripts.Fix
failover enable --yes, which only skips the proxy-bootstrap confirmation. Default interactive behavior remains unchanged.(enabled=true, auto_failover_enabled=true)before starting the daemon worker, so its first takeover uses automatic-failover semantics.EnsureWorkererror:DropTakeovercompensation only when a worker exists but takeover did not complete;Tests
failover enabledefaults toyes=false.failover enable --yesparses as non-interactive confirmation.Deployment note
This PR does not add or modify a systemd unit. Deployments may use the following after updating the binary:
ExecStartPost=/path/to/cc-switch --app codex failover enable --yes