diff --git a/src/main/scala/mesosphere/marathon/core/task/state/NetworkInfo.scala b/src/main/scala/mesosphere/marathon/core/task/state/NetworkInfo.scala index d4ca6a4ac61..f431f27a8e8 100644 --- a/src/main/scala/mesosphere/marathon/core/task/state/NetworkInfo.scala +++ b/src/main/scala/mesosphere/marathon/core/task/state/NetworkInfo.scala @@ -28,7 +28,9 @@ case class NetworkInfo( */ def effectiveIpAddress(runSpec: RunSpec): Option[String] = { if (!ipAddresses.isEmpty) { - pickFirstIpAddressFrom(ipAddresses) + findCriteoIpAddress().getOrElse( + pickFirstIpAddressFrom(ipAddresses) + ) } else { Some(hostName) } @@ -91,6 +93,18 @@ object NetworkInfo extends StrictLogging { } } + def findCriteoIpAddress(mesosStatus: mesos.Protos.TaskStatus): Option[mesos.Protos.NetworkInfo.IPAddress] = { + if (mesosStatus.hasContainerStatus && mesosStatus.getContainerStatus.getNetworkInfosCount > 0) { + mesosStatus.getContainerStatus.getNetworkInfosList + .find(_.getName == "criteo") + .map(_.getIpAddressesList) + .headOption + .map(_.getIpAddress) + } else { + None + } + } + private def computePortAssignments( app: AppDefinition, hostName: String,