Open
fix(gateway): 可选渠道启动失败后关停仍以退出码 0 结束 #490
yechenzhenAdd on 1 day ago
fix(gateway): 可选渠道启动失败后关停仍以退出码 0 结束 #490
Open
Merge blocked
1 day ago Associated issue: 【Bug】writer 收尾吞掉调用方的取消信号(except (CancelledError, Exception): pass),[Bug]: 可选渠道启动失败后,Gateway 关停或重启会以崩溃码 70 退出
1 day ago Associated issue: 【Bug】writer 收尾吞掉调用方的取消信号(except (CancelledError, Exception): pass),[Bug]: 可选渠道启动失败后,Gateway 关停或重启会以崩溃码 70 退出
atomgit-bot
1 day ago Comments:
1 day ago Comments:
atomgit-bot
1 day ago Comments:
1 day ago Comments:
atomgit-bot
1 day ago Comments:
1 day ago Comments:
1 day ago Added label: sig/sig-agent-gateway
openJiuwen-bot
1 day ago Comments:
1 day ago Comments:
欢迎来到 openJiuwen 社区
Hey @yechenzhen , 感谢你对社区的贡献.
机器人使用手册
有关指令的使用,可以点击 此处 查看详情。开发人员可以在每个PR或Issue下方评论特定指令来触发机器人任务。
联系指引
有疑问可以联系 SIG: sig-agent-gateway ,
维护者是: @YiyangShao, @mingo007 ,
审核者是: @d-0771, @gcw_hx9prznZ, @yechenzhen, @yukuanj .


1 day ago Added label: openJiuwen-cla/yes
openJiuwen-bot
1 day ago Comments:
1 day ago Comments:
1 day ago Modify description of pull request
1 day ago Modify description of pull request
openJiuwen-bot
1 day ago Comments:
1 day ago Comments:
The pipeline(pipeline number:490) is running. Please wait a moment...


1 day ago Added label: ci-running
1 day ago Removed label: ci-running
1 day ago Added label: ci-successful
Paired: GitHub #707 ↔ GitCode !490
/kind bug
What does this PR do / why do we need it:
可选渠道的
start()因凭据无效或平台不可达抛错之后,Gateway 仍在运行,但之后每一次关停或重启都会以崩溃码 70 退出:services.stop()、遥测关停和restart_gateway()被跳过。完整分析见 #265,根因简述如下。OptionalChannels.stop_channels()对每个渠道任务都是cancel()后await,并且只兜CancelledError。任务早已因start()抛错而结束时,cancel()是空操作,await会把存着的异常重新抛出。这个调用位于run_single的finally中,异常一旦抛出,后面的关停步骤全部被跳过,最终被 crash handler 记成未处理异常。本 PR 新增
_await_channel_task_stopped(),把stop_channels()中 11 处相同的等待收敛到它,并采取与重配置路径_stop_channel()相同的策略:启动失败的异常在发生时已经记录,关停时只打一条 warning 并继续。保持不变的部分:停止顺序、各渠道
stop()的调用,以及CancelledError的处理(#131 所说的"吞掉本协程的取消"是另一个议题,本 PR 没有扩大范围)。修复前后对比(macOS,默认配置启用 telegram 且 token 无效;修复前为 develop
273533f91,修复后为本 PR):[App] Gateway stoppedos.execv原地重启对外可见的行为变化只有两处:
stop()。此前它被异常跳过;重配置路径本来就会调用它。[App] ignored exception while waiting for <渠道> channel task: ...。Which issue(s) this PR fixes:
Fixes #265
Test Plan and Test result:What scenarios were tested, and what were the verification results(Function, performance, reliability, etc.):
273533f91上全量 UT 7039 通过、6 跳过;本 PR 上全量 UT 7051 通过、6 跳过,新增 12 项,无失败。新增的 12 项在未修复的代码上全部失败。run_single级别的关停顺序(services.stop()与遥测关停仍然执行)。jiuwenswarm.app的process_supervision.supervise(),结果见上表。启动失败的形态覆盖了 token 被拒、连接超时和连接错误。8fc3c8774合并无冲突,合并结果上生命周期、装配与启动相关测试 107 项通过。start()抛错),其余渠道由单测中的假渠道覆盖。Self-checklist:(请自检,在[ ]内打上x,我们将检视你的完成情况,否则会导致pr无法合入)
Linked Closing Issues: