From f3f16d904a83f30d2b4d6d2c2a9af14d53183a68 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Tue, 3 Feb 2026 23:06:16 +0700 Subject: [PATCH] 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. --- cmd/cli/cli.go | 2 +- cmd/cli/prog.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/cli/cli.go b/cmd/cli/cli.go index d014f9a..5544bc1 100644 --- a/cmd/cli/cli.go +++ b/cmd/cli/cli.go @@ -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 { diff --git a/cmd/cli/prog.go b/cmd/cli/prog.go index d511790..67d3a95 100644 --- a/cmd/cli/prog.go +++ b/cmd/cli/prog.go @@ -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 ""