Search in sources :

Example 1 with SelfManagedDisruptionBudgetPolicy

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

the class GrpcJobManagementModelConverters method toGrpcDisruptionBudget.

public static com.netflix.titus.grpc.protogen.JobDisruptionBudget toGrpcDisruptionBudget(DisruptionBudget coreDisruptionBudget) {
    JobDisruptionBudget.Builder builder = JobDisruptionBudget.newBuilder();
    DisruptionBudgetPolicy disruptionBudgetPolicy = coreDisruptionBudget.getDisruptionBudgetPolicy();
    if (disruptionBudgetPolicy instanceof SelfManagedDisruptionBudgetPolicy) {
        builder.setSelfManaged(JobDisruptionBudget.SelfManaged.newBuilder().setRelocationTimeMs(((SelfManagedDisruptionBudgetPolicy) disruptionBudgetPolicy).getRelocationTimeMs()));
    } else if (disruptionBudgetPolicy instanceof AvailabilityPercentageLimitDisruptionBudgetPolicy) {
        builder.setAvailabilityPercentageLimit(JobDisruptionBudget.AvailabilityPercentageLimit.newBuilder().setPercentageOfHealthyContainers(((AvailabilityPercentageLimitDisruptionBudgetPolicy) disruptionBudgetPolicy).getPercentageOfHealthyContainers()));
    } else if (disruptionBudgetPolicy instanceof UnhealthyTasksLimitDisruptionBudgetPolicy) {
        builder.setUnhealthyTasksLimit(JobDisruptionBudget.UnhealthyTasksLimit.newBuilder().setLimitOfUnhealthyContainers(((UnhealthyTasksLimitDisruptionBudgetPolicy) disruptionBudgetPolicy).getLimitOfUnhealthyContainers()));
    } else if (disruptionBudgetPolicy instanceof RelocationLimitDisruptionBudgetPolicy) {
        builder.setRelocationLimit(JobDisruptionBudget.RelocationLimit.newBuilder().setLimit(((RelocationLimitDisruptionBudgetPolicy) disruptionBudgetPolicy).getLimit()));
    }
    DisruptionBudgetRate disruptionBudgetRate = coreDisruptionBudget.getDisruptionBudgetRate();
    if (disruptionBudgetRate instanceof UnlimitedDisruptionBudgetRate) {
        builder.setRateUnlimited(JobDisruptionBudget.RateUnlimited.newBuilder().build());
    } else if (disruptionBudgetRate instanceof PercentagePerHourDisruptionBudgetRate) {
        builder.setRatePercentagePerHour(JobDisruptionBudget.RatePercentagePerHour.newBuilder().setMaxPercentageOfContainersRelocatedInHour(((PercentagePerHourDisruptionBudgetRate) disruptionBudgetRate).getMaxPercentageOfContainersRelocatedInHour()));
    } else if (disruptionBudgetRate instanceof RatePerIntervalDisruptionBudgetRate) {
        RatePerIntervalDisruptionBudgetRate ratePerInterval = (RatePerIntervalDisruptionBudgetRate) disruptionBudgetRate;
        builder.setRatePerInterval(JobDisruptionBudget.RatePerInterval.newBuilder().setIntervalMs(ratePerInterval.getIntervalMs()).setLimitPerInterval(ratePerInterval.getLimitPerInterval()).build());
    } else if (disruptionBudgetRate instanceof RatePercentagePerIntervalDisruptionBudgetRate) {
        RatePercentagePerIntervalDisruptionBudgetRate ratePercentagePerInterval = (RatePercentagePerIntervalDisruptionBudgetRate) disruptionBudgetRate;
        builder.setRatePercentagePerInterval(JobDisruptionBudget.RatePercentagePerInterval.newBuilder().setIntervalMs(ratePercentagePerInterval.getIntervalMs()).setPercentageLimitPerInterval(ratePercentagePerInterval.getPercentageLimitPerInterval()).build());
    }
    return builder.addAllTimeWindows(toGrpcTimeWindows(coreDisruptionBudget.getTimeWindows())).addAllContainerHealthProviders(toGrpcContainerHealthProviders(coreDisruptionBudget.getContainerHealthProviders())).build();
}
Also used : PercentagePerHourDisruptionBudgetRate(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.PercentagePerHourDisruptionBudgetRate) RelocationLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RelocationLimitDisruptionBudgetPolicy) RatePerIntervalDisruptionBudgetRate(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RatePerIntervalDisruptionBudgetRate) JobDisruptionBudget(com.netflix.titus.grpc.protogen.JobDisruptionBudget) SelfManagedDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.SelfManagedDisruptionBudgetPolicy) AvailabilityPercentageLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.AvailabilityPercentageLimitDisruptionBudgetPolicy) DisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetPolicy) RelocationLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RelocationLimitDisruptionBudgetPolicy) UnhealthyTasksLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.UnhealthyTasksLimitDisruptionBudgetPolicy) SelfManagedDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.SelfManagedDisruptionBudgetPolicy) UnlimitedDisruptionBudgetRate(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.UnlimitedDisruptionBudgetRate) RatePercentagePerIntervalDisruptionBudgetRate(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RatePercentagePerIntervalDisruptionBudgetRate) DisruptionBudgetRate(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetRate) UnlimitedDisruptionBudgetRate(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.UnlimitedDisruptionBudgetRate) RatePercentagePerIntervalDisruptionBudgetRate(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RatePercentagePerIntervalDisruptionBudgetRate) PercentagePerHourDisruptionBudgetRate(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.PercentagePerHourDisruptionBudgetRate) RatePerIntervalDisruptionBudgetRate(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RatePerIntervalDisruptionBudgetRate) UnhealthyTasksLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.UnhealthyTasksLimitDisruptionBudgetPolicy) AvailabilityPercentageLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.AvailabilityPercentageLimitDisruptionBudgetPolicy)

Example 2 with SelfManagedDisruptionBudgetPolicy

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

the class ExtendedJobSanitizerTest method testLegacyBatchJobDisruptionBudgetRewrite.

@Test
public void testLegacyBatchJobDisruptionBudgetRewrite() {
    JobDescriptor<BatchJobExt> jobDescriptor = newBatchJob().getValue().toBuilder().withDisruptionBudget(DisruptionBudget.none()).build();
    ExtendedJobSanitizer sanitizer = new ExtendedJobSanitizer(configuration, jobAssertions, entitySanitizer, disruptionBudgetSanitizer, jd -> false, jd -> false, titusRuntime);
    Optional<JobDescriptor<BatchJobExt>> sanitizedOpt = sanitizer.sanitize(jobDescriptor);
    assertThat(sanitizedOpt).isNotEmpty();
    JobDescriptor<BatchJobExt> sanitized = sanitizedOpt.get();
    String nonCompliant = sanitized.getAttributes().get(TITUS_NON_COMPLIANT_FEATURES);
    assertThat(nonCompliant).contains(JobFeatureComplianceChecks.DISRUPTION_BUDGET_FEATURE);
    SelfManagedDisruptionBudgetPolicy policy = (SelfManagedDisruptionBudgetPolicy) sanitized.getDisruptionBudget().getDisruptionBudgetPolicy();
    assertThat(policy.getRelocationTimeMs()).isEqualTo((long) ((jobDescriptor.getExtensions()).getRuntimeLimitMs() * BATCH_RUNTIME_LIMIT_FACTOR));
}
Also used : SelfManagedDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.SelfManagedDisruptionBudgetPolicy) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) Test(org.junit.Test)

Example 3 with SelfManagedDisruptionBudgetPolicy

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

the class ExtendedJobSanitizerTest method testLegacyServiceJobDisruptionBudgetRewrite.

@Test
public void testLegacyServiceJobDisruptionBudgetRewrite() {
    JobDescriptor<ServiceJobExt> jobDescriptor = newServiceJob().getValue().toBuilder().withDisruptionBudget(DisruptionBudget.none()).build();
    ExtendedJobSanitizer sanitizer = new ExtendedJobSanitizer(configuration, jobAssertions, entitySanitizer, disruptionBudgetSanitizer, jd -> false, jd -> false, titusRuntime);
    Optional<JobDescriptor<ServiceJobExt>> sanitizedOpt = sanitizer.sanitize(jobDescriptor);
    assertThat(sanitizedOpt).isNotEmpty();
    JobDescriptor<ServiceJobExt> sanitized = sanitizedOpt.get();
    String nonCompliant = sanitized.getAttributes().get(TITUS_NON_COMPLIANT_FEATURES);
    assertThat(nonCompliant).contains(JobFeatureComplianceChecks.DISRUPTION_BUDGET_FEATURE);
    SelfManagedDisruptionBudgetPolicy policy = (SelfManagedDisruptionBudgetPolicy) sanitized.getDisruptionBudget().getDisruptionBudgetPolicy();
    assertThat(policy.getRelocationTimeMs()).isEqualTo(DisruptionBudgetSanitizer.DEFAULT_SERVICE_RELOCATION_TIME_MS);
}
Also used : SelfManagedDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.SelfManagedDisruptionBudgetPolicy) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor) ServiceJobExt(com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt) Test(org.junit.Test)

Example 4 with SelfManagedDisruptionBudgetPolicy

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

the class ArchaiusEffectiveJobDisruptionBudgetResolver method parse.

private DisruptionBudget parse(String newValue) throws Exception {
    DisruptionBudget budget = ObjectMappers.storeMapper().readValue(newValue, DisruptionBudget.class);
    Preconditions.checkArgument(!(budget.getDisruptionBudgetPolicy() instanceof SelfManagedDisruptionBudgetPolicy), "Self managed migration policy not allowed as a fallback");
    DisruptionBudget sanitized = sanitizer.sanitize(budget).orElse(budget);
    Set<ValidationError> violations = sanitizer.validate(sanitized);
    Preconditions.checkState(violations.isEmpty(), "Invalid self managed fallback disruption budget: value=%s, violations=%s", sanitized, violations);
    return sanitized;
}
Also used : SelfManagedDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.SelfManagedDisruptionBudgetPolicy) DisruptionBudget(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudget) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError)

Example 5 with SelfManagedDisruptionBudgetPolicy

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

the class MustBeRelocatedSelfManagedTaskCollectorStep method buildSelfManagedRelocationPlan.

/**
 * Relocation plans today are limited to self managed polices.
 */
private TaskRelocationPlan buildSelfManagedRelocationPlan(Job<?> job, Task task, String reason) {
    long now = clock.wallTime();
    SelfManagedDisruptionBudgetPolicy selfManaged = (SelfManagedDisruptionBudgetPolicy) job.getJobDescriptor().getDisruptionBudget().getDisruptionBudgetPolicy();
    TaskRelocationPlan relocationPlan = TaskRelocationPlan.newBuilder().withTaskId(task.getId()).withReason(TaskRelocationReason.SelfManagedMigration).withReasonMessage(reason).withDecisionTime(now).withRelocationTime(now + selfManaged.getRelocationTimeMs()).build();
    TaskRelocationPlan previous = lastResult.get(task.getId());
    boolean keepPrevious = previous != null && (areEqualExceptRelocationTime(previous, relocationPlan) || previous.getRelocationTime() < relocationPlan.getRelocationTime());
    return keepPrevious ? previous : relocationPlan;
}
Also used : SelfManagedDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.SelfManagedDisruptionBudgetPolicy) TaskRelocationPlan(com.netflix.titus.api.relocation.model.TaskRelocationPlan)

Aggregations

SelfManagedDisruptionBudgetPolicy (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.SelfManagedDisruptionBudgetPolicy)5 JobDescriptor (com.netflix.titus.api.jobmanager.model.job.JobDescriptor)2 Test (org.junit.Test)2 AvailabilityPercentageLimitDisruptionBudgetPolicy (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.AvailabilityPercentageLimitDisruptionBudgetPolicy)1 DisruptionBudget (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudget)1 DisruptionBudgetPolicy (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetPolicy)1 DisruptionBudgetRate (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetRate)1 PercentagePerHourDisruptionBudgetRate (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.PercentagePerHourDisruptionBudgetRate)1 RatePerIntervalDisruptionBudgetRate (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RatePerIntervalDisruptionBudgetRate)1 RatePercentagePerIntervalDisruptionBudgetRate (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RatePercentagePerIntervalDisruptionBudgetRate)1 RelocationLimitDisruptionBudgetPolicy (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RelocationLimitDisruptionBudgetPolicy)1 UnhealthyTasksLimitDisruptionBudgetPolicy (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.UnhealthyTasksLimitDisruptionBudgetPolicy)1 UnlimitedDisruptionBudgetRate (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.UnlimitedDisruptionBudgetRate)1 BatchJobExt (com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt)1 ServiceJobExt (com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt)1 TaskRelocationPlan (com.netflix.titus.api.relocation.model.TaskRelocationPlan)1 ValidationError (com.netflix.titus.common.model.sanitizer.ValidationError)1 JobDisruptionBudget (com.netflix.titus.grpc.protogen.JobDisruptionBudget)1