Search in sources :

Example 6 with DeschedulingResult

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;
}
Also used : HashMap(java.util.HashMap) DeschedulingResult(com.netflix.titus.supplementary.relocation.model.DeschedulingResult) TitusNode(com.netflix.titus.supplementary.relocation.connector.TitusNode)

Example 7 with DeschedulingResult

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();
}
Also used : Task(com.netflix.titus.api.jobmanager.model.job.Task) DeschedulingResult(com.netflix.titus.supplementary.relocation.model.DeschedulingResult) Test(org.junit.Test)

Example 8 with DeschedulingResult

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();
}
Also used : Task(com.netflix.titus.api.jobmanager.model.job.Task) DeschedulingResult(com.netflix.titus.supplementary.relocation.model.DeschedulingResult) Test(org.junit.Test)

Example 9 with DeschedulingResult

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)");
        }
    }
}
Also used : Task(com.netflix.titus.api.jobmanager.model.job.Task) ServiceJobTask(com.netflix.titus.api.jobmanager.model.job.ServiceJobTask) DeschedulingResult(com.netflix.titus.supplementary.relocation.model.DeschedulingResult) TaskRelocationPlan(com.netflix.titus.api.relocation.model.TaskRelocationPlan) Test(org.junit.Test)

Aggregations

DeschedulingResult (com.netflix.titus.supplementary.relocation.model.DeschedulingResult)9 Task (com.netflix.titus.api.jobmanager.model.job.Task)6 Test (org.junit.Test)5 TitusNode (com.netflix.titus.supplementary.relocation.connector.TitusNode)3 HashMap (java.util.HashMap)3 TaskRelocationPlan (com.netflix.titus.api.relocation.model.TaskRelocationPlan)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Stopwatch (com.google.common.base.Stopwatch)1 ReadOnlyEvictionOperations (com.netflix.titus.api.eviction.service.ReadOnlyEvictionOperations)1 Job (com.netflix.titus.api.jobmanager.model.job.Job)1 JobFunctions.hasDisruptionBudget (com.netflix.titus.api.jobmanager.model.job.JobFunctions.hasDisruptionBudget)1 ServiceJobTask (com.netflix.titus.api.jobmanager.model.job.ServiceJobTask)1 ReadOnlyJobOperations (com.netflix.titus.api.jobmanager.service.ReadOnlyJobOperations)1 TaskRelocationReason (com.netflix.titus.api.relocation.model.TaskRelocationPlan.TaskRelocationReason)1 TitusRuntime (com.netflix.titus.common.runtime.TitusRuntime)1 CollectionsExt (com.netflix.titus.common.util.CollectionsExt)1 Clock (com.netflix.titus.common.util.time.Clock)1 Pair (com.netflix.titus.common.util.tuple.Pair)1 EvictionConfiguration (com.netflix.titus.runtime.connector.eviction.EvictionConfiguration)1 NodeDataResolver (com.netflix.titus.supplementary.relocation.connector.NodeDataResolver)1