fix(cli): avoid warning when HTTP log server is not yet available

Treat "socket missing" (ENOENT) and connection refused as expected when
probing the log server, and only log when the error indicates something
unexpected. This prevents noisy warnings when the log server has not
started yet.

Discover while doing captive portal tests.
This commit is contained in:
Cuong Manh Le
2026-02-03 23:06:16 +07:00
committed by Cuong Manh Le
parent 4640a9f20a
commit f3f16d904a
2 changed files with 11 additions and 1 deletions

View File

@@ -238,7 +238,7 @@ func run(appCallback *AppCallback, stopCh chan struct{}) {
// Test if HTTP log server is available
if err := hlc.Ping(); err != nil {
if !errConnectionRefused(err) {
if !errLogServerUnavailable(err) {
p.Warn().Err(err).Msg("Unable to ping log server")
}
} else {

View File

@@ -1209,6 +1209,16 @@ func errConnectionRefused(err error) bool {
return errors.Is(opErr.Err, syscall.ECONNREFUSED) || errors.Is(opErr.Err, windowsECONNREFUSED)
}
// errLogServerUnavailable reports whether err indicates the log server is not up yet
// (e.g. socket missing or connection refused). Callers should not log these as errors.
func errLogServerUnavailable(err error) bool {
var opErr *net.OpError
if !errors.As(err, &opErr) {
return false
}
return errors.Is(opErr.Err, syscall.ECONNREFUSED) || errors.Is(opErr.Err, syscall.ENOENT) || errors.Is(opErr.Err, windowsECONNREFUSED)
}
func ifaceFirstPrivateIP(iface *net.Interface) string {
if iface == nil {
return ""