mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-03-13 10:26:06 +00:00
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:
committed by
Cuong Manh Le
parent
4640a9f20a
commit
f3f16d904a
@@ -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 {
|
||||
|
||||
@@ -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 ""
|
||||
|
||||
Reference in New Issue
Block a user