Skip to content

Commit

Permalink
Merge pull request #12 from jehiah/error_handling_12
Browse files Browse the repository at this point in the history
dataproc: return errors for failed jobs
  • Loading branch information
jehiah authored Dec 24, 2019
2 parents 084a928 + d64ca43 commit 353126e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion dataproc/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ import (
"github.com/jehiah/gomrjob/hdfs"
)

func isErrorState(s string) bool {
switch s {
case "ATTEMPT_FAILURE", "ERROR", "CANCELLED":
return true
default:
return false
}
}

func isTerminalState(s string) bool {
switch s {
case "ATTEMPT_FAILURE", "ERROR", "DONE", "CANCELLED":
Expand Down Expand Up @@ -97,7 +106,10 @@ func SubmitJob(j hdfs.Job, client *http.Client, project, region, cluster string)
log.Printf("job:%s status:%s", job.Reference.JobID, state)
}
if isTerminalState(state) {
break
if isErrorState(state) {
return fmt.Errorf("job:%s finished with status:%s", job.Reference.JobID, state)
}
return nil
}
}
return nil
Expand Down

0 comments on commit 353126e

Please sign in to comment.