use of com.netflix.titus.api.jobmanager.model.job.vpc.SignedIpAddressAllocation in project titus-control-plane by Netflix.
the class JobAssertionsTest method testEbsAndIpZoneMatchValidation.
@Test
public void testEbsAndIpZoneMatchValidation() {
int size = 4;
List<String> availabilityZones = JobEbsVolumeGenerator.availabilityZones().getValues(size);
List<EbsVolume> ebsVolumes = JobEbsVolumeGenerator.jobEbsVolumes(size).toList();
List<SignedIpAddressAllocation> ipAddressAllocations = JobIpAllocationGenerator.jobIpAllocations(size).toList();
for (int i = 0; i < size; i++) {
String az = availabilityZones.get(i);
EbsVolume updatedEbsVolume = ebsVolumes.get(i).toBuilder().withVolumeAvailabilityZone(az).build();
ebsVolumes.set(i, updatedEbsVolume);
SignedIpAddressAllocation updatedIpAllocation = ipAddressAllocations.get(i).toBuilder().withIpAddressAllocation(ipAddressAllocations.get(i).getIpAddressAllocation().toBuilder().withIpAddressLocation(ipAddressAllocations.get(i).getIpAddressAllocation().getIpAddressLocation().toBuilder().withAvailabilityZone(az).build()).build()).build();
ipAddressAllocations.set(i, updatedIpAllocation);
}
Map<String, String> violations = jobAssertions.matchingEbsAndIpZones(ebsVolumes, ipAddressAllocations);
assertThat(violations).hasSize(0);
}
use of com.netflix.titus.api.jobmanager.model.job.vpc.SignedIpAddressAllocation in project titus-control-plane by Netflix.
the class JobAssertions method validateMatchingEbsAndIpZones.
public static Set<ValidationError> validateMatchingEbsAndIpZones(List<EbsVolume> ebsVolumes, List<SignedIpAddressAllocation> ipSignedAddressAllocations) {
if (ebsVolumes == null || ipSignedAddressAllocations == null) {
return Collections.emptySet();
}
if (ebsVolumes.isEmpty() || ipSignedAddressAllocations.isEmpty()) {
return Collections.emptySet();
}
int numElements = Math.min(ebsVolumes.size(), ipSignedAddressAllocations.size());
for (int i = 0; i < numElements; i++) {
EbsVolume ebsVolume = ebsVolumes.get(i);
IpAddressAllocation ipAddressAllocation = ipSignedAddressAllocations.get(i).getIpAddressAllocation();
if (!ebsVolume.getVolumeAvailabilityZone().equals(ipAddressAllocation.getIpAddressLocation().getAvailabilityZone())) {
return Collections.singleton(new ValidationError("containerResources.ebsVolumes", String.format("EBS volume %s zone %s conflicts with Static IP %s zone %s and index %d", ebsVolume.getVolumeId(), ebsVolume.getVolumeAvailabilityZone(), ipAddressAllocation.getAllocationId(), ipAddressAllocation.getIpAddressLocation().getAvailabilityZone(), i)));
}
}
return Collections.emptySet();
}
use of com.netflix.titus.api.jobmanager.model.job.vpc.SignedIpAddressAllocation in project titus-control-plane by Netflix.
the class DefaultPodAffinityFactoryTest method testIpAllocationAzAffinity.
@Test
public void testIpAllocationAzAffinity() {
Job<BatchJobExt> job = JobGenerator.oneBatchJob();
List<SignedIpAddressAllocation> ipAddressAllocations = JobIpAllocationGenerator.jobIpAllocations(1).toList();
job = job.toBuilder().withJobDescriptor(JobFunctions.jobWithIpAllocations(job.getJobDescriptor(), ipAddressAllocations)).build();
Pair<V1Affinity, Map<String, String>> affinityWithAnnotations = factory.buildV1Affinity(job, JobIpAllocationGenerator.appendIpAllocationAttribute(JobGenerator.oneBatchTask(), ipAddressAllocations.get(0).getIpAddressAllocation().getAllocationId()));
V1NodeSelector nodeSelector = affinityWithAnnotations.getLeft().getNodeAffinity().getRequiredDuringSchedulingIgnoredDuringExecution();
assertThat(nodeSelector.getNodeSelectorTerms()).hasSize(1);
assertThat(nodeSelector.getNodeSelectorTerms().get(0).getMatchExpressions().get(0).getKey()).isEqualTo(KubeConstants.NODE_LABEL_ZONE);
assertThat(nodeSelector.getNodeSelectorTerms().get(0).getMatchExpressions().get(0).getValues().get(0)).isEqualTo(ipAddressAllocations.get(0).getIpAddressAllocation().getIpAddressLocation().getAvailabilityZone());
}
use of com.netflix.titus.api.jobmanager.model.job.vpc.SignedIpAddressAllocation in project titus-control-plane by Netflix.
the class JobAssertionsTest method testEbsAndIpZoneDoNotMatchValidation.
@Test
public void testEbsAndIpZoneDoNotMatchValidation() {
int size = 4;
List<String> availabilityZones = JobEbsVolumeGenerator.availabilityZones().getValues(size);
List<EbsVolume> ebsVolumes = JobEbsVolumeGenerator.jobEbsVolumes(size).toList();
List<SignedIpAddressAllocation> ipAddressAllocations = JobIpAllocationGenerator.jobIpAllocations(size).toList();
for (int i = 0; i < size; i++) {
String az = availabilityZones.get(i);
EbsVolume updatedEbsVolume = ebsVolumes.get(i).toBuilder().withVolumeAvailabilityZone(az).build();
ebsVolumes.set(i, updatedEbsVolume);
}
Map<String, String> violations = jobAssertions.matchingEbsAndIpZones(ebsVolumes, ipAddressAllocations);
assertThat(violations).hasSize(1);
}
Aggregations