Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(cherry-pick) Avoid internal error in the UI when reset a schedule #17960

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/pkg/task/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package task
import (
"context"
"encoding/json"
"fmt"
"sync"
"time"

Expand All @@ -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.
Expand Down Expand Up @@ -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
}
Expand Down