Skip to content

Commit

Permalink
fix(api): don't restart stooped jobs (#6692)
Browse files Browse the repository at this point in the history
Signed-off-by: François Samin <[email protected]>
  • Loading branch information
fsamin authored Nov 20, 2023
1 parent e94d2eb commit 9941e10
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions engine/api/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,14 @@ func DisableWorker(ctx context.Context, db *gorp.DbMap, id string, maxLogSize in
// Worker is awol while building !
// We need to restart this action
wNodeJob, err := workflow.LoadNodeJobRun(ctx, db, nil, jobID.Int64)
if err == nil && wNodeJob.Retry < 3 {
if err == nil && wNodeJob.Retry < 3 && !sdk.StatusIsTerminated(wNodeJob.Status) {
if err := workflow.RestartWorkflowNodeJob(context.TODO(), db, *wNodeJob, maxLogSize); err != nil {
log.Warn(ctx, "DisableWorker[%s]> Cannot restart workflow node run: %v", name, err)
} else {
log.Info(ctx, "DisableWorker[%s]> WorkflowNodeRun %d restarted after crash", name, jobID.Int64)
}
log.Info(ctx, "DisableWorker> Worker %s crashed while building %d !", name, jobID.Int64)
}
log.Info(ctx, "DisableWorker> Worker %s crashed while building %d !", name, jobID.Int64)
}
return nil
}
2 changes: 1 addition & 1 deletion engine/api/worker/dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func SetStatus(ctx context.Context, db gorpmapper.SqlExecutorWithTx, workerID st
return err
}
w.Status = status
if status == sdk.StatusBuilding || status == sdk.StatusWaiting {
if status == sdk.StatusBuilding || status == sdk.StatusWaiting || status == sdk.StatusDisabled {
w.JobRunID = nil
}
dbData := &dbWorker{Worker: *w}
Expand Down

0 comments on commit 9941e10

Please sign in to comment.