Skip to content

Commit

Permalink
Automatically detect criteo IP address for checks
Browse files Browse the repository at this point in the history
This should remove the constraint on Mesos to configure `criteo` network
in a specific order (last element). With patch, the effective address of
the current task should be assign the criteo network's (first) IP
address (if it is defined), otherwise we will fall back to the previous
heuristic (extract the first IP address provided by Mesos).

JIRA: MESOS-5907
  • Loading branch information
komuta committed Nov 24, 2023
1 parent 9389049 commit 137f9c0
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 137f9c0

Please sign in to comment.