Surfaced during the audit of #608 / #611. Same bug class: unbounded contexts on Docker SDK calls that hang Ofelia when the daemon is reachable-but-wedged.
#611 bounded the construction-time NegotiateAPIVersion. Three more sites still pass context.Background() to Docker calls:
| File:Line |
Call |
Symptom on wedged daemon |
web/health.go:116 |
dockerProvider.Ping(ctx) and Info(ctx) in checkDocker |
/health and /ready endpoints hang; monitoring fails to detect the wedge |
cli/docker_config_handler.go:183 |
provider.Ping(context.Background()) in buildSDKProvider sanity check |
Daemon startup hangs at the post-construction sanity ping |
cli/doctor.go:378, 553 |
Ping, HasImageLocally in ofelia doctor |
The diagnostic command hangs — the very tool meant to surface this kind of failure |
Suggested fix
Wrap each call in context.WithTimeout(parentCtx, 5–10s) (10s for sanity-checks, 5s for health-endpoint checks where responsiveness matters). For health checks, prefer a per-handler timeout via r.Context() so request cancellation propagates.
Acceptance criteria
Severity
Medium — availability gaps. Health endpoint hanging is the worst of the three because it defeats external monitoring. The startup sanity-check is partially shadowed by the now-bounded NegotiateAPIVersion, but still independently unbounded.
Surfaced during the audit of #608 / #611. Same bug class: unbounded contexts on Docker SDK calls that hang Ofelia when the daemon is reachable-but-wedged.
#611 bounded the construction-time
NegotiateAPIVersion. Three more sites still passcontext.Background()to Docker calls:web/health.go:116dockerProvider.Ping(ctx)andInfo(ctx)incheckDocker/healthand/readyendpoints hang; monitoring fails to detect the wedgecli/docker_config_handler.go:183provider.Ping(context.Background())inbuildSDKProvidersanity checkcli/doctor.go:378, 553Ping,HasImageLocallyinofelia doctorSuggested fix
Wrap each call in
context.WithTimeout(parentCtx, 5–10s)(10s for sanity-checks, 5s for health-endpoint checks where responsiveness matters). For health checks, prefer a per-handler timeout viar.Context()so request cancellation propagates.Acceptance criteria
defer cancel().Severity
Medium — availability gaps. Health endpoint hanging is the worst of the three because it defeats external monitoring. The startup sanity-check is partially shadowed by the now-bounded
NegotiateAPIVersion, but still independently unbounded.