From e567e4fc1021b72a6e5205753302233c71786d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20August=C3=BDn?= Date: Thu, 9 Mar 2017 23:41:28 +0100 Subject: [PATCH] don't accept unhealthy state Fixes #63 --- .../com/avast/gradle/dockercompose/tasks/ComposeUp.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/groovy/com/avast/gradle/dockercompose/tasks/ComposeUp.groovy b/src/main/groovy/com/avast/gradle/dockercompose/tasks/ComposeUp.groovy index b684eac..5313256 100644 --- a/src/main/groovy/com/avast/gradle/dockercompose/tasks/ComposeUp.groovy +++ b/src/main/groovy/com/avast/gradle/dockercompose/tasks/ComposeUp.groovy @@ -242,10 +242,12 @@ class ComposeUp extends DefaultTask { Map inspectionState = getDockerInspection(service.getContainerId()).State if (inspectionState.containsKey('Health')) { String healthStatus = inspectionState.Health.Status - if (!"starting".equalsIgnoreCase(healthStatus)) { + if (!"starting".equalsIgnoreCase(healthStatus) && !"unhealthy".equalsIgnoreCase(healthStatus)) { logger.lifecycle("${service.name} health state reported as '$healthStatus' - continuing...") return } + logger.lifecycle("Waiting for ${service.name} to become healthy (it's $healthStatus)") + sleep(extension.waitAfterHealthyStateProbeFailure.toMillis()) } else { logger.debug("Service ${service.name} or this version of Docker doesn't support healtchecks") return @@ -253,8 +255,6 @@ class ComposeUp extends DefaultTask { if (start.plus(extension.waitForHealthyStateTimeout) < Instant.now()) { throw new RuntimeException("Container ${service.containerId} of service ${service.name} is still reported as 'starting'. Logs:${System.lineSeparator()}${getServiceLogs(service.name)}") } - logger.lifecycle("Waiting for ${service.name} to become healthy") - sleep(extension.waitAfterHealthyStateProbeFailure.toMillis()) } } }