Skip to content

Commit

Permalink
More robust parsing of shm-size containerOptions (#5177)
Browse files Browse the repository at this point in the history
This commit ensures that the `shm-size` option is correctly parsed from the containerOptions. This is necessary to ensure that the correct value in MiB is passed to the AWS Batch API when creating a job definition.



Signed-off-by: Rob Syme <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
Co-authored-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
robsyme and pditommaso committed Jul 31, 2024
1 parent b2ab651 commit 98cf006
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.amazonaws.services.batch.model.Tmpfs
import com.amazonaws.services.batch.model.Ulimit
import groovy.transform.CompileStatic
import nextflow.util.CmdLineOptionMap
import nextflow.util.MemoryUnit

/**
* Maps task container options to AWS container properties
Expand Down Expand Up @@ -106,7 +107,8 @@ class AwsContainerOptionsMapper {
// shared Memory Size
def value = findOptionWithSingleValue(options, 'shm-size')
if ( value ) {
params.setSharedMemorySize(value as Integer)
final sharedMemorySize = MemoryUnit.of(value)
params.setSharedMemorySize(sharedMemorySize.mega as Integer)
atLeastOneSet = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,25 @@ class AwsContainerOptionsMapperTest extends Specification {
def map = CmdLineHelper.parseGnuArgs('--shm-size 12048024')
def properties = AwsContainerOptionsMapper.createContainerProperties(map)
then:
properties.getLinuxParameters().getSharedMemorySize() == 12048024
properties.getLinuxParameters().getSharedMemorySize() == 11
}

def 'should set shared memory size with unit in MiB'() {

when:
def map = CmdLineHelper.parseGnuArgs('--shm-size 256m')
def properties = AwsContainerOptionsMapper.createContainerProperties(map)
then:
properties.getLinuxParameters().getSharedMemorySize() == 256
}

def 'should set shared memory size with unit in GiB'() {

when:
def map = CmdLineHelper.parseGnuArgs('--shm-size 1g')
def properties = AwsContainerOptionsMapper.createContainerProperties(map)
then:
properties.getLinuxParameters().getSharedMemorySize() == 1024
}

def 'should set memory swappiness'() {
Expand Down

0 comments on commit 98cf006

Please sign in to comment.