Aias00 commented on code in PR #994:
URL: https://github.com/apache/dubbo-go-pixiu/pull/994#discussion_r3568303563
##########
pkg/config/xds/xds.go:
##########
@@ -116,8 +126,13 @@ func (a *Xds) Start() {
// lds fetch just run on init phase.
if a.dynamicResourceMg.GetLds() != nil {
+ discoverApi := a.createApiManager(a.dynamicResourceMg.GetLds(),
a.dynamicResourceMg.GetNode(), constant.ListenerType)
+ if discoverApi == nil {
+ logger.Errorf("failed to create LDS API manager")
+ return
Review Comment:
已按 fail-fast 路线处理(commit `0c110d94`)。
**问题根因**:原 PR 把 panic 改成 `log+return` 后,整条调用链 `Xds.Start → StartXdsClient →
createDynamicResourceManger → Server.initialize → Start → deploy.start → CLI`
都没有 error 通道——`StartXdsClient` 只返回 `Client` 且被 `_ =` 丢弃,`deploy.start()` 无条件返回
`nil`,所以 xDS 失败时进程表现为成功存活,且 LDS 失败会 `return` 跳过 CDS 初始化。
**改动**(全链路返回 error,任一失败即启动失败、非零退出):
- `Xds.Start() error`:LDS/CDS **独立初始化**,各自失败用 `errors.Join` 合并返回,LDS 失败不再跳过
CDS。
- `createApiManager() (DiscoverApi, error)`:把失败原因(空 cluster / 不支持的 api type
/ 连接失败)作为 error 上抛,不再内部 log。
- `StartXdsClient() (Client, error)`、`createDynamicResourceManger() (DRM,
error)`(顺带去掉 `validate` 的 `panic`)、`Server.initialize() error`、`server.Start()
error`、`deploy.start()` 透传该 error。CLI 侧 `cobra Run` 已有 `panic(err)` → 非零退出。
**验证**:
- `go build/vet/test -race` 全绿,`gofmt`、`imports-formatter`(CI
门禁)、`golangci-lint` 0 issues。
- 新增 `TestAdapter_Start_LdsAndCdsIndependentErrors`:LDS 与 CDS 同时配置为空
cluster,断言 `Start()` 返回的 error 同时包含 `LDS` 和 `CDS`,证明 CDS 未被跳过。
- 端到端:`pixiu gateway start -c <指向不存在 cluster 的配置>` 现在退出码 2,输出 `panic: create
LDS api manager: ... \n\tcreate CDS api manager: ...`,而非继续存活。
降级路线未采用:xDS 不可达/配置缺失属于致命启动错误,fail-fast 比静默半残更符合预期;若后续需要 LDS/CDS 可独立降级,可在此
error 传播骨架上改为 per-resource 降级标记。
--
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]