Search in sources :

Example 1 with Version

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

the class JobReconciliationFrameworkFactory method validateTask.

private Optional<Task> validateTask(Task task) {
    // Perform strict validation for reporting purposes
    Set<ValidationError> strictViolations = strictEntitySanitizer.validate(task);
    if (!strictViolations.isEmpty()) {
        logger.error("No strictly consistent task record found: taskId={}, violations={}", task.getId(), EntitySanitizerUtil.toStringMap(strictViolations));
        errorCollector.strictlyInvalidTask(task.getId());
    }
    // Required checks
    Set<ValidationError> violations = permissiveEntitySanitizer.validate(task);
    if (!violations.isEmpty()) {
        logger.error("Bad task record found: taskId={}, violations={}", task.getId(), EntitySanitizerUtil.toStringMap(violations));
        if (jobManagerConfiguration.isFailOnDataValidation()) {
            return Optional.empty();
        }
    }
    // If version is missing (old task objects) create one based on the current task state.
    Task taskWithVersion = task;
    if (task.getVersion() == null || task.getVersion().getTimestamp() < 0) {
        Version newVersion = Version.newBuilder().withTimestamp(task.getStatus().getTimestamp()).build();
        taskWithVersion = task.toBuilder().withVersion(newVersion).build();
    }
    return Optional.of(taskWithVersion);
}
Also used : Task(com.netflix.titus.api.jobmanager.model.job.Task) Version(com.netflix.titus.api.jobmanager.model.job.Version) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError)

Example 2 with Version

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

the class JobReconciliationFrameworkFactory method validateJob.

private Optional<Job> validateJob(Job job) {
    // Perform strict validation for reporting purposes
    Set<ValidationError> strictViolations = strictEntitySanitizer.validate(job);
    if (!strictViolations.isEmpty()) {
        logger.error("No strictly consistent job record found: jobId={}, violations={}", job.getId(), EntitySanitizerUtil.toStringMap(strictViolations));
        errorCollector.strictlyInvalidJob(job.getId());
    }
    // Required checks
    Set<ValidationError> violations = permissiveEntitySanitizer.validate(job);
    if (!violations.isEmpty()) {
        logger.error("Bad job record found: jobId={}, violations={}", job.getId(), EntitySanitizerUtil.toStringMap(violations));
        if (jobManagerConfiguration.isFailOnDataValidation()) {
            return Optional.empty();
        }
    }
    // If version is missing (old job objects) create one based on the current job state.
    Job jobWithVersion = job;
    if (job.getVersion() == null || job.getVersion().getTimestamp() < 0) {
        Version newVersion = Version.newBuilder().withTimestamp(job.getStatus().getTimestamp()).build();
        jobWithVersion = job.toBuilder().withVersion(newVersion).build();
    }
    return Optional.of(jobWithVersion);
}
Also used : Version(com.netflix.titus.api.jobmanager.model.job.Version) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) Job(com.netflix.titus.api.jobmanager.model.job.Job)

Aggregations

Version (com.netflix.titus.api.jobmanager.model.job.Version)2 ValidationError (com.netflix.titus.common.model.sanitizer.ValidationError)2 Job (com.netflix.titus.api.jobmanager.model.job.Job)1 Task (com.netflix.titus.api.jobmanager.model.job.Task)1