Skip to content

Commit

Permalink
ensure task assigned is a backup worker
Browse files Browse the repository at this point in the history
  • Loading branch information
Son Roy Almerol committed Nov 4, 2024
1 parent 8bfa817 commit 945a860
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions internal/backend/backup/jobrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,33 @@ func RunBackup(job *store.Job, storeInstance *store.Store) (*store.Task, error)
time.Sleep(time.Millisecond * 100)
}

task, err := storeInstance.GetMostRecentTask(job)
if err != nil {
_ = cmd.Process.Kill()
if agentMount != nil {
agentMount.Unmount()
var task *store.Task
for {
task, err = storeInstance.GetMostRecentTask(job)
if err != nil {
_ = cmd.Process.Kill()
if agentMount != nil {
agentMount.Unmount()
}

return nil, fmt.Errorf("RunBackup: unable to get most recent task -> %w", err)
}

return nil, fmt.Errorf("RunBackup: unable to get most recent task -> %w", err)
if task.WorkerType == "backup" {
break
}

if cmd.ProcessState != nil {
break
}

time.Sleep(time.Millisecond * 500)
}

job.LastRunUpid = &task.UPID
job.LastRunState = &task.Status
if task != nil {
job.LastRunUpid = &task.UPID
job.LastRunState = &task.Status
}

err = storeInstance.UpdateJob(*job)
if err != nil {
Expand Down

0 comments on commit 945a860

Please sign in to comment.