AlexStocks commented on code in PR #982:
URL: https://github.com/apache/dubbo-go-pixiu/pull/982#discussion_r4522106037
##########
pkg/cmd/gateway.go:
##########
@@ -78,9 +78,16 @@ var (
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
- err := deploy.start()
- if err != nil {
- return errors.Wrap(err, "failed to start
gateway")
+ startErr := deploy.start()
+ stopErr := deploy.stop()
Review Comment:
更正我上一条的定级:PR 正文的 "Upgrade and shutdown requirements" 已经明确写了 `Enable graceful
signal cleanup with a positive static_resources.shutdown_config.timeout. The
existing default 0s disables that signal handler.`,所以这属于已披露的设计取舍,不该按「遗漏」定级。降为
P2,只保留下面三点仍然成立的观察。
**1) 新增的关闭代码在默认配置下是死路径(与正文描述一致,记录可达性证据)**
`shutdown.RunHooks()` 全仓库只有一个调用点,位于 `gracefulShutdownInit` 里 `if timeout <=
0 { return }` 之后:
```go
timeout := sdc.GetTimeout() // ShutdownConfig.Timeout 默认 "0s"
if timeout <= 0 {
return
}
signals := make(chan os.Signal, 1)
signal.Notify(signals, shutdown.ShutdownSignals...)
```
未配置时 `GetShutdownConfig()` 使用 `Timeout: "0s"`(`pkg/model/bootstrap.go`),于是
`signal.Notify` 不执行 → `shutdown.RunHooks()` 不执行 → `RegisterHook` 注册的
`d.configManger.Close`(`pkg/cmd/gateway.go`)与
`s.adapterManager.Stop`(`pkg/server/pixiu_start.go`)都不执行。`pkg/cmd/gateway.go` 的
`deploy.stop()` 另一条路径也不可达(`server.Start` 尾部 `blockForever()` 不返回)。也就是说,本 PR 新增的
`CloseClient()`/`Close()` 调用只有在运维显式打开 timeout
时才会生效——这正是正文承诺的语义,但意味着默认部署下这批代码不产生任何效果。
**2) 文档承诺的行为没有测试钉子**
新增用例都在非零 timeout 下运行:`pkg/server/listener_manager_test.go` 用 `Timeout:
"1h"`,`pkg/cmd/gateway_shutdown_test.go` 用 `"2s"`。`timeout <= 0` 时「不注册信号处理器、不执行
hooks」这个被文档化的行为没有任何断言,后续调整 `gracefulShutdownInit` 的无人察觉地改变它。建议补一条 `Timeout:
"0s"` 的用例把现状钉住。
**3) `release-note` 块缺失(无法行内定位,仅记录)**
本仓库 `PULL_REQUEST_TEMPLATE.md` 要求把用户升级时需要额外操作的说明写进 ```release-note 块并含
`action required`;当前正文只有普通小节 "Upgrade and shutdown requirements",Nacos 2.x
端口要求与 timeout 前置条件不会出现在 release notes 里。这一项不在本行,我只在评审结论中记录,不在此展开。
**可选方向**:若希望 cleanup 默认生效,把 `signal.Notify` 与 `RunHooks()` 移出 `timeout <= 0`
判断,让 timeout 只约束排空等待上限;若维持现状,则至少补上面第 2 点的用例。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]