Skip to content

Commit

Permalink
Only crash HealthCheckActor if stream for the current incarnation of …
Browse files Browse the repository at this point in the history
…HealthCheckActor stopped

Backport of 0dfe515 / mesosphere#7174

JIRA Issues: MARATHON-8743
  • Loading branch information
Tim Harper authored and Lqp1 committed Sep 28, 2020
1 parent be24ad8 commit 96dbf34
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ private[health] class HealthCheckActor(
val healthByTaskId = TrieMap.empty[Task.Id, Health]
var killingInFlight = Set.empty[Task.Id]

private case class HealthCheckStreamStopped(thisInstance: this.type)

override def preStart(): Unit = {
healthCheck match {
case marathonHealthCheck: MarathonHealthCheck =>
Expand All @@ -62,10 +64,11 @@ private[health] class HealthCheckActor(
done.onComplete {
case Success(_) =>
logger.info(s"HealthCheck stream for app ${app.id} version ${app.version} and healthCheck $healthCheck was stopped")
self ! HealthCheckStreamStopped(this)

case Failure(ex) =>
logger.warn(s"HealthCheck stream for app ${app.id} version ${app.version} and healthCheck $healthCheck crashed due to:", ex)
self ! 'restart
self ! HealthCheckStreamStopped(this)
}
}
.runWith(healthCheckHub)
Expand Down Expand Up @@ -231,8 +234,11 @@ private[health] class HealthCheckActor(
case InstanceHealthFailure(instance, health) =>
checkConsecutiveFailures(instance, health)

case 'restart =>
throw new RuntimeException("HealthCheckActor stream stopped, restarting")
case HealthCheckStreamStopped(thisInstance) =>
if (thisInstance == this)
throw new RuntimeException("HealthCheckActor stream stopped, restarting")
else
logger.info("Stream pertaining to previous instance of actor stopped; ignoring.")
}
}

Expand Down

0 comments on commit 96dbf34

Please sign in to comment.