Merge branch 'main' into feat/agent-stream-rebased

This commit is contained in:
yusing
2026-01-09 00:42:48 +08:00
4 changed files with 9 additions and 5 deletions

View File

@@ -35,7 +35,7 @@ func NewDockerHealthcheckState(client *docker.SharedClient, containerId string)
} }
} }
func Docker(ctx context.Context, state *DockerHealthcheckState, containerId string, timeout time.Duration) (types.HealthCheckResult, error) { func Docker(ctx context.Context, state *DockerHealthcheckState, timeout time.Duration) (types.HealthCheckResult, error) {
if state.numDockerFailures > dockerFailuresThreshold { if state.numDockerFailures > dockerFailuresThreshold {
return types.HealthCheckResult{}, ErrDockerHealthCheckFailedTooManyTimes return types.HealthCheckResult{}, ErrDockerHealthCheckFailedTooManyTimes
} }
@@ -44,7 +44,7 @@ func Docker(ctx context.Context, state *DockerHealthcheckState, containerId stri
defer cancel() defer cancel()
// the actual inspect response is intercepted and returned as RequestInterceptedError // the actual inspect response is intercepted and returned as RequestInterceptedError
_, err := state.client.ContainerInspect(ctx, containerId, client.ContainerInspectOptions{}) _, err := state.client.ContainerInspect(ctx, state.containerId, client.ContainerInspectOptions{})
var interceptedErr *httputils.RequestInterceptedError var interceptedErr *httputils.RequestInterceptedError
if !httputils.AsRequestInterceptedError(err, &interceptedErr) { if !httputils.AsRequestInterceptedError(err, &interceptedErr) {

View File

@@ -106,6 +106,11 @@ func processHealthResponse(lat time.Duration, err error, getStatusCode func() in
Detail: err.Error(), Detail: err.Error(),
}, nil }, nil
} }
return types.HealthCheckResult{
Latency: lat,
Healthy: true,
Detail: tlsErr.Error(),
}, nil
} }
statusCode := getStatusCode() statusCode := getStatusCode()

View File

@@ -42,7 +42,7 @@ type (
var ErrNegativeInterval = gperr.New("negative interval") var ErrNegativeInterval = gperr.New("negative interval")
func (mon *monitor) init(u *url.URL, cfg types.HealthCheckConfig, healthCheckFunc HealthCheckFunc) *monitor { func (mon *monitor) init(u *url.URL, cfg types.HealthCheckConfig, healthCheckFunc HealthCheckFunc) {
if state := config.WorkingState.Load(); state != nil { if state := config.WorkingState.Load(); state != nil {
cfg.ApplyDefaults(state.Value().Defaults.HealthCheck) cfg.ApplyDefaults(state.Value().Defaults.HealthCheck)
} else { } else {
@@ -60,7 +60,6 @@ func (mon *monitor) init(u *url.URL, cfg types.HealthCheckConfig, healthCheckFun
} else { } else {
mon.url.Store(u) mon.url.Store(u)
} }
return nil
} }
func (mon *monitor) Context() context.Context { func (mon *monitor) Context() context.Context {

View File

@@ -98,7 +98,7 @@ func NewDockerHealthMonitor(config types.HealthCheckConfig, client *docker.Share
var mon monitor var mon monitor
mon.init(displayURL, config, func(u *url.URL) (result Result, err error) { mon.init(displayURL, config, func(u *url.URL) (result Result, err error) {
result, err = healthcheck.Docker(mon.Context(), state, containerId, config.Timeout) result, err = healthcheck.Docker(mon.Context(), state, config.Timeout)
if err != nil { if err != nil {
if isFirstFailure { if isFirstFailure {
isFirstFailure = false isFirstFailure = false