Skip to content

Commit 9818f7a

Browse files
authored
Fix panic when checking service status (#1078)
There seems to be a race condition since a container starts running, till its state reports any health information. During this time the value obtained from the API is nil. Don't try to get the status from the healtcheck if that's the case.
1 parent 85b6995 commit 9818f7a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/stack/compose.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,11 @@ func newServiceStatus(description *docker.ContainerDescription) (*ServiceStatus,
221221
Version: getVersionFromDockerImage(description.Config.Image),
222222
}
223223
if description.State.Status == "running" {
224-
service.Status = fmt.Sprintf("%v (%v)", service.Status, description.State.Health.Status)
224+
healthStatus := "unknown health"
225+
if health := description.State.Health; health != nil {
226+
healthStatus = health.Status
227+
}
228+
service.Status = fmt.Sprintf("%v (%v)", service.Status, healthStatus)
225229
}
226230
if description.State.Status == "exited" {
227231
service.Status = fmt.Sprintf("%v (%v)", service.Status, description.State.ExitCode)

0 commit comments

Comments
 (0)