mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-09 20:29:23 +02:00
hotfix(healthcheck): only fallback to plain dns if icmp is not permitted on the very first try
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user