hotfix(healthcheck): only fallback to plain dns if icmp is not permitted on the very first try

This commit is contained in:
Quentin McGaw
2025-12-24 02:57:50 +00:00
parent 2b0719225d
commit 0a0bb4cf71
+6 -5
View File
@@ -25,7 +25,7 @@ type Checker struct {
smallCheckType string smallCheckType string
configMutex sync.Mutex configMutex sync.Mutex
icmpNotPermitted bool icmpNotPermitted *bool
// Internal periodic service signals // Internal periodic service signals
stop context.CancelFunc stop context.CancelFunc
@@ -70,7 +70,7 @@ func (c *Checker) Start(ctx context.Context) (runError <-chan error, err error)
panic("call Checker.SetConfig with non empty values before Checker.Start") panic("call Checker.SetConfig with non empty values before Checker.Start")
} }
if c.icmpNotPermitted { if c.icmpNotPermitted != nil && *c.icmpNotPermitted {
// restore forced check type to dns if icmp was found to be not permitted // restore forced check type to dns if icmp was found to be not permitted
c.smallCheckType = smallCheckDNS c.smallCheckType = smallCheckDNS
} }
@@ -154,11 +154,12 @@ func (c *Checker) smallPeriodicCheck(ctx context.Context) error {
} }
ip := icmpTargetIPs[try%len(icmpTargetIPs)] ip := icmpTargetIPs[try%len(icmpTargetIPs)]
err := c.echoer.Echo(ctx, ip) err := c.echoer.Echo(ctx, ip)
if errors.Is(err, icmp.ErrNotPermitted) { if c.icmpNotPermitted == nil && errors.Is(err, icmp.ErrNotPermitted) {
c.icmpNotPermitted = true c.icmpNotPermitted = new(bool)
*c.icmpNotPermitted = true
c.smallCheckType = smallCheckDNS c.smallCheckType = smallCheckDNS
c.logger.Infof("%s; permanently falling back to %s checks", c.logger.Infof("%s; permanently falling back to %s checks",
smallCheckTypeToString(c.smallCheckType), err) err, smallCheckTypeToString(c.smallCheckType))
return c.dnsClient.Check(ctx) return c.dnsClient.Check(ctx)
} }
return err return err