Skip to content

Commit

Permalink
Create process exception when batch error job
Browse files Browse the repository at this point in the history
Signed-off-by: jorgee <[email protected]>
  • Loading branch information
jorgee committed Dec 4, 2024
1 parent aa26a76 commit 81be12c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class GoogleBatchTaskHandler extends TaskHandler implements FusionAwareTask {

private static Pattern EXIT_CODE_REGEX = ~/exit code 500(\d\d)/

private static Pattern BATCH_ERROR_REGEX = ~/Batch Error: code/

private GoogleBatchExecutor executor

private Path exitFile
Expand Down Expand Up @@ -535,7 +537,7 @@ class GoogleBatchTaskHandler extends TaskHandler implements FusionAwareTask {
log.debug "[GOOGLE BATCH] Process `${task.lazyName()}` - last event: ${lastEvent}; exit code: ${lastEvent?.taskExecution?.exitCode}"

final error = lastEvent?.description
if( error && EXIT_CODE_REGEX.matcher(error).find() ) {
if( error && (EXIT_CODE_REGEX.matcher(error).find() || BATCH_ERROR_REGEX.matcher(error).find())) {
return new ProcessException(error)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ class GoogleBatchTaskHandlerTest extends Specification {
builder.build()
}

def 'should check job status when '() {
def 'should check job status when no tasks in job '() {

given:
def jobId = 'job-id'
Expand All @@ -605,15 +605,17 @@ class GoogleBatchTaskHandlerTest extends Specification {
lazyName() >> 'foo (1)'
}
def handler = Spy(new GoogleBatchTaskHandler(jobId: jobId, taskId: taskId, client: client, task: task))

final message = 'Job failed when Batch tries to schedule it: Batch Error: code - CODE_MACHINE_TYPE_NOT_FOUND'
when:
client.listTasks(jobId) >>> [new LinkedList<Task>(), new LinkedList<Task>()]
client.getJobStatus(jobId) >>> [
null,
makeJobStatus(JobStatus.State.FAILED, 'Scheduling Failed'),
makeJobStatus(JobStatus.State.FAILED, message)
]
then:
handler.getTaskState() == "PENDING"
handler.getTaskState() == "FAILED"
handler.getJobError().message == message
}
}

0 comments on commit 81be12c

Please sign in to comment.