diff --git a/plugins/nf-google/build.gradle b/plugins/nf-google/build.gradle index 35c216e93a..c1141eff28 100644 --- a/plugins/nf-google/build.gradle +++ b/plugins/nf-google/build.gradle @@ -58,7 +58,7 @@ dependencies { api 'com.google.cloud:google-cloud-logging:3.23.5' api 'com.google.cloud:google-cloud-nio:0.128.5' api 'com.google.cloud:google-cloud-storage:2.58.0' - + api 'io.seqera:lib-cloudinfo:1.0.0' // Force patched version to address CVE-2025-55163 (MadeYouReset HTTP/2 DDoS vulnerability) runtimeOnly 'io.grpc:grpc-netty-shaded:1.75.0' // Force patched version to address GHSA-72hv-8253-57qq (jackson-core Number Length Constraint Bypass DoS) diff --git a/plugins/nf-google/src/main/nextflow/cloud/google/batch/GoogleBatchMachineTypeSelector.groovy b/plugins/nf-google/src/main/nextflow/cloud/google/batch/GoogleBatchMachineTypeSelector.groovy index 6bdd8bb6e9..81de01f8e3 100644 --- a/plugins/nf-google/src/main/nextflow/cloud/google/batch/GoogleBatchMachineTypeSelector.groovy +++ b/plugins/nf-google/src/main/nextflow/cloud/google/batch/GoogleBatchMachineTypeSelector.groovy @@ -15,9 +15,11 @@ */ package nextflow.cloud.google.batch +import io.seqera.cloudinfo.api.CloudPrice +import io.seqera.cloudinfo.client.CloudInfoClient + import java.math.RoundingMode -import groovy.json.JsonSlurper import groovy.transform.CompileStatic import groovy.transform.Immutable import groovy.transform.Memoized @@ -42,8 +44,6 @@ class GoogleBatchMachineTypeSelector { static GoogleBatchMachineTypeSelector INSTANCE = new GoogleBatchMachineTypeSelector() - private static final CLOUD_INFO_API = "https://cloudinfo.seqera.io/api/v1" - /* * Some families CPUs are faster so this is a cost correction factor * for processes that request more than 2 CPUs or 2GB, smaller processes @@ -101,6 +101,12 @@ class GoogleBatchMachineTypeSelector { */ private static final List PARTIAL_LOCAL_SSD_SUPPORT_FAMILIES = ['c3-*', 'c3a-*', 'c3d-*', 'c4-*', 'c4a-*', 'c4d-*', 'h4d-*', 'z3-*'] + private CloudInfoClient cloudInfo + + GoogleBatchMachineTypeSelector(){ + cloudInfo = CloudInfoClient.create() + } + @Immutable static class MachineType { String type @@ -170,16 +176,14 @@ class GoogleBatchMachineTypeSelector { @Memoized protected List getAvailableMachineTypes(String region, boolean spot) { final priceModel = spot ? PriceModel.spot : PriceModel.standard - final json = "${CLOUD_INFO_API}/providers/google/services/compute/regions/${region}/products".toURL().text - final data = new JsonSlurper().parseText(json) - final products = data['products'] as List - final averageSpotPrice = (List prices) -> prices ? prices.collect{it.price as float}.average() as float : 0.0f + final products = cloudInfo.getProducts('google', region) + final averageSpotPrice = (List prices) -> prices ? prices.collect{it.price as float}.average() as float : 0.0f products.collect { new MachineType( type: it.type, family: it.type.toString().split('-')[0], - spotPrice: averageSpotPrice(it.spotPrice as List), + spotPrice: averageSpotPrice(it.spotPrice as List), onDemandPrice: it.onDemandPrice as float, cpusPerVm: it.cpusPerVm as int, memPerVm: it.memPerVm as int,