Skip to content

fail plex jobs based on bacalhau status #529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions internal/bacalhau/bacalhau.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,24 @@ func GetBacalhauJobResults(submittedJob *model.Job, showAnimation bool) (results
fmt.Printf("Bacalhau job id: %s \n", submittedJob.Metadata.ID)

for i := 0; i < maxTrys; i++ {
results, err = client.GetResults(context.Background(), submittedJob.Metadata.ID)
updatedJob, _, err := client.Get(context.Background(), submittedJob.Metadata.ID)
if err != nil {
return results, err
}
if len(results) > 0 {
return results, err
if updatedJob.State.State == model.JobStateCancelled {
return results, fmt.Errorf("bacalhau cancelled job; please run `bacalhau describe %s` for more details", submittedJob.Metadata.ID)
} else if updatedJob.State.State == model.JobStateError {
return results, fmt.Errorf("bacalhau errored job; please run `bacalhau describe %s` for more details", submittedJob.Metadata.ID)
} else if updatedJob.State.State == model.JobStateCompleted {
results, err = client.GetResults(context.Background(), submittedJob.Metadata.ID)
if err != nil {
return results, err
}
if len(results) > 0 {
return results, err
} else {
return results, fmt.Errorf("bacalhau job completed but no results found")
}
}
if showAnimation {
saplingIndex := i % 5
Expand Down