Aias00 opened a new pull request, #995:
URL: https://github.com/apache/dubbo-go-pixiu/pull/995
## Summary
Fixes #989 Issue 3 (admin config loading path): Replace panic/os.Exit with
proper error handling in admin config loading.
### Problem
The original implementation used panic and os.Exit in multiple places:
- `viper.go`: panic on config file read error
- `xds.go`: os.Exit(1) on startup validation failures
- `xds.go`: panic/os.Exit in background goroutine on runtime failures
### Changes in viper.go
- `Viper()` now returns `(*viper.Viper, error)` instead of panic on config
read error
- Update `server.go` caller to handle the error gracefully
### Changes in xds.go
- **Startup errors**: return error instead of os.Exit(1)
- config.Consistent() failure → return error
- snapshot.SetSnapshot() failure → return error
- **Background goroutine**: log and continue instead of exit
- WatchWithPrefix error → log and return (keep running)
- config reload errors → log and continue (keep previous valid config)
- **Invariant violation**: keep panic in makeHTTPFilter (true programming
error)
### Classification
| Location | Type | Classification | Fix |
|----------|------|----------------|-----|
| viper.go:59 | panic | Config/startup error | Return error |
| xds.go:95,101 | os.Exit | Config/startup error | Return error |
| xds.go:151,160,166 | panic/exit | Runtime failure | Log and continue |
| xds.go:207 | panic | True invariant | Keep |
### Why This Matters
Background goroutines should not exit the process directly. They should:
- Log errors and continue running with previous valid state
- Optionally signal for graceful shutdown
## Test Plan
- Build passes: `go build ./admin/...`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]