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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations