mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-27 01:02:34 +01:00
Avoid internal error in the UI when reset a schedule (#17946)
fixes #17926 Signed-off-by: stonezdj <daojunz@vmware.com> Signed-off-by: stonezdj <daojunz@vmware.com>
This commit is contained in:
parent
c678d6cc76
commit
ceb130e617
@ -196,7 +196,13 @@ func (s *scheduler) UnScheduleByID(ctx context.Context, id int64) error {
|
||||
executionID := executions[0].ID
|
||||
// stop the execution
|
||||
if err = s.execMgr.StopAndWait(ctx, executionID, 10*time.Second); err != nil {
|
||||
return err
|
||||
if err == task.ErrTimeOut {
|
||||
// Avoid return this error to the UI, log time out error and continue
|
||||
// the execution will be finally stopped by jobservice
|
||||
log.Debugf("time out when stopping the execution %d, but the execution will be stopped eventually", executionID)
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// delete execution
|
||||
if err = s.execMgr.Delete(ctx, executionID); err != nil {
|
||||
|
@ -17,7 +17,6 @@ package task
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -34,6 +33,7 @@ var (
|
||||
// ExecMgr is a global execution manager instance
|
||||
ExecMgr = NewExecutionManager()
|
||||
executionSweeperCount = map[string]uint8{}
|
||||
ErrTimeOut = errors.New("stopping the execution timeout")
|
||||
)
|
||||
|
||||
// ExecutionManager manages executions.
|
||||
@ -333,7 +333,7 @@ func (e *executionManager) StopAndWait(ctx context.Context, id int64, timeout ti
|
||||
lock.Lock()
|
||||
overtime = true
|
||||
lock.Unlock()
|
||||
return fmt.Errorf("stopping the execution %d timeout", id)
|
||||
return ErrTimeOut
|
||||
case err := <-errChan:
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user