private Optional<NodeResources> nearestFlavorResources(NodeResources requestedResources) {
        return nodeRepository.flavors().getFlavors().stream()
                             .map(flavor -> nodeRepository.resourcesCalculator().advertisedResourcesOf(flavor))
                             .filter(resources -> resources.satisfies(requestedResources))
                             .min(Comparator.comparingDouble(resources -> resources.distanceTo(requestedResources)))
                             .map(resources -> resources.withBandwidthGbps(requestedResources.bandwidthGbps()))
                             .map(resources -> resources.storageType() == NodeResources.StorageType.remote ?
                                               resources.withDiskGb(requestedResources.diskGb()) : resources);
    }
Returns the advertised flavor resources which are nearest to the given resources
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeRepositoryProvisioner.java