Search in sources :

Example 1 with DisruptionBudget

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

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

the class DefaultJobManagementServiceGrpc method validateAndConvertJobDisruptionBudgetToCoreModel.

private Optional<DisruptionBudget> validateAndConvertJobDisruptionBudgetToCoreModel(com.netflix.titus.api.jobmanager.model.job.Job<?> coreJob, JobDisruptionBudget grpcDisruptionBudget, StreamObserver<Empty> responseObserver) {
    DisruptionBudget coreDisruptionBudget;
    try {
        coreDisruptionBudget = GrpcJobManagementModelConverters.toCoreDisruptionBudget(grpcDisruptionBudget);
    } catch (Exception e) {
        safeOnError(logger, TitusServiceException.invalidArgument("Error when converting GRPC disruption budget to the internal model: " + e.getMessage()), responseObserver);
        return Optional.empty();
    }
    DisruptionBudget sanitizedCoreDisruptionBudget = entitySanitizer.sanitize(coreDisruptionBudget).orElse(coreDisruptionBudget);
    Set<ValidationError> violations = entitySanitizer.validate(sanitizedCoreDisruptionBudget);
    if (!violations.isEmpty()) {
        safeOnError(logger, TitusServiceException.invalidArgument(violations), responseObserver);
        return Optional.empty();
    }
    return Optional.of(sanitizedCoreDisruptionBudget);
}
Also used : DisruptionBudget(com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudget) JobDisruptionBudget(com.netflix.titus.grpc.protogen.JobDisruptionBudget) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) StatusRuntimeException(io.grpc.StatusRuntimeException) TitusServiceException(com.netflix.titus.api.service.TitusServiceException) JobManagerException(com.netflix.titus.api.jobmanager.service.JobManagerException)

Example 3 with DisruptionBudget

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

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

Example 5 with DisruptionBudget

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

Aggregations

DisruptionBudget (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudget)5 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 AvailabilityPercentageLimitDisruptionBudgetPolicy (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.AvailabilityPercentageLimitDisruptionBudgetPolicy)3 DisruptionBudgetPolicy (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.DisruptionBudgetPolicy)3 RelocationLimitDisruptionBudgetPolicy (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RelocationLimitDisruptionBudgetPolicy)3 UnhealthyTasksLimitDisruptionBudgetPolicy (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.UnhealthyTasksLimitDisruptionBudgetPolicy)3 ArrayList (java.util.ArrayList)3 PercentagePerHourDisruptionBudgetRate (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.PercentagePerHourDisruptionBudgetRate)2 RatePerIntervalDisruptionBudgetRate (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RatePerIntervalDisruptionBudgetRate)2 RatePercentagePerIntervalDisruptionBudgetRate (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.RatePercentagePerIntervalDisruptionBudgetRate)2 ValidationError (com.netflix.titus.common.model.sanitizer.ValidationError)2 QuotaController (com.netflix.titus.master.eviction.service.quota.QuotaController)2 Job (com.netflix.titus.api.jobmanager.model.job.Job)1 SelfManagedDisruptionBudgetPolicy (com.netflix.titus.api.jobmanager.model.job.disruptionbudget.SelfManagedDisruptionBudgetPolicy)1 JobManagerException (com.netflix.titus.api.jobmanager.service.JobManagerException)1 TitusServiceException (com.netflix.titus.api.service.TitusServiceException)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 StatusRuntimeException (io.grpc.StatusRuntimeException)1