mirror of
https://github.com/goharbor/harbor.git
synced 2024-08-20 02:52:49 +02:00
Merge pull request #2553 from reasonerjt/master
State machine recover from panic and set job state to error
This commit is contained in:
commit
4993646ebe
|
@ -77,6 +77,13 @@ func (sm *SM) EnterState(s string) (string, error) {
|
|||
// It will search the transit map if the next state is "_continue", and
|
||||
// will enter error state if there's more than one possible path when next state is "_continue"
|
||||
func (sm *SM) Start(s string) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
sm.Logger.Errorf("Panic: %v, entering error state", r)
|
||||
log.Warningf("Panic when handling job: %v, panic: %v, entering error state", sm.CurrentJob, r)
|
||||
sm.EnterState(models.JobError)
|
||||
}
|
||||
}()
|
||||
n, err := sm.EnterState(s)
|
||||
log.Debugf("Job: %v, next state from handler: %s", sm.CurrentJob, n)
|
||||
for len(n) > 0 && err == nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user