use of com.netflix.titus.api.containerhealth.service.ContainerHealthService in project titus-control-plane by Netflix.
the class JobQuotaControllerTest method testSelfManagedJobUsesInternalDisruptionBudget.
@Test
public void testSelfManagedJobUsesInternalDisruptionBudget() {
Job<BatchJobExt> job = newBatchJob(10, budget(selfManagedPolicy(1_000), unlimitedRate(), Collections.emptyList()));
com.netflix.titus.api.model.reference.Reference jobReference = com.netflix.titus.api.model.reference.Reference.job(job.getId());
scheduleJob(job, 10);
EffectiveJobDisruptionBudgetResolver budgetResolver = j -> budget(perTaskRelocationLimitPolicy(100), hourlyRatePercentage(5), singletonList(officeHourTimeWindow()));
JobQuotaController jobController = new JobQuotaController(job, jobOperations, budgetResolver, containerHealthService, titusRuntime);
assertThat(jobController.getQuota(jobReference).getQuota()).isEqualTo(1);
Task task = jobOperations.getTasks(job.getId()).get(0);
assertThat(jobController.consume(task.getId()).isApproved()).isTrue();
assertThat(jobController.getQuota(jobReference).getQuota()).isEqualTo(0);
ConsumptionResult failure = jobController.consume(task.getId());
assertThat(failure.isApproved()).isFalse();
assertThat(failure.getRejectionReason().get()).contains("JobPercentagePerHourRelocationRateController");
}
use of com.netflix.titus.api.containerhealth.service.ContainerHealthService in project titus-control-plane by Netflix.
the class AggregatingContainerHealthService method takeStatusOfTaskWithHealthProviders.
private ContainerHealthStatus takeStatusOfTaskWithHealthProviders(Task task, Set<String> enabledServices) {
ContainerHealthStatus current = null;
for (String name : enabledServices) {
ContainerHealthService healthService = healthServices.get(name);
ContainerHealthStatus newStatus;
if (healthService != null) {
newStatus = healthService.findHealthStatus(task.getId()).orElseGet(() -> ContainerHealthStatus.newBuilder().withTaskId(task.getId()).withState(ContainerHealthState.Unknown).withReason("not known to: " + name).withTimestamp(clock.wallTime()).build());
} else {
newStatus = ContainerHealthStatus.newBuilder().withTaskId(task.getId()).withState(ContainerHealthState.Unknown).withReason("unknown container health provider set: " + name).withTimestamp(clock.wallTime()).build();
}
current = current == null ? newStatus : ContainerHealthFunctions.merge(current, newStatus);
}
return current;
}
Aggregations