Search in sources :

Example 1 with BatchJobTask

use of com.netflix.titus.api.jobmanager.model.job.BatchJobTask in project titus-control-plane by Netflix.

the class JobModelSanitizationTest method testBatchTaskWithNullFieldValues.

@Test
public void testBatchTaskWithNullFieldValues() {
    BatchJobTask task = JobGenerator.batchTasks(JobGenerator.batchJobs(oneTaskBatchJobDescriptor()).getValue()).getValue().toBuilder().withStatus(null).build();
    assertThat(entitySanitizer.sanitize(task)).isEmpty();
    assertThat(entitySanitizer.validate(task)).isNotEmpty();
}
Also used : BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask) Test(org.junit.Test)

Example 2 with BatchJobTask

use of com.netflix.titus.api.jobmanager.model.job.BatchJobTask in project titus-control-plane by Netflix.

the class BatchDifferenceResolver method findMissingRunningTasks.

/**
 * Check that for each reference job task, there is a corresponding running task.
 */
private List<ChangeAction> findMissingRunningTasks(ReconciliationEngine<JobManagerReconcilerEvent> engine, BatchJobView refJobView, BatchJobView runningJobView) {
    List<ChangeAction> missingTasks = new ArrayList<>();
    List<BatchJobTask> tasks = refJobView.getTasks();
    for (BatchJobTask refTask : tasks) {
        BatchJobTask runningTask = runningJobView.getTaskById(refTask.getId());
        if (runtime.getComputeProvider().isReadyForScheduling()) {
            // TODO This complexity exists due to the way Fenzo is initialized on bootstrap. This code can be simplified one we move off Fenzo.
            if (runningTask == null || (refTask.getStatus().getState() == TaskState.Accepted && !TaskStatus.hasPod(refTask))) {
                missingTasks.add(BasicTaskActions.launchTaskInKube(configuration, runtime, engine, runningJobView.getJob(), refTask, RECONCILER_CALLMETADATA.toBuilder().withCallReason("Launching task in Kube").build(), versionSupplier, titusRuntime));
            }
        }
    }
    return missingTasks;
}
Also used : TitusChangeAction(com.netflix.titus.master.jobmanager.service.common.action.TitusChangeAction) ChangeAction(com.netflix.titus.common.framework.reconciler.ChangeAction) ArrayList(java.util.ArrayList) BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask)

Example 3 with BatchJobTask

use of com.netflix.titus.api.jobmanager.model.job.BatchJobTask in project titus-control-plane by Netflix.

the class CreateOrReplaceBatchTaskActions method createOriginalTaskChangeAction.

private static TitusChangeAction createOriginalTaskChangeAction(Job<BatchJobExt> job, int index, JobStore jobStore, VersionSupplier versionSupplier, Clock clock, Map<String, String> taskContext) {
    Retryer newRetryer = JobFunctions.retryer(job);
    BatchJobTask newTask = createNewBatchTask(job, index, clock.wallTime(), versionSupplier, taskContext);
    return TitusChangeAction.newAction("createOrReplaceTask").id(newTask.getId()).trigger(Trigger.Reconciler).summary(String.format("Creating new task at index %d in DB store: %s", newTask.getIndex(), newTask.getId())).changeWithModelUpdates(self -> jobStore.storeTask(newTask).andThen(Observable.just(createNewTaskModelAction(self, newTask, Optional.empty(), newRetryer))));
}
Also used : Retryer(com.netflix.titus.common.util.retry.Retryer) BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask)

Example 4 with BatchJobTask

use of com.netflix.titus.api.jobmanager.model.job.BatchJobTask in project titus-control-plane by Netflix.

the class KubeNotificationProcessorTest method testAreTasksEquivalent_DifferentTwoLevelResource.

@Test
public void testAreTasksEquivalent_DifferentTwoLevelResource() {
    BatchJobTask first = JobGenerator.oneBatchTask();
    BatchJobTask second = first.toBuilder().withTwoLevelResources(TwoLevelResource.newBuilder().withName("fakeResource").build()).build();
    assertThat(KubeNotificationProcessor.areTasksEquivalent(first, second)).contains("different task two level resources");
}
Also used : BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask) Test(org.junit.Test)

Example 5 with BatchJobTask

use of com.netflix.titus.api.jobmanager.model.job.BatchJobTask in project titus-control-plane by Netflix.

the class KubeNotificationProcessorTest method testAreTasksEquivalent_DifferentAttributes.

@Test
public void testAreTasksEquivalent_DifferentAttributes() {
    BatchJobTask first = JobGenerator.oneBatchTask();
    BatchJobTask second = first.toBuilder().withAttributes(Collections.singletonMap("testAreTasksEquivalent_DifferentAttributes", "true")).build();
    assertThat(KubeNotificationProcessor.areTasksEquivalent(first, second)).contains("different task attributes");
}
Also used : BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask) Test(org.junit.Test)

Aggregations

BatchJobTask (com.netflix.titus.api.jobmanager.model.job.BatchJobTask)30 Test (org.junit.Test)20 BatchJobExt (com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt)14 HashMap (java.util.HashMap)14 V1Affinity (io.kubernetes.client.openapi.models.V1Affinity)10 V1Pod (io.kubernetes.client.openapi.models.V1Pod)10 Task (com.netflix.titus.api.jobmanager.model.job.Task)7 V1Container (io.kubernetes.client.openapi.models.V1Container)5 BasicContainer (com.netflix.titus.api.jobmanager.model.job.BasicContainer)4 ArrayList (java.util.ArrayList)4 Container (com.netflix.titus.api.jobmanager.model.job.Container)3 V1Volume (io.kubernetes.client.openapi.models.V1Volume)3 V1VolumeMount (io.kubernetes.client.openapi.models.V1VolumeMount)3 ContainerResources (com.netflix.titus.api.jobmanager.model.job.ContainerResources)2 ServiceJobTask (com.netflix.titus.api.jobmanager.model.job.ServiceJobTask)2 EfsMount (com.netflix.titus.api.model.EfsMount)2 ChangeAction (com.netflix.titus.common.framework.reconciler.ChangeAction)2 EntityHolder (com.netflix.titus.common.framework.reconciler.EntityHolder)2 Retryer (com.netflix.titus.common.util.retry.Retryer)2 TitusChangeAction (com.netflix.titus.master.jobmanager.service.common.action.TitusChangeAction)2