Skip to content

Commit

Permalink
fix cancel build to cancel pending stages
Browse files Browse the repository at this point in the history
  • Loading branch information
zc2638 committed Feb 4, 2024
1 parent 908bf73 commit 1d5ccfc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/service/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,15 @@ func (s *srv) Cancel(ctx context.Context, namespace, name string, number uint64)
return errors.New("already done")
}

if err := db.Model(&storageV1.Stage{}).
Where(&storageV1.Stage{
BoxID: buildS.BoxID,
BuildID: buildS.ID,
Phase: v1.PhasePending.String(),
}).Update("phase", v1.PhaseCanceled).Error; err != nil {
return err
}

sched := scheduler.FromContext(ctx)
return sched.Cancel(ctx, int64(build.ID))
}

0 comments on commit 1d5ccfc

Please sign in to comment.