[migration] fix major task state handling

This commit is contained in:
Kassian Sun 2023-04-19 14:32:14 +08:00 committed by Gitea
parent 1bca4335f1
commit 1f95d4af48
1 changed files with 9 additions and 3 deletions

View File

@ -1035,6 +1035,9 @@ func (p *DispatcherProcessor) getMajorTaskState(majorTask *task2.Task) (taskStat
if v, ok := res.Aggregations["total_docs"].Value.(float64); ok {
taskState.IndexDocs = v
}
var (
hasError bool
)
for _, bk := range res.Aggregations["grp"].Buckets {
status, _ := util.ExtractString(bk["key"])
if migration_util.IsRunningState(status) {
@ -1042,11 +1045,14 @@ func (p *DispatcherProcessor) getMajorTaskState(majorTask *task2.Task) (taskStat
return taskState, nil
}
if status == task2.StatusError {
hasError = true
}
}
if hasError {
taskState.Status = task2.StatusError
return taskState, nil
}
}
} else {
taskState.Status = task2.StatusComplete
}
return taskState, nil
}