From cf756f561ab32cb89635a1ed5c7565c0bcbb6ce4 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Tue, 21 Oct 2025 18:42:33 +0000 Subject: [PATCH] feat(health): info log when healthcheck passes after failure for the case of `HEALTH_VPN_RESTART=off` --- internal/vpn/tunnelup.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/vpn/tunnelup.go b/internal/vpn/tunnelup.go index 49ebd423..803ee958 100644 --- a/internal/vpn/tunnelup.go +++ b/internal/vpn/tunnelup.go @@ -75,6 +75,11 @@ func (l *Loop) onTunnelUp(ctx, loopCtx context.Context, data tunnelUpData) { l.logger.Error(err.Error()) } + l.collectHealthErrors(ctx, loopCtx, healthErrCh) +} + +func (l *Loop) collectHealthErrors(ctx, loopCtx context.Context, healthErrCh <-chan error) { + var previousHealthErr error for { select { case <-ctx.Done(): @@ -82,6 +87,10 @@ func (l *Loop) onTunnelUp(ctx, loopCtx context.Context, data tunnelUpData) { return case healthErr := <-healthErrCh: l.healthServer.SetError(healthErr) + if previousHealthErr != nil && healthErr == nil { + l.logger.Info("healthcheck passed successfully after previous failure(s)") + continue + } if healthErr != nil { if *l.healthSettings.RestartVPN { // Note this restart call must be done in a separate goroutine @@ -93,6 +102,7 @@ func (l *Loop) onTunnelUp(ctx, loopCtx context.Context, data tunnelUpData) { l.logger.Warnf("healthcheck failed: %s", healthErr) l.logger.Info("👉 See https://github.com/qdm12/gluetun-wiki/blob/main/faq/healthcheck.md") } + previousHealthErr = healthErr } } }