public Optional<Allocation> findAllocation(Allocation.Context context, LockedNodeList nodes) {
            if (ipAddresses.addresses.isEmpty()) {
                // IP addresses have not yet been resolved and should be done later.
                return findUnusedHostnames(nodes).map(Allocation::ofHostname)
                                                 .findFirst();
            }

            List<String> unusedIps = findUnusedIpAddresses(nodes);

            if (context.allocateFromUnusedHostname())
                return findUnusedHostnames(nodes).findFirst().map(hostname -> Allocation.fromHostname(context, hostname, ipAddresses.stack, unusedIps));

            if (ipAddresses.stack == IpAddresses.Stack.ipv4) {
                return unusedIps.stream()
                                .findFirst()
                                .map(addr -> Allocation.ofIpv4(addr, context.resolver()));
            }

            var allocation = unusedIps.stream()
                                      .filter(IP::isV6)
                                      .findFirst()
                                      .map(addr -> Allocation.ofIpv6(addr, context.resolver()));
            allocation.flatMap(Allocation::ipv4Address).ifPresent(ipv4Address -> {
                if (!unusedIps.contains(ipv4Address)) {
                    throw new IllegalArgumentException("Allocation resolved " + ipv4Address + " from hostname " +
                                                       allocation.get().hostname +
                                                       ", but that address is not owned by this node");
                }
            });
            return allocation;
        }
Find a free allocation in this pool. Note that the allocation is not final until it is assigned to a node

<p>TODO(2023-09-20): Once all dynamically provisioned hosts have been reprovisioned, the order of IP addresses
is significant and should be 1:1 with the order of hostnames, if both are filled.  This needs to be verified.
This can be used to strengthen validation, and simplify the selection of the Allocation to return.</p>

@param context allocation context
@param nodes   a locked list of all nodes in the repository
@return an allocation from the pool, if any can be made
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/IP.java