Search in sources :

Example 1 with IpAddressAllocation

use of com.netflix.titus.api.jobmanager.model.job.vpc.IpAddressAllocation 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();
}
Also used : SignedIpAddressAllocation(com.netflix.titus.api.jobmanager.model.job.vpc.SignedIpAddressAllocation) IpAddressAllocation(com.netflix.titus.api.jobmanager.model.job.vpc.IpAddressAllocation) EbsVolume(com.netflix.titus.api.jobmanager.model.job.ebs.EbsVolume) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError)

Aggregations

EbsVolume (com.netflix.titus.api.jobmanager.model.job.ebs.EbsVolume)1 IpAddressAllocation (com.netflix.titus.api.jobmanager.model.job.vpc.IpAddressAllocation)1 SignedIpAddressAllocation (com.netflix.titus.api.jobmanager.model.job.vpc.SignedIpAddressAllocation)1 ValidationError (com.netflix.titus.common.model.sanitizer.ValidationError)1