Skip to content

Commit

Permalink
Fix AWS Cloudwatch access when using custom log group name
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso committed Jul 16, 2024
1 parent 61b2205 commit 3019583
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class AwsBatchExecutor extends Executor implements ExtensionPoint, TaskArrayExec

String getJobOutputStream(String jobId) {
try {
return helper.getTaskLogStream(jobId)
return helper.getTaskLogStream(jobId, awsOptions.getLogsGroup())
}
catch (ResourceNotFoundException e) {
log.debug "Unable to find AWS Cloudwatch logs for Batch Job id=$jobId - ${e.message}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ class AwsBatchHelper {
* The Batch jobs as a string value or {@code null} if no logs is available. Note, if the log
* is made of multiple *page* this method returns only the first one
*/
String getTaskLogStream(String jobId) {
String getTaskLogStream(String jobId, String groupName) {
final streamId = getLogStreamId(jobId)
if( !streamId ) {
log.debug "Unable to find CloudWatch log stream for batch job id=$jobId"
return null
}

final logRequest = new GetLogEventsRequest()
.withLogGroupName("/aws/batch/job")
.withLogGroupName(groupName ?: "/aws/batch/job")
.withLogStreamName(streamId)

final result = new StringBuilder()
Expand Down

0 comments on commit 3019583

Please sign in to comment.