Skip to content

Commit

Permalink
Bed 4885: Jobs stuck in Running state (#951)
Browse files Browse the repository at this point in the history
* fix: move job update closer to actual use to prevent status from getting stuck in running
chore: add schemagen back to justfile

Closes: https://specterops.atlassian.net/browse/BED-4885

* chore: streamline logic
  • Loading branch information
rvazarkar authored Nov 13, 2024
1 parent 3f1a4f8 commit cefb309
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
18 changes: 8 additions & 10 deletions cmd/api/src/daemons/datapipe/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,21 +252,19 @@ func (s *Daemon) processIngestTasks(ctx context.Context, ingestTasks model.Inges
return
}

job, err := s.db.GetFileUploadJob(ctx, ingestTask.TaskID.ValueOrZero())
if err != nil {
log.Errorf("Failed to fetch job for ingest task %d: %v", ingestTask.ID, err)
}
total, failed, err := s.processIngestFile(ctx, ingestTask.FileName, ingestTask.FileType)
if errors.Is(err, fs.ErrNotExist) {
log.Warnf("Did not process ingest task %d with file %s: %v", ingestTask.ID, ingestTask.FileName, err)
} else if err != nil {
log.Errorf("Failed processing ingest task %d with file %s: %v", ingestTask.ID, ingestTask.FileName, err)
}

job.TotalFiles = total
job.FailedFiles += failed
if err = s.db.UpdateFileUploadJob(ctx, job); err != nil {
log.Errorf("Failed to update number of failed files for file upload job ID %s: %v", job.ID, err)
} else if job, err := s.db.GetFileUploadJob(ctx, ingestTask.TaskID.ValueOrZero()); err != nil {
log.Errorf("Failed to fetch job for ingest task %d: %v", ingestTask.ID, err)
} else {
job.TotalFiles = total
job.FailedFiles += failed
if err = s.db.UpdateFileUploadJob(ctx, job); err != nil {
log.Errorf("Failed to update number of failed files for file upload job ID %s: %v", job.ID, err)
}
}

s.clearFileTask(ingestTask)
Expand Down
5 changes: 5 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ generate *FLAGS:
@just stbernard generate {{FLAGS}}
@just check-license

# run the code generation from the cue schema
schemagen: yarn-local && check-license (yarn "format") goimports
go run github.com/specterops/bloodhound/schemagen


# Show repository status
show *FLAGS:
@just stbernard show {{FLAGS}}
Expand Down

0 comments on commit cefb309

Please sign in to comment.