Skip to content

Commit

Permalink
Improve Aws Batch error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
pditommaso committed Apr 1, 2022
1 parent fa68778 commit 0044351
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import java.util.regex.Pattern

import com.amazonaws.services.batch.AWSBatch
import com.amazonaws.services.batch.model.AWSBatchException
import com.amazonaws.services.batch.model.AttemptContainerDetail
import com.amazonaws.services.batch.model.ClientException
import com.amazonaws.services.batch.model.ContainerOverrides
import com.amazonaws.services.batch.model.ContainerProperties
Expand Down Expand Up @@ -232,6 +233,18 @@ class AwsBatchTaskHandler extends TaskHandler implements BatchHandler<String,Job
return result
}

protected String errReason(JobDetail job){
if(!job)
return "(unknown)"
final result = new ArrayList(2)
if( job.statusReason )
result.add(job.statusReason)
final AttemptContainerDetail container = job.attempts ? job.attempts[-1].container : null
if( container?.reason )
result.add(container.reason)
return result.join(' - ')
}

/**
* {@inheritDoc}
*/
Expand All @@ -254,7 +267,7 @@ class AwsBatchTaskHandler extends TaskHandler implements BatchHandler<String,Job
task.exitStatus = readExitFile()
task.stdout = outputFile
if( job?.status == 'FAILED' ) {
task.error = new ProcessUnrecoverableException(job?.getStatusReason())
task.error = new ProcessUnrecoverableException(errReason(job))
task.stderr = executor.getJobOutputStream(jobId) ?: errorFile
}
else {
Expand Down

0 comments on commit 0044351

Please sign in to comment.