use of com.netflix.titus.api.relocation.model.TaskRelocationPlan 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)");
}
}
}
use of com.netflix.titus.api.relocation.model.TaskRelocationPlan in project titus-control-plane by Netflix.
the class MustBeRelocatedSelfManagedTaskCollectorStep method collectTasksThatMustBeRelocated.
public Map<String, TaskRelocationPlan> collectTasksThatMustBeRelocated() {
Stopwatch stopwatch = Stopwatch.createStarted();
try {
Map<String, TaskRelocationPlan> result = buildRelocationPlans();
metrics.onSuccess(result.size(), stopwatch.elapsed(TimeUnit.MILLISECONDS));
logger.debug("Step results: {}", result);
return result;
} catch (Exception e) {
logger.error("Step processing error", e);
metrics.onError(stopwatch.elapsed(TimeUnit.MILLISECONDS));
throw e;
}
}
use of com.netflix.titus.api.relocation.model.TaskRelocationPlan in project titus-control-plane by Netflix.
the class MustBeRelocatedSelfManagedTaskCollectorStep method buildSelfManagedRelocationPlan.
/**
* Relocation plans today are limited to self managed polices.
*/
private TaskRelocationPlan buildSelfManagedRelocationPlan(Job<?> job, Task task, String reason) {
long now = clock.wallTime();
SelfManagedDisruptionBudgetPolicy selfManaged = (SelfManagedDisruptionBudgetPolicy) job.getJobDescriptor().getDisruptionBudget().getDisruptionBudgetPolicy();
TaskRelocationPlan relocationPlan = TaskRelocationPlan.newBuilder().withTaskId(task.getId()).withReason(TaskRelocationReason.SelfManagedMigration).withReasonMessage(reason).withDecisionTime(now).withRelocationTime(now + selfManaged.getRelocationTimeMs()).build();
TaskRelocationPlan previous = lastResult.get(task.getId());
boolean keepPrevious = previous != null && (areEqualExceptRelocationTime(previous, relocationPlan) || previous.getRelocationTime() < relocationPlan.getRelocationTime());
return keepPrevious ? previous : relocationPlan;
}
Aggregations