feat(docker): implement container inspection and health checking #661
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/thwap-pagesd!661
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/docker-container-inspect"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Implements container inspection and health checking for standalone mode (#357):
InspectContainerreturns the runtime status of a site container (site.ContainerStatus), mappingErrContainerNotFoundto a typed error when the container is gone.WaitContainerRunningpolls until the container is running (and healthy when a healthcheck is configured), failing withErrContainerTimeouton deadline.StandaloneDeployer.ContainerStatusimplements the optionalsite.ContainerStatusReporterinterface, soGET /api/v1/sites/:namenow reports the active deployment's container status ascontainer_status.standalone.health_check_timeout(default"30s").ContainerRef.Why
Closes Phase 2 item #357 and its sub-tasks #354 (verify running before routing), #355 (wait for healthy with timeout), and #356 (report status through the API). These primitives will be wired into the standalone deploy flow in Phase 4.
Testing
ContainerStatusreporter mapping (production vs preview)Status()container-status wiring (populated, missing, reporter error)health_check_timeoutdefaultgo vet ./...,golangci-lint run,go test -race ./...passBreaking Changes
None.
ContainerCreateOptions/ContainerRemoveOptionsembedContainerRef; existing field names are promoted and unchanged.Notes
nginx:alpine images have no healthcheck by default, so "ready" is defined as the running state; when a container reports a healthcheck, running + healthy is required.
Closes #354
Closes #355
Closes #356
Closes #357
Solid PR. Inspection/health-check primitives are well structured, the
ContainerRefembed refactor is clean and backward compatible (all in-repo callers updated), error wrapping follows the existing centralized pattern, and test coverage for the new code is strong (health semantics table-driven, not-found mapping, timeout, reporter wiring).Questions
DOCKER-ROADMAP.md+ PR bodyCloses #354/#355— #354 ("Verify container is running before routing traffic") is marked done and closed, but routing traffic is not yet implemented (CreateSiteIngress/PublishSitestill return "not yet implemented") andWaitContainerRunningis never invoked in a deploy flow. #355 is similar: the primitive andhealth_check_timeoutconfig exist, but the config value is never read. The PR body itself says these "will be wired into the standalone deploy flow in Phase 4". Consider keeping #354 (and possibly #355) open until the deploy flow actually uses these primitives, and drop them from theCloseslist.internal/site/service.go:410— reporter errors other thanErrContainerNotFoundfail the wholeStatus()call, so in standalone mode a docker daemon outage turns into 500s on the site status and deployments endpoints. Combined withsitesHandler.ownerScopedfailing open onStatus()errors, the/deploymentsendpoint can return data without the owner check while docker is down. Consider degrading gracefully (log the reporter error and leavecontainer_statusunset) or failing closed inownerScoped.Praise
ErrContainerNotFoundvsErrContainerTimeoutare distinct, wrapped with context, and the not-found case degrades to unset rather than failing the site status.ContainerStatusv-prefix heuristic matches the existingisPreviewDeploymentconvention (service.go:486), keeping production/preview mapping consistent.WaitContainerRunninghandles both ctx cancellation and per-inspect errors, and the poll/ready semantics are documented.Filed issues
standalone.health_check_timeouthealth_check_timeoutas a duration at config loadWaitContainerRunningctx cancellation and non-404 inspect errorsownerScopedfails open onSiteStatuserror