private static List<String> getIpAddresses(Protos.TaskStatus taskStatus) { if (taskStatus != null && taskStatus.hasContainerStatus() && taskStatus.getContainerStatus().getNetworkInfosCount() > 0) { return taskStatus .getContainerStatus() .getNetworkInfosList() .stream() .flatMap(networkInfo -> networkInfo.getIpAddressesList().stream()) .map(Protos.NetworkInfo.IPAddress::getIpAddress) .collect(Collectors.toList()); } return Collections.emptyList(); }
@Override protected void processStatusUpdate(Protos.TaskStatus status) throws Exception { // Store status, then pass status to PlanManager => Plan => Steps String taskName = StateStoreUtils.fetchTaskInfo(stateStore, status).getName(); // StateStore updates: // - TaskStatus // - Override status (if applicable) stateStore.storeStatus(taskName, status); // Notify plans of status update: planCoordinator.getPlanManagers().forEach(planManager -> planManager.update(status)); // If the TaskStatus contains an IP Address, store it as a property in the StateStore. // We expect the TaskStatus to contain an IP address in both Host or CNI networking. // Currently, we are always _missing_ the IP Address on TASK_LOST. We always expect it on TASK_RUNNINGs if (status.hasContainerStatus() && status.getContainerStatus().getNetworkInfosCount() > 0 && status.getContainerStatus().getNetworkInfosList().stream() .anyMatch(networkInfo -> networkInfo.getIpAddressesCount() > 0)) { // Map the TaskStatus to a TaskInfo. The map will throw a StateStoreException if no such TaskInfo exists. try { StateStoreUtils.storeTaskStatusAsProperty(stateStore, taskName, status); } catch (StateStoreException e) { logger.warn("Unable to store network info for status update: " + status, e); } } }