Search in sources :

Example 1 with DisruptionBudgetPolicy

use of com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetPolicy 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 DisruptionBudgetPolicy

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

the class JobQuotaController method mergeQuotaControllers.

@VisibleForTesting
static List<QuotaController<Job<?>>> mergeQuotaControllers(List<QuotaController<Job<?>>> previousControllers, Job<?> job, V3JobOperations jobOperations, EffectiveJobDisruptionBudgetResolver effectiveDisruptionBudgetResolver, TitusRuntime titusRuntime) {
    List<QuotaController<Job<?>>> quotaControllers = new ArrayList<>();
    DisruptionBudget effectiveBudget = effectiveDisruptionBudgetResolver.resolve(job);
    if (effectiveBudget.getDisruptionBudgetRate() instanceof PercentagePerHourDisruptionBudgetRate) {
        QuotaController<Job<?>> newController = mergeQuotaController(job, previousControllers, JobPercentagePerHourRelocationRateController.class, () -> JobPercentagePerHourRelocationRateController.newJobPercentagePerHourRelocationRateController(job, effectiveDisruptionBudgetResolver, titusRuntime));
        quotaControllers.add(newController);
    } else if (effectiveBudget.getDisruptionBudgetRate() instanceof RatePercentagePerIntervalDisruptionBudgetRate) {
        QuotaController<Job<?>> newController = mergeQuotaController(job, previousControllers, JobPercentagePerIntervalRateController.class, () -> JobPercentagePerIntervalRateController.newJobPercentagePerIntervalRateController(job, effectiveDisruptionBudgetResolver, titusRuntime));
        quotaControllers.add(newController);
    } else if (effectiveBudget.getDisruptionBudgetRate() instanceof RatePerIntervalDisruptionBudgetRate) {
        QuotaController<Job<?>> newController = mergeQuotaController(job, previousControllers, RatePerIntervalRateController.class, () -> RatePerIntervalRateController.newRatePerIntervalRateController(job, effectiveDisruptionBudgetResolver, titusRuntime));
        quotaControllers.add(newController);
    }
    DisruptionBudgetPolicy policy = effectiveBudget.getDisruptionBudgetPolicy();
    if (policy instanceof RelocationLimitDisruptionBudgetPolicy) {
        QuotaController<Job<?>> newController = mergeQuotaController(job, previousControllers, TaskRelocationLimitController.class, () -> new TaskRelocationLimitController(job, jobOperations, effectiveDisruptionBudgetResolver));
        quotaControllers.add(newController);
    }
    return quotaControllers;
}
Also used : 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) RelocationLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RelocationLimitDisruptionBudgetPolicy) DisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetPolicy) AvailabilityPercentageLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.AvailabilityPercentageLimitDisruptionBudgetPolicy) QuotaController(com.netflix.titus.master.eviction.service.quota.QuotaController) DisruptionBudget(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudget) ArrayList(java.util.ArrayList) RelocationLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RelocationLimitDisruptionBudgetPolicy) RatePercentagePerIntervalDisruptionBudgetRate(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RatePercentagePerIntervalDisruptionBudgetRate) Job(com.netflix.titus.api.jobmanager.model.job.Job) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with DisruptionBudgetPolicy

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

the class DefaultTopologyFactory method getJobMaxSkew.

/**
 * Get max skew from a job descriptor or compute a value based on the job type and its configured disruption budget.
 *
 * @return -1 if max skew not set or is invalid
 */
private int getJobMaxSkew(Job<?> job) {
    String maxSkewAttr = job.getJobDescriptor().getAttributes().get(JobAttributes.JOB_ATTRIBUTES_SPREADING_MAX_SKEW);
    if (maxSkewAttr != null) {
        try {
            int maxSkew = Integer.parseInt(maxSkewAttr);
            if (maxSkew > 0) {
                return maxSkew;
            }
        } catch (Exception ignore) {
        }
    }
    DisruptionBudgetPolicy policy = job.getJobDescriptor().getDisruptionBudget().getDisruptionBudgetPolicy();
    // Job spreading is only relevant for jobs that care about the availability.
    if (!(policy instanceof AvailabilityPercentageLimitDisruptionBudgetPolicy)) {
        return -1;
    }
    int jobSize = getJobDesiredSize(job);
    if (jobSize <= 1) {
        return -1;
    }
    double alpha = configuration.getJobSpreadingSkewAlpha();
    if (alpha <= 0) {
        return -1;
    }
    int skew = (int) (Math.floor(jobSize / alpha));
    // The skew must be between 1 and the configured max skew.
    return Math.max(1, Math.min(skew, configuration.getJobSpreadingMaxSkew()));
}
Also used : DisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetPolicy) AvailabilityPercentageLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.AvailabilityPercentageLimitDisruptionBudgetPolicy) AvailabilityPercentageLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.AvailabilityPercentageLimitDisruptionBudgetPolicy) V1TopologySpreadConstraint(io.kubernetes.client.openapi.models.V1TopologySpreadConstraint)

Example 4 with DisruptionBudgetPolicy

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

the class JobQuotaController method buildQuotaTrackers.

@VisibleForTesting
static List<QuotaTracker> buildQuotaTrackers(Job<?> job, V3JobOperations jobOperations, EffectiveJobDisruptionBudgetResolver effectiveDisruptionBudgetResolver, ContainerHealthService containerHealthService, TitusRuntime titusRuntime) {
    List<QuotaTracker> quotaTrackers = new ArrayList<>();
    DisruptionBudget effectiveBudget = effectiveDisruptionBudgetResolver.resolve(job);
    if (!effectiveBudget.getTimeWindows().isEmpty()) {
        quotaTrackers.add(new TimeWindowQuotaTracker(effectiveBudget.getTimeWindows(), titusRuntime));
    }
    DisruptionBudgetPolicy policy = effectiveBudget.getDisruptionBudgetPolicy();
    if (policy instanceof AvailabilityPercentageLimitDisruptionBudgetPolicy) {
        quotaTrackers.add(UnhealthyTasksLimitTracker.percentageLimit(job, (AvailabilityPercentageLimitDisruptionBudgetPolicy) policy, jobOperations, containerHealthService));
    } else if (policy instanceof UnhealthyTasksLimitDisruptionBudgetPolicy) {
        quotaTrackers.add(UnhealthyTasksLimitTracker.absoluteLimit(job, (UnhealthyTasksLimitDisruptionBudgetPolicy) policy, jobOperations, containerHealthService));
    }
    return quotaTrackers;
}
Also used : TimeWindowQuotaTracker(com.netflix.titus.master.eviction.service.quota.TimeWindowQuotaTracker) QuotaTracker(com.netflix.titus.master.eviction.service.quota.QuotaTracker) UnhealthyTasksLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.UnhealthyTasksLimitDisruptionBudgetPolicy) RelocationLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RelocationLimitDisruptionBudgetPolicy) DisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetPolicy) AvailabilityPercentageLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.AvailabilityPercentageLimitDisruptionBudgetPolicy) DisruptionBudget(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudget) ArrayList(java.util.ArrayList) TimeWindowQuotaTracker(com.netflix.titus.master.eviction.service.quota.TimeWindowQuotaTracker) UnhealthyTasksLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.UnhealthyTasksLimitDisruptionBudgetPolicy) AvailabilityPercentageLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.AvailabilityPercentageLimitDisruptionBudgetPolicy) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 5 with DisruptionBudgetPolicy

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

the class JobQuotaController method buildQuotaControllers.

@VisibleForTesting
static List<QuotaController<Job<?>>> buildQuotaControllers(Job<?> job, V3JobOperations jobOperations, EffectiveJobDisruptionBudgetResolver effectiveDisruptionBudgetResolver, TitusRuntime titusRuntime) {
    List<QuotaController<Job<?>>> quotaControllers = new ArrayList<>();
    DisruptionBudget effectiveBudget = effectiveDisruptionBudgetResolver.resolve(job);
    if (effectiveBudget.getDisruptionBudgetRate() instanceof PercentagePerHourDisruptionBudgetRate) {
        quotaControllers.add(JobPercentagePerHourRelocationRateController.newJobPercentagePerHourRelocationRateController(job, effectiveDisruptionBudgetResolver, titusRuntime));
    } else if (effectiveBudget.getDisruptionBudgetRate() instanceof RatePercentagePerIntervalDisruptionBudgetRate) {
        quotaControllers.add(JobPercentagePerIntervalRateController.newJobPercentagePerIntervalRateController(job, effectiveDisruptionBudgetResolver, titusRuntime));
    } else if (effectiveBudget.getDisruptionBudgetRate() instanceof RatePerIntervalDisruptionBudgetRate) {
        quotaControllers.add(RatePerIntervalRateController.newRatePerIntervalRateController(job, effectiveDisruptionBudgetResolver, titusRuntime));
    }
    DisruptionBudgetPolicy policy = effectiveBudget.getDisruptionBudgetPolicy();
    if (policy instanceof RelocationLimitDisruptionBudgetPolicy) {
        quotaControllers.add(new TaskRelocationLimitController(job, jobOperations, effectiveDisruptionBudgetResolver));
    }
    return quotaControllers;
}
Also used : PercentagePerHourDisruptionBudgetRate(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.PercentagePerHourDisruptionBudgetRate) RatePerIntervalDisruptionBudgetRate(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RatePerIntervalDisruptionBudgetRate) RelocationLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RelocationLimitDisruptionBudgetPolicy) UnhealthyTasksLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.UnhealthyTasksLimitDisruptionBudgetPolicy) RelocationLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RelocationLimitDisruptionBudgetPolicy) DisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetPolicy) AvailabilityPercentageLimitDisruptionBudgetPolicy(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.AvailabilityPercentageLimitDisruptionBudgetPolicy) QuotaController(com.netflix.titus.master.eviction.service.quota.QuotaController) RatePercentagePerIntervalDisruptionBudgetRate(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RatePercentagePerIntervalDisruptionBudgetRate) DisruptionBudget(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudget) ArrayList(java.util.ArrayList) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

AvailabilityPercentageLimitDisruptionBudgetPolicy (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.AvailabilityPercentageLimitDisruptionBudgetPolicy)5 DisruptionBudgetPolicy (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetPolicy)5 RelocationLimitDisruptionBudgetPolicy (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RelocationLimitDisruptionBudgetPolicy)4 UnhealthyTasksLimitDisruptionBudgetPolicy (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.UnhealthyTasksLimitDisruptionBudgetPolicy)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 DisruptionBudget (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudget)3 PercentagePerHourDisruptionBudgetRate (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.PercentagePerHourDisruptionBudgetRate)3 RatePerIntervalDisruptionBudgetRate (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RatePerIntervalDisruptionBudgetRate)3 RatePercentagePerIntervalDisruptionBudgetRate (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RatePercentagePerIntervalDisruptionBudgetRate)3 ArrayList (java.util.ArrayList)3 QuotaController (com.netflix.titus.master.eviction.service.quota.QuotaController)2 Job (com.netflix.titus.api.jobmanager.model.job.Job)1 DisruptionBudgetRate (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetRate)1 SelfManagedDisruptionBudgetPolicy (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.SelfManagedDisruptionBudgetPolicy)1 UnlimitedDisruptionBudgetRate (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.UnlimitedDisruptionBudgetRate)1 JobDisruptionBudget (com.netflix.titus.grpc.protogen.JobDisruptionBudget)1 QuotaTracker (com.netflix.titus.master.eviction.service.quota.QuotaTracker)1 TimeWindowQuotaTracker (com.netflix.titus.master.eviction.service.quota.TimeWindowQuotaTracker)1 V1TopologySpreadConstraint (io.kubernetes.client.openapi.models.V1TopologySpreadConstraint)1