mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-23 00:57:44 +01:00
State machine recover from panic and set job state to error
This commit is contained in:
parent
482f91d91a
commit
7a57cb4c87
@ -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