From 1f95d4af4830491594fad372090432c96830c4c0 Mon Sep 17 00:00:00 2001 From: Kassian Sun Date: Wed, 19 Apr 2023 14:32:14 +0800 Subject: [PATCH] [migration] fix major task state handling --- plugin/migration/pipeline.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugin/migration/pipeline.go b/plugin/migration/pipeline.go index 09069ad4..8db3d47e 100644 --- a/plugin/migration/pipeline.go +++ b/plugin/migration/pipeline.go @@ -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 { - taskState.Status = task2.StatusError - return taskState, nil + hasError = true } } - taskState.Status = task2.StatusComplete + if hasError { + taskState.Status = task2.StatusError + } else { + taskState.Status = task2.StatusComplete + } return taskState, nil }