use of com.netflix.titus.supplementary.relocation.model.DeschedulingResult in project titus-control-plane by Netflix.
the class TaskMigrationDescheduler method findAllImmediateEvictions.
Map<String, DeschedulingResult> findAllImmediateEvictions() {
long now = clock.wallTime();
Map<String, DeschedulingResult> result = new HashMap<>();
tasksById.values().forEach(task -> {
Job<?> job = jobsById.get(task.getJobId());
TitusNode instance = evacuatedAgentsAllocationTracker.getAgent(task);
if (job != null && instance != null) {
RelocationPredicates.checkIfMustBeRelocatedImmediately(job, task, instance).ifPresent(reason -> {
evictionQuotaTracker.consumeQuotaNoError(job.getId());
result.put(task.getId(), newDeschedulingResultForRequestedRelocation(now, task, instance, reason.getRight()));
});
}
});
return result;
}
use of com.netflix.titus.supplementary.relocation.model.DeschedulingResult in project titus-control-plane by Netflix.
the class TaskMigrationDeschedulerTest method testTaskRequiredMigration.
@Test
public void testTaskRequiredMigration() {
Task job1Task0 = jobOperations.getTasks("job1").get(0);
relocationConnectorStubs.place("active1", job1Task0);
relocationConnectorStubs.setQuota("job1", 1);
relocationConnectorStubs.addTaskAttribute(job1Task0.getId(), RelocationAttributes.RELOCATION_REQUIRED, "true");
clock.advanceTime(Duration.ofSeconds(1));
Map<String, DeschedulingResult> results = newDescheduler(Collections.emptyMap()).findRequestedJobOrTaskMigrations();
assertThat(results).isNotEmpty();
}
use of com.netflix.titus.supplementary.relocation.model.DeschedulingResult in project titus-control-plane by Netflix.
the class TaskMigrationDeschedulerTest method testSystemQuotaExemption.
@Test
public void testSystemQuotaExemption() {
Task job1Task0 = jobOperations.getTasks("job1").get(0);
relocationConnectorStubs.place("active1", job1Task0);
relocationConnectorStubs.addTaskAttribute(job1Task0.getId(), RelocationAttributes.RELOCATION_REQUIRED, "true");
EvictionQuotaTracker evictionQuotaTracker = mock(EvictionQuotaTracker.class);
when(evictionQuotaTracker.getSystemEvictionQuota()).thenReturn(0L);
when(evictionQuotaTracker.isSystemDisruptionWindowOpen()).thenReturn(false);
when(evictionQuotaTracker.getJobEvictionQuota("job1")).thenReturn(1L);
Map<String, DeschedulingResult> results = newDescheduler(evictionQuotaTracker, () -> "app2").findRequestedJobOrTaskMigrations();
assertThat(results).isEmpty();
Map<String, DeschedulingResult> results2 = newDescheduler(evictionQuotaTracker, () -> "app1").findRequestedJobOrTaskMigrations();
assertThat(results2).isNotEmpty();
// system window open with quota = 0
when(evictionQuotaTracker.isSystemDisruptionWindowOpen()).thenReturn(true);
Map<String, DeschedulingResult> results3 = newDescheduler(evictionQuotaTracker, () -> "app1").findRequestedJobOrTaskMigrations();
assertThat(results3).isEmpty();
}
use of com.netflix.titus.supplementary.relocation.model.DeschedulingResult in project titus-control-plane by Netflix.
the class DefaultDeschedulerServiceTest method testAllExpectedJobMigrationsAreFound.
@Test
public void testAllExpectedJobMigrationsAreFound() {
List<Task> tasksOfJob1 = jobOperations.getTasks("job1");
dataGenerator.place("active1", tasksOfJob1.get(0), tasksOfJob1.get(1));
dataGenerator.place("removable1", tasksOfJob1.get(2), tasksOfJob1.get(3));
dataGenerator.setQuota("job1", 2);
List<Task> tasksOfJob2 = jobOperations.getTasks("job2");
dataGenerator.place("active1", tasksOfJob2.get(0), tasksOfJob2.get(1));
dataGenerator.place("removable1", tasksOfJob2.get(2), tasksOfJob2.get(3));
dataGenerator.setQuota("job2", 2);
dataGenerator.addJobAttribute("jobImmediate", RelocationAttributes.RELOCATION_REQUIRED_BY_IMMEDIATELY, "" + (clock.wallTime() + 1));
Task taskImmediate = jobOperations.getTasks("jobImmediate").get(0);
dataGenerator.place("active1", taskImmediate);
List<DeschedulingResult> results = deschedulerService.deschedule(Collections.emptyMap());
assertThat(results).hasSize(5);
for (DeschedulingResult result : results) {
boolean isImmediateJobMigration = result.getTask().getId().equals(taskImmediate.getId());
if (isImmediateJobMigration) {
assertThat(result.getAgentInstance().getServerGroupId()).isEqualTo("active1");
} else {
assertThat(result.getAgentInstance().getServerGroupId()).isEqualTo("removable1");
}
TaskRelocationPlan plan = result.getTaskRelocationPlan();
if (plan.getTaskId().startsWith("jobImmediate")) {
assertThat(plan.getReason()).isEqualTo(TaskRelocationReason.TaskMigration);
} else {
assertThat(plan.getReason()).isEqualTo(TaskRelocationReason.AgentEvacuation);
}
if (isImmediateJobMigration) {
assertThat(plan.getReasonMessage()).containsSequence("Job marked for immediate eviction");
} else {
assertThat(plan.getReasonMessage()).isEqualTo("Enough quota to migrate the task (no migration delay configured)");
}
}
}
Aggregations