Skip to content

Commit

Permalink
Merge 4abd7c1 into c0b2f34
Browse files Browse the repository at this point in the history
  • Loading branch information
jeschkies committed Sep 14, 2016
2 parents c0b2f34 + 4abd7c1 commit 5734df3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Expand Up @@ -129,6 +129,9 @@ object HealthCheck {
val DefaultMaxConsecutiveFailures = 3
val DefaultIgnoreHttp1xx = false
val DefaultPort = None
// As soon as an application is started (before a task is launched), we start the health checks for this app.
// We optimistically set a low value here, for tasks that start really fast
val DefaultFirstHealthCheckAfter = 5.seconds

implicit val healthCheck = validator[HealthCheck] { hc =>
(hc.portIndex.nonEmpty is true) or (hc.port.nonEmpty is true)
Expand Down
Expand Up @@ -11,6 +11,8 @@ import mesosphere.marathon.core.health._
import mesosphere.marathon.state.{ AppDefinition, Timestamp }
import mesosphere.marathon.core.task.termination.{ TaskKillReason, TaskKillService }

import scala.concurrent.duration._

private[health] class HealthCheckActor(
app: AppDefinition,
killService: TaskKillService,
Expand All @@ -33,7 +35,9 @@ private[health] class HealthCheckActor(
app.version,
healthCheck
)
scheduleNextHealthCheck()
//Start health checking not after the default first health check
val start = math.min(healthCheck.interval.toMillis, HealthCheck.DefaultFirstHealthCheckAfter.toMillis).millis
scheduleNextHealthCheck(Some(start))
}

override def preRestart(reason: Throwable, message: Option[Any]): Unit =
Expand Down Expand Up @@ -67,7 +71,7 @@ private[health] class HealthCheckActor(
taskHealth = taskHealth.filterKeys(activeTaskIds).iterator.toMap
}

def scheduleNextHealthCheck(): Unit =
def scheduleNextHealthCheck(interval: Option[FiniteDuration] = None): Unit =
if (healthCheck.protocol != Protocol.COMMAND) {
log.debug(
"Scheduling next health check for app [{}] version [{}] and healthCheck [{}]",
Expand Down

0 comments on commit 5734df3

Please sign in to comment.