Skip to content

Bound remaining unbounded context.Background() Docker calls (web/health, cli/docker_config_handler, cli/doctor) #614

@CybotTM

Description

@CybotTM

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions