use of com.netflix.titus.supplementary.relocation.model.DeschedulingFailure in project titus-control-plane by Netflix.
the class TaskMigrationDeschedulerTest method testFailures.
@Test
public void testFailures() {
Task job1Task0 = jobOperations.getTasks("job1").get(0);
relocationConnectorStubs.place("removable1", job1Task0);
relocationConnectorStubs.setQuota("job1", 0);
DeschedulingFailure failure = newDescheduler(Collections.emptyMap()).getDeschedulingFailure(job1Task0);
assertThat(failure.getReasonMessage()).contains("job quota");
}
use of com.netflix.titus.supplementary.relocation.model.DeschedulingFailure in project titus-control-plane by Netflix.
the class DefaultDeschedulerService method deschedule.
@Override
public List<DeschedulingResult> deschedule(Map<String, TaskRelocationPlan> plannedAheadTaskRelocationPlans) {
List<Pair<Job, List<Task>>> allJobsAndTasks = jobOperations.getJobsAndTasks();
Map<String, Job<?>> jobs = allJobsAndTasks.stream().map(Pair::getLeft).collect(Collectors.toMap(Job::getId, j -> j));
Map<String, Task> tasksById = allJobsAndTasks.stream().flatMap(p -> p.getRight().stream()).collect(Collectors.toMap(Task::getId, t -> t));
EvacuatedAgentsAllocationTracker evacuatedAgentsAllocationTracker = new EvacuatedAgentsAllocationTracker(nodeDataResolver.resolve(), tasksById);
EvictionQuotaTracker evictionQuotaTracker = new EvictionQuotaTracker(evictionOperations, jobs);
TaskMigrationDescheduler taskMigrationDescheduler = new TaskMigrationDescheduler(plannedAheadTaskRelocationPlans, evacuatedAgentsAllocationTracker, evictionQuotaTracker, evictionConfiguration, jobs, tasksById, titusRuntime);
Map<String, DeschedulingResult> requestedImmediateEvictions = taskMigrationDescheduler.findAllImmediateEvictions();
Map<String, DeschedulingResult> requestedEvictions = taskMigrationDescheduler.findRequestedJobOrTaskMigrations();
Map<String, DeschedulingResult> allRequestedEvictions = CollectionsExt.merge(requestedImmediateEvictions, requestedEvictions);
Map<String, DeschedulingResult> regularEvictions = new HashMap<>();
Optional<Pair<TitusNode, List<Task>>> bestMatch;
while ((bestMatch = taskMigrationDescheduler.nextBestMatch()).isPresent()) {
TitusNode agent = bestMatch.get().getLeft();
List<Task> tasks = bestMatch.get().getRight();
tasks.forEach(task -> {
if (!allRequestedEvictions.containsKey(task.getId())) {
Optional<TaskRelocationPlan> relocationPlanForTask = getRelocationPlanForTask(agent, task, plannedAheadTaskRelocationPlans);
relocationPlanForTask.ifPresent(rp -> regularEvictions.put(task.getId(), DeschedulingResult.newBuilder().withTask(task).withAgentInstance(agent).withTaskRelocationPlan(rp).build()));
}
});
}
// Find eviction which could not be scheduled now.
for (Task task : tasksById.values()) {
if (allRequestedEvictions.containsKey(task.getId()) || regularEvictions.containsKey(task.getId())) {
continue;
}
if (evacuatedAgentsAllocationTracker.isEvacuated(task)) {
DeschedulingFailure failure = taskMigrationDescheduler.getDeschedulingFailure(task);
TaskRelocationPlan relocationPlan = plannedAheadTaskRelocationPlans.get(task.getId());
if (relocationPlan == null) {
relocationPlan = newNotDelayedRelocationPlan(task, false);
}
TitusNode agent = evacuatedAgentsAllocationTracker.getRemovableAgent(task);
regularEvictions.put(task.getId(), DeschedulingResult.newBuilder().withTask(task).withAgentInstance(agent).withTaskRelocationPlan(relocationPlan).withFailure(failure).build());
}
}
return CollectionsExt.merge(new ArrayList<>(allRequestedEvictions.values()), new ArrayList<>(regularEvictions.values()));
}
use of com.netflix.titus.supplementary.relocation.model.DeschedulingFailure in project titus-control-plane by Netflix.
the class RelocationTransactionLogger method logTaskRelocationDeschedulingResult.
void logTaskRelocationDeschedulingResult(String stepName, DeschedulingResult deschedulingResult) {
String taskId = deschedulingResult.getTask().getId();
DeschedulingFailure failure = deschedulingResult.getFailure().orElse(null);
if (failure == null) {
doLog(findJob(taskId), taskId, stepName, "descheduling", "success", "Scheduled for being evicted now from agent: agentId=" + deschedulingResult.getAgentInstance().getId());
} else {
doLog(findJob(taskId), taskId, stepName, "descheduling", "failure", String.format("Task eviction not possible: agentId=%s, reason=%s", deschedulingResult.getAgentInstance().getId(), failure.getReasonMessage()));
}
}
Aggregations