Skip to content

Commit

Permalink
fix: improve code and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mageshwaran-lifebit committed Jan 4, 2024
1 parent 14ce722 commit e1de8e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -600,23 +600,29 @@ class AwsBatchTaskHandler extends TaskHandler implements BatchHandler<String,Job
if( this.environment?.containsKey('NXF_DEBUG') )
vars << new KeyValuePair().withName('NXF_DEBUG').withValue(this.environment['NXF_DEBUG'])

vars.addAll(this.getLifebitEnv())
vars.addAll(this.getAwsCliOptimisationEnvs())
return vars
}

private List<KeyValuePair> getLifebitEnv() {
/**
* List of envs to fix AWS Client retries
* @return
*/
List<KeyValuePair> getAwsCliOptimisationEnvs() {
def vars = []
if( this.getAwsOptions().retryMode && this.getAwsOptions().retryMode in AwsOptions.VALID_RETRY_MODES) {
vars << new KeyValuePair().withName('AWS_RETRY_MODE').withValue(this.getAwsOptions().retryMode)
vars << new KeyValuePair().withName('AWS_METADATA_SERVICE_TIMEOUT').withValue(this.getAwsOptions().metadataServiceTimeout.toSeconds() as String)

def opts = this.getAwsOptions()
if ( opts.retryMode && opts.retryMode in AwsOptions.VALID_RETRY_MODES) {
vars << new KeyValuePair().withName('AWS_RETRY_MODE').withValue(opts.retryMode)
}
if( this.getAwsOptions().maxTransferAttempts ) {
vars << new KeyValuePair().withName('AWS_MAX_ATTEMPTS').withValue(this.getAwsOptions().maxTransferAttempts as String)
vars << new KeyValuePair().withName('AWS_METADATA_SERVICE_NUM_ATTEMPTS').withValue(this.getAwsOptions().maxTransferAttempts as String)
if ( opts.maxTransferAttempts ) {
vars << new KeyValuePair().withName('AWS_MAX_ATTEMPTS').withValue(opts.maxTransferAttempts as String)
vars << new KeyValuePair().withName('AWS_METADATA_SERVICE_NUM_ATTEMPTS').withValue(opts.maxTransferAttempts as String)
}
return vars

if ( opts.metadataServiceTimeout ) {
vars << new KeyValuePair().withName('AWS_METADATA_SERVICE_TIMEOUT').withValue(opts.metadataServiceTimeout.toSeconds() as String)
}
return vars
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class AwsOptions implements CloudTransferOptions {

public static final List<String> VALID_RETRY_MODES = ['legacy','standard','adaptive']

String retryMode
String retryMode = 'standard'

String cliPath

Expand Down

0 comments on commit e1de8e3

Please sign in to comment.