fix: update stopped execution status immediately instead of async update (#18527)

Update the stopped execution status immediately becasue the user
experience is not good if wait long time when stop or reschedule a job.

Fixes: #18526

Signed-off-by: chlins <chenyuzh@vmware.com>
This commit is contained in:
Chlins Zhang 2023-04-13 17:52:41 +08:00 committed by GitHub
parent 3afa525f0b
commit d3d6e29aa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -107,8 +107,9 @@ func (h *HookHandler) Handle(ctx context.Context, sc *job.StatusChange) error {
logger.Errorf("failed to run the task status change post function for task %d: %v", task.ID, err)
}
}
// execution status refresh interval <= 0 means update the status immediately
if config.GetExecutionStatusRefreshIntervalSeconds() <= 0 {
// 1. execution status refresh interval <= 0 means update the status immediately
// 2. if the status is Stopped, we should also update the status immediately to avoid long wait time for user
if config.GetExecutionStatusRefreshIntervalSeconds() <= 0 || sc.Status == job.StoppedStatus.String() {
// update execution status immediately which may have optimistic lock
statusChanged, currentStatus, err := h.executionDAO.RefreshStatus(ctx, task.ExecutionID)
if err != nil {