Search in sources :

Example 1 with ContainerHealthService

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");
}
Also used : DisruptionBudgetGenerator.numberOfHealthyPolicy(com.netflix.titus.testkit.model.eviction.DisruptionBudgetGenerator.numberOfHealthyPolicy) DisruptionBudgetGenerator.unlimitedRate(com.netflix.titus.testkit.model.eviction.DisruptionBudgetGenerator.unlimitedRate) ConsumptionResult(com.netflix.titus.master.eviction.service.quota.ConsumptionResult) DisruptionBudgetGenerator.exceptBudget(com.netflix.titus.testkit.model.eviction.DisruptionBudgetGenerator.exceptBudget) DisruptionBudgetGenerator.percentageOfHealthyPolicy(com.netflix.titus.testkit.model.eviction.DisruptionBudgetGenerator.percentageOfHealthyPolicy) Task(com.netflix.titus.api.jobmanager.model.job.Task) DisruptionBudgetGenerator.budget(com.netflix.titus.testkit.model.eviction.DisruptionBudgetGenerator.budget) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DisruptionBudgetGenerator.exceptRate(com.netflix.titus.testkit.model.eviction.DisruptionBudgetGenerator.exceptRate) TimeWindowQuotaTracker(com.netflix.titus.master.eviction.service.quota.TimeWindowQuotaTracker) DisruptionBudgetGenerator.newBatchJob(com.netflix.titus.testkit.model.eviction.DisruptionBudgetGenerator.newBatchJob) JobQuotaController.buildQuotaControllers(com.netflix.titus.master.eviction.service.quota.job.JobQuotaController.buildQuotaControllers) DisruptionBudgetGenerator.hourlyRatePercentage(com.netflix.titus.testkit.model.eviction.DisruptionBudgetGenerator.hourlyRatePercentage) Collections.singletonList(java.util.Collections.singletonList) DisruptionBudgetGenerator.perTaskRelocationLimitPolicy(com.netflix.titus.testkit.model.eviction.DisruptionBudgetGenerator.perTaskRelocationLimitPolicy) TitusRuntimes(com.netflix.titus.common.runtime.TitusRuntimes) QuotaTracker(com.netflix.titus.master.eviction.service.quota.QuotaTracker) JobQuotaController.buildQuotaTrackers(com.netflix.titus.master.eviction.service.quota.job.JobQuotaController.buildQuotaTrackers) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) QuotaController(com.netflix.titus.master.eviction.service.quota.QuotaController) DisruptionBudgetGenerator.exceptPolicy(com.netflix.titus.testkit.model.eviction.DisruptionBudgetGenerator.exceptPolicy) DisruptionBudgetGenerator.selfManagedPolicy(com.netflix.titus.testkit.model.eviction.DisruptionBudgetGenerator.selfManagedPolicy) Clocks(com.netflix.titus.common.util.time.Clocks) Job(com.netflix.titus.api.jobmanager.model.job.Job) DisruptionBudgetGenerator.officeHourTimeWindow(com.netflix.titus.testkit.model.eviction.DisruptionBudgetGenerator.officeHourTimeWindow) Set(java.util.Set) JobFunctions(com.netflix.titus.api.jobmanager.model.job.JobFunctions) Test(org.junit.Test) Collectors(java.util.stream.Collectors) TaskState(com.netflix.titus.api.jobmanager.model.job.TaskState) List(java.util.List) V3JobOperations(com.netflix.titus.api.jobmanager.service.V3JobOperations) Stream(java.util.stream.Stream) DayOfWeek(java.time.DayOfWeek) JobComponentStub(com.netflix.titus.testkit.model.job.JobComponentStub) TitusRuntime(com.netflix.titus.common.runtime.TitusRuntime) TestClock(com.netflix.titus.common.util.time.TestClock) DisruptionBudgetGenerator.ratePerInterval(com.netflix.titus.testkit.model.eviction.DisruptionBudgetGenerator.ratePerInterval) ContainerHealthService(com.netflix.titus.api.containerhealth.service.ContainerHealthService) Collections(java.util.Collections) JobQuotaController.mergeQuotaControllers(com.netflix.titus.master.eviction.service.quota.job.JobQuotaController.mergeQuotaControllers) Task(com.netflix.titus.api.jobmanager.model.job.Task) ConsumptionResult(com.netflix.titus.master.eviction.service.quota.ConsumptionResult) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) Test(org.junit.Test)

Example 2 with ContainerHealthService

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;
}
Also used : ContainerHealthStatus(com.netflix.titus.api.containerhealth.model.ContainerHealthStatus) ContainerHealthService(com.netflix.titus.api.containerhealth.service.ContainerHealthService)

Aggregations

ContainerHealthService (com.netflix.titus.api.containerhealth.service.ContainerHealthService)2 ContainerHealthStatus (com.netflix.titus.api.containerhealth.model.ContainerHealthStatus)1 Job (com.netflix.titus.api.jobmanager.model.job.Job)1 JobFunctions (com.netflix.titus.api.jobmanager.model.job.JobFunctions)1 Task (com.netflix.titus.api.jobmanager.model.job.Task)1 TaskState (com.netflix.titus.api.jobmanager.model.job.TaskState)1 BatchJobExt (com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt)1 V3JobOperations (com.netflix.titus.api.jobmanager.service.V3JobOperations)1 TitusRuntime (com.netflix.titus.common.runtime.TitusRuntime)1 TitusRuntimes (com.netflix.titus.common.runtime.TitusRuntimes)1 Clocks (com.netflix.titus.common.util.time.Clocks)1 TestClock (com.netflix.titus.common.util.time.TestClock)1 ConsumptionResult (com.netflix.titus.master.eviction.service.quota.ConsumptionResult)1 QuotaController (com.netflix.titus.master.eviction.service.quota.QuotaController)1 QuotaTracker (com.netflix.titus.master.eviction.service.quota.QuotaTracker)1 TimeWindowQuotaTracker (com.netflix.titus.master.eviction.service.quota.TimeWindowQuotaTracker)1 JobQuotaController.buildQuotaControllers (com.netflix.titus.master.eviction.service.quota.job.JobQuotaController.buildQuotaControllers)1 JobQuotaController.buildQuotaTrackers (com.netflix.titus.master.eviction.service.quota.job.JobQuotaController.buildQuotaTrackers)1 JobQuotaController.mergeQuotaControllers (com.netflix.titus.master.eviction.service.quota.job.JobQuotaController.mergeQuotaControllers)1 DisruptionBudgetGenerator.budget (com.netflix.titus.testkit.model.eviction.DisruptionBudgetGenerator.budget)1