return workers info of index level

This commit is contained in:
liugq 2023-10-09 10:56:22 +08:00
parent f3569c2701
commit 9f60c4685f
1 changed files with 13 additions and 0 deletions

View File

@ -301,6 +301,7 @@ func (h *APIHandler) getDataComparisonTaskOfIndex(w http.ResponseWriter, req *ht
startTime, completedTime, duration, completedPartitions := h.calcMajorTaskInfo(subTasks, taskInfo.Repeating)
var partitionTaskInfos []util.MapStr
var workers = map[string]struct{}{}
for i, subTask := range subTasks {
cfg := migration_model.IndexComparisonTaskConfig{}
@ -312,6 +313,10 @@ func (h *APIHandler) getDataComparisonTaskOfIndex(w http.ResponseWriter, req *ht
if i == 0 {
taskInfo.Step = cfg.Source.Step
}
instID := migration_util.GetMapStringValue(subTask.Metadata.Labels, "execution_instance_id")
if instID != "" {
workers[instID] = struct{}{}
}
var durationInMS int64
var subCompletedTime int64
@ -381,6 +386,14 @@ func (h *APIHandler) getDataComparisonTaskOfIndex(w http.ResponseWriter, req *ht
if taskInfo.StartTime == 0 {
taskInfo.StartTime = startTime
}
for _, node := range taskConfig.Settings.Execution.Nodes.Permit {
if _, ok := workers[node.ID]; ok {
taskInfo.Workers = append(taskInfo.Workers, util.MapStr{
"id": node.ID,
"name": node.Name,
})
}
}
taskInfo.Partitions = partitionTaskInfos
taskInfo.CompletedPartitions = completedPartitions
h.WriteJSON(w, taskInfo, http.StatusOK)