Skip to content

Commit

Permalink
fix: check error when getting job history (#4512)
Browse files Browse the repository at this point in the history
- related to #4510

---------

Co-authored-by: frrist <[email protected]>
Co-authored-by: Walid Baruni <[email protected]>
  • Loading branch information
3 people authored Sep 25, 2024
1 parent d5e5f57 commit d004042
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/jobstore/boltdb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,12 @@ func (b *BoltJobStore) getJobHistory(tx *bolt.Tx, jobID string, query jobstore.J

bkt, err := NewBucketPath(BucketJobs, jobID, BucketJobHistory).Get(tx, false)
if err != nil {
// If the bucket doesn't exist, then we return an empty response to maintain compatibility
// with < v1.5.0 versions as the history bucket name was renamed in v1.5.0 without migration
// as migration is not worth the complexity
if errors.Is(err, bolt.ErrBucketNotFound) {
return &jobstore.JobHistoryQueryResponse{}, nil
}
return nil, NewBoltDbError(err)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/publicapi/endpoint/orchestrator/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ func (e *Endpoint) getJob(c echo.Context) error { //nolint: gocyclo
continue
}
jobHistoryQueryResponse, err := e.store.GetJobHistory(ctx, jobID, jobstore.JobHistoryQuery{})
history := jobHistoryQueryResponse.JobHistory
if err != nil {
return err
}
history := jobHistoryQueryResponse.JobHistory
response.History = &apimodels.ListJobHistoryResponse{
Items: make([]*models.JobHistory, len(history)),
}
Expand Down

0 comments on commit d004042

Please sign in to comment.