AlexStocks commented on code in PR #982:
URL: https://github.com/apache/dubbo-go-pixiu/pull/982#discussion_r4505147838


##########
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:
   🟡 **`stop()` 在正常关闭路径上永远执行不到,Nacos v2 的 `Close()` 实际不会被调用。**
   
   看调用链:
   
   ```go
   RunE: func(...) error {
       startErr := deploy.start()   // -> server.Start(bs) -> blockForever() = 
select{}
       stopErr := deploy.stop()     // 只有 start 返回之后才会执行
       ...
   }
   ```
   
   `blockForever`(`pkg/server/pixiu_start.go:37`)是 `select 
{}`,正常运行时永不返回;进程退出走的是 `ListenerManager.gracefulShutdownInit` 里的 
`os.Exit(...)`,而 `os.Exit` 会跳过所有 `defer`。所以 `stop()` 只在「启动失败」这一种情况下被调用。
   
   也就是说:`ConfigManager.Close()` → `nacos.Client.CloseClient()` 
这条链在网关正常下线时不会执行。这不影响正确性(进程退出后连接由内核回收),但它与 PR 描述里的 "release naming/config 
clients during shutdown" 以及新加的 `TestConfigManager_Close` 是脱节的——后者证明的是「Close 
会转发」,不是「关闭时会调 Close」。
   
   真正的收口点在 `handleShutdownSignal` 之后。而这恰好是 PR #993 
正在改造的那段代码(`pkg/server/listener_manager.go`),两者可以配合:
   
   ```go
   // after listeners drained, before os.Exit
   if closer, ok := any(cfgManager).(interface{ Close() }); ok {
       closer.Close()
   }
   os.Exit(shutdownExitCode(shutdownErrors, timedOut))
   ```
   
   或者退一步:先把 PR 描述里那句话改成「在启动失败路径上释放」,等 #993 合入后再补正常关闭路径。



##########
pkg/config/config_load.go:
##########
@@ -278,6 +278,18 @@ func (m *ConfigManager) ViewRemoteConfig() 
*model.Bootstrap {
        return m.load.ViewRemoteConfig()
 }
 
+// Close releases the remote config-center client (e.g. the Nacos v2 gRPC
+// connection). It is intended for the gateway shutdown path and is a no-op
+// when no remote config center is configured. See AlexStocks' [P1] review on

Review Comment:
   💭 生产代码注释里引用了 reviewer 名字和 PR 号:
   
   ```go
   // ... See AlexStocks' [P1] review on PR #982: the migrated v2 clients must 
be closed ...
   ```
   
   建议只保留「为什么」,去掉「谁在哪个 PR 说的」。理由:注释会跟着代码活很久,评审上下文(人名、PR 
号、当时的编号体系)很快会失效;对后来的读者来说这行文本不提供任何可执行信息。可以写成:
   
   ```go
   // Close releases the remote config-center client (e.g. the Nacos v2 gRPC
   // connection and its internal retry goroutines). It is safe to call when no
   // remote config center is configured.
   ```
   
   同样的建议也适用于 `config_load_test.go` 里的 "See AlexStocks' [P1] review on PR #982"。



##########
.github/workflows/nacos-v2.yml:
##########
@@ -0,0 +1,64 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+name: Nacos v2 Integration
+
+on:
+  pull_request:

Review Comment:
   💭 这个工作流只在 `pull_request` + path filter 下触发,而 `TestNacosV2Integration` 在常规 
Unit Test job 里因为没有 `NACOS_TEST_ADDRESS` 是 **skip** 的。两个后果:
   
   1. develop 上的回归不会被这条流水线发现(`push` 分支没有触发)。如果要低成本兜住,加一个 `push: {branches: 
[develop]}` + 同样的 path filter 即可。
   2. 如果哪天有人重命名/删除 `TestNacosV2Integration`,`-run '^TestNacosV2Integration$'` 
会匹配不到任何用例,`go test` 仍以 exit 0 结束(只打印 "no tests to run"),这条唯一覆盖 v2 的 CI 就静默失效了。
   
   建议显式断言「真的跑了」:
   
   ```yaml
   - name: Verify registration and discovery through Nacos v2 gRPC
     run: |
       go test ./pkg/remote/nacos -run '^TestNacosV2Integration$' -race 
-count=1 -timeout=90s -v | tee /tmp/nacos.log
       grep -q -- '--- PASS: TestNacosV2Integration' /tmp/nacos.log
   ```



-- 
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]

Reply via email to