Search in sources :

Example 1 with Image

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

the class JobDescriptorGenerator method oneTaskBatchJobDescriptor.

public static JobDescriptor<BatchJobExt> oneTaskBatchJobDescriptor() {
    JobDescriptor<BatchJobExt> jobDescriptor = batchJobDescriptors().getValue();
    Image imageWithTag = JobModel.newImage().withName("titusops/alpine").withTag("latest").build();
    return JobModel.newJobDescriptor(jobDescriptor).withContainer(JobModel.newContainer(jobDescriptor.getContainer()).withImage(imageWithTag).build()).withDisruptionBudget(DisruptionBudgetGenerator.budget(DisruptionBudgetGenerator.perTaskRelocationLimitPolicy(3), DisruptionBudgetGenerator.hourlyRatePercentage(50), Collections.singletonList(DisruptionBudgetGenerator.officeHourTimeWindow()))).withExtensions(JobModel.newBatchJobExt(jobDescriptor.getExtensions()).withSize(1).withRetryPolicy(JobModel.newImmediateRetryPolicy().withRetries(0).build()).build()).withExtraContainers(jobDescriptor.getExtraContainers()).withPlatformSidecars(jobDescriptor.getPlatformSidecars()).build();
}
Also used : BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) Image(com.netflix.titus.api.jobmanager.model.job.Image)

Example 2 with Image

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

the class JobDescriptorGenerator method oneTaskServiceJobDescriptor.

public static JobDescriptor<ServiceJobExt> oneTaskServiceJobDescriptor() {
    JobDescriptor<ServiceJobExt> jobDescriptor = serviceJobDescriptors().getValue();
    Image imageWithTag = JobModel.newImage().withName("titusops/alpine").withTag("latest").build();
    return JobModel.newJobDescriptor(jobDescriptor).withContainer(JobModel.newContainer(jobDescriptor.getContainer()).withImage(imageWithTag).build()).withDisruptionBudget(DisruptionBudgetGenerator.budget(DisruptionBudgetGenerator.perTaskRelocationLimitPolicy(3), DisruptionBudgetGenerator.hourlyRatePercentage(50), Collections.singletonList(DisruptionBudgetGenerator.officeHourTimeWindow()))).withExtensions(JobModel.newServiceJobExt(jobDescriptor.getExtensions()).withCapacity(Capacity.newBuilder().withMin(0).withDesired(1).withMax(2).build()).withRetryPolicy(JobModel.newImmediateRetryPolicy().withRetries(0).build()).withMigrationPolicy(JobModel.newSystemDefaultMigrationPolicy().build()).withEnabled(true).withServiceJobProcesses(ServiceJobProcesses.newBuilder().build()).build()).build();
}
Also used : ServiceJobExt(com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt) Image(com.netflix.titus.api.jobmanager.model.job.Image)

Example 3 with Image

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

the class JobAssertionsTest method testImageDigestValidation.

@Test
public void testImageDigestValidation() {
    Image image = Image.newBuilder().withName("imageName").withDigest("sha256:abcdef0123456789abcdef0123456789abcdef0123456789").build();
    Map<String, String> violations = jobAssertions.validateImage(image);
    assertThat(violations).isEmpty();
}
Also used : Image(com.netflix.titus.api.jobmanager.model.job.Image) Test(org.junit.Test)

Example 4 with Image

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

the class JobAssertionsTest method testInvalidDigestValidation.

@Test
public void testInvalidDigestValidation() {
    Image image = Image.newBuilder().withName("imageName").withDigest("sha256:XYZ").build();
    Map<String, String> violations = jobAssertions.validateImage(image);
    assertThat(violations).hasSize(1);
}
Also used : Image(com.netflix.titus.api.jobmanager.model.job.Image) Test(org.junit.Test)

Example 5 with Image

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

the class JobImageSanitizerTest method testJobWithDigestExists.

@Test
public void testJobWithDigestExists() {
    Image image = jobDescriptorWithDigest.getContainer().getImage();
    when(registryClient.getImageDigest(image.getName(), image.getDigest())).thenReturn(Mono.just(digest));
    StepVerifier.create(sanitizer.sanitize(jobDescriptorWithDigest)).expectNextCount(// nothing to do when digest is valid
    0).verifyComplete();
}
Also used : Image(com.netflix.titus.api.jobmanager.model.job.Image) Test(org.junit.Test)

Aggregations

Image (com.netflix.titus.api.jobmanager.model.job.Image)7 Test (org.junit.Test)4 BatchJobExt (com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt)3 ServiceJobExt (com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt)2 BasicContainer (com.netflix.titus.api.jobmanager.model.job.BasicContainer)1 BatchJobTask (com.netflix.titus.api.jobmanager.model.job.BatchJobTask)1 Capacity (com.netflix.titus.api.jobmanager.model.job.Capacity)1 Container (com.netflix.titus.api.jobmanager.model.job.Container)1 ContainerResources (com.netflix.titus.api.jobmanager.model.job.ContainerResources)1 JobDescriptor (com.netflix.titus.api.jobmanager.model.job.JobDescriptor)1 JobGroupInfo (com.netflix.titus.api.jobmanager.model.job.JobGroupInfo)1 V1Affinity (io.kubernetes.client.openapi.models.V1Affinity)1 V1Container (io.kubernetes.client.openapi.models.V1Container)1 V1Pod (io.kubernetes.client.openapi.models.V1Pod)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1