Skip to content

Commit

Permalink
Fix invalid machine type setting when no valid machine type is found (#…
Browse files Browse the repository at this point in the history
…3961)



Signed-off-by: Jordi Deu-Pons <[email protected]>
  • Loading branch information
jordeu authored May 19, 2023
1 parent b5257cd commit 5eb9397
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,6 @@ class GoogleBatchTaskHandler extends TaskHandler implements FusionAwareTask {
if( executor.config.cpuPlatform )
instancePolicy.setMinCpuPlatform( executor.config.cpuPlatform )

if( task.config.getMachineType() )
instancePolicy.setMachineType( task.config.getMachineType() )

machineInfo = findBestMachineType(task.config)
if( machineInfo )
instancePolicy.setMachineType(machineInfo.type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import com.google.cloud.batch.v1.Volume
import com.google.cloud.storage.contrib.nio.CloudStorageFileSystem
import nextflow.cloud.google.batch.client.BatchClient
import nextflow.cloud.google.batch.client.BatchConfig
import nextflow.cloud.types.CloudMachineInfo
import nextflow.cloud.types.PriceModel
import nextflow.executor.Executor
import nextflow.executor.res.AcceleratorResource
import nextflow.processor.TaskBean
Expand Down Expand Up @@ -159,7 +161,7 @@ class GoogleBatchTaskHandlerTest extends Specification {
def req = handler.newSubmitRequest(task, launcher)
then:
handler.fusionEnabled() >> false
handler.findBestMachineType(_) >> null
handler.findBestMachineType(_) >> new CloudMachineInfo(type: MACHINE_TYPE, zone: "location", priceModel: PriceModel.spot)

and:
def taskGroup = req.getTaskGroups(0)
Expand Down Expand Up @@ -293,4 +295,37 @@ class GoogleBatchTaskHandlerTest extends Specification {
and:
taskGroup.getTaskSpec().getVolumesList().size()==0
}

def 'should not set wildcard expressions as machine type'() {
given:
def WORK_DIR = CloudStorageFileSystem.forBucket('foo').getPath('/scratch')
def CONTAINER_IMAGE = 'debian:latest'
def exec = Mock(GoogleBatchExecutor) {
getConfig() >> Mock(BatchConfig)
}
def bean = new TaskBean(workDir: WORK_DIR, inputFiles: [:])
def task = Mock(TaskRun) {
toTaskBean() >> bean
getHashLog() >> 'abcd1234'
getWorkDir() >> WORK_DIR
getContainer() >> CONTAINER_IMAGE
getConfig() >> Mock(TaskConfig) {
getCpus() >> 2
getResourceLabels() >> [:]
getMachineType() >> "n1-*,n2-*"
}
}
def handler = Spy(new GoogleBatchTaskHandler(task, exec))
def env = [FUSION_WORK: '/xyz']
def launcher = new GoogleBatchLauncherSpecMock('bash .command.run', [], [], env)

when:
def req = handler.newSubmitRequest(task, launcher)
then:
handler.fusionEnabled() >> false
handler.findBestMachineType(_) >> null
and:
req.getAllocationPolicy().getInstances(0).policy.getMachineType() == ""

}
}

0 comments on commit 5eb9397

Please sign in to comment.