fix(health): correct docker fallback url

This commit is contained in:
yusing
2026-01-16 14:09:07 +08:00
parent 1e567bc950
commit 9d6e3fdc87
2 changed files with 7 additions and 2 deletions

View File

@@ -26,6 +26,8 @@ type (
config types.HealthCheckConfig config types.HealthCheckConfig
url synk.Value[*url.URL] url synk.Value[*url.URL]
onUpdateURL func(url *url.URL)
status synk.Value[types.HealthStatus] status synk.Value[types.HealthStatus]
lastResult synk.Value[types.HealthCheckResult] lastResult synk.Value[types.HealthCheckResult]
@@ -151,6 +153,9 @@ func (mon *monitor) UpdateURL(url *url.URL) {
return return
} }
mon.url.Store(url) mon.url.Store(url)
if mon.onUpdateURL != nil {
mon.onUpdateURL(url)
}
} }
// URL implements HealthChecker. // URL implements HealthChecker.

View File

@@ -97,7 +97,7 @@ func NewDockerHealthMonitor(config types.HealthCheckConfig, client *docker.Share
isFirstFailure := true isFirstFailure := true
var mon monitor var mon monitor
mon.init(displayURL, config, func(u *url.URL) (result Result, err error) { mon.init(displayURL, config, func(_ *url.URL) (result Result, err error) {
result, err = healthcheck.Docker(mon.Context(), state, config.Timeout) result, err = healthcheck.Docker(mon.Context(), state, config.Timeout)
if err != nil { if err != nil {
if isFirstFailure { if isFirstFailure {
@@ -106,11 +106,11 @@ func NewDockerHealthMonitor(config types.HealthCheckConfig, client *docker.Share
logger.Err(err).Msg("docker health check failed, using fallback") logger.Err(err).Msg("docker health check failed, using fallback")
} }
} }
fallback.UpdateURL(u)
return fallback.CheckHealth() return fallback.CheckHealth()
} }
return result, nil return result, nil
}) })
mon.onUpdateURL = fallback.UpdateURL
return &mon return &mon
} }