use of com.netflix.titus.common.model.sanitizer.ValidationError in project titus-control-plane by Netflix.
the class AggregatingValidatorTest method validateHardPassTimeout.
@Test
public void validateHardPassTimeout() {
AdmissionValidator pass = new PassJobValidator();
AdmissionValidator never = new NeverJobValidator(ValidationError.Type.HARD);
AdmissionValidator validator = new AggregatingValidator(configuration, registry, Arrays.asList(pass, never));
Mono<Set<ValidationError>> mono = validator.validate(MOCK_JOB);
StepVerifier.create(mono).expectNextMatches(errors -> errors.size() == 1).verifyComplete();
Set<ValidationError> errors = mono.block();
validateTimeoutErrors(errors);
validateErrorType(errors, ValidationError.Type.HARD);
}
use of com.netflix.titus.common.model.sanitizer.ValidationError in project titus-control-plane by Netflix.
the class SanitizingJobServiceGateway method updateJobCapacity.
@Override
public Completable updateJobCapacity(JobCapacityUpdate jobCapacityUpdate, CallMetadata callMetadata) {
Capacity newCapacity = GrpcJobManagementModelConverters.toCoreCapacity(jobCapacityUpdate.getCapacity());
Set<ValidationError> violations = entitySanitizer.validate(newCapacity);
if (!violations.isEmpty()) {
return Completable.error(TitusServiceException.invalidArgument(violations));
}
return delegate.updateJobCapacity(jobCapacityUpdate, callMetadata);
}
use of com.netflix.titus.common.model.sanitizer.ValidationError in project titus-control-plane by Netflix.
the class SanitizingJobServiceGateway method updateJobCapacityWithOptionalAttributes.
@Override
public Completable updateJobCapacityWithOptionalAttributes(JobCapacityUpdateWithOptionalAttributes jobCapacityUpdateWithOptionalAttributes, CallMetadata callMetadata) {
final JobCapacityWithOptionalAttributes jobCapacityWithOptionalAttributes = jobCapacityUpdateWithOptionalAttributes.getJobCapacityWithOptionalAttributes();
CapacityAttributes capacityAttributes = GrpcJobManagementModelConverters.toCoreCapacityAttributes(jobCapacityWithOptionalAttributes);
Set<ValidationError> violations = entitySanitizer.validate(capacityAttributes);
if (!violations.isEmpty()) {
return Completable.error(TitusServiceException.invalidArgument(violations));
}
return delegate.updateJobCapacityWithOptionalAttributes(jobCapacityUpdateWithOptionalAttributes, callMetadata);
}
use of com.netflix.titus.common.model.sanitizer.ValidationError 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