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();
}
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;
}
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))));
}
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");
}
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");
}
Aggregations