From ef7ade7efc295c0145a05753b5ecb9eec5088141 Mon Sep 17 00:00:00 2001 From: Jianjun Liao <36503113+Leavrth@users.noreply.github.com> Date: Mon, 23 Dec 2024 16:20:13 +0800 Subject: [PATCH] br: add status field for log status with json (#58465) close pingcap/tidb#57959 --- br/pkg/stream/stream_status.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/br/pkg/stream/stream_status.go b/br/pkg/stream/stream_status.go index 10e916cbd6578..f22487d2f19ef 100644 --- a/br/pkg/stream/stream_status.go +++ b/br/pkg/stream/stream_status.go @@ -98,6 +98,16 @@ func (t *TaskStatus) colorfulStatusString() string { return statusOK("NORMAL") } +func (t *TaskStatus) statusString() string { + if t.paused && len(t.LastErrors) > 0 { + return "ERROR" + } + if t.paused { + return "PAUSE" + } + return "NORMAL" +} + // GetCheckpoint calculates the checkpoint of the task. func (t TaskStatus) GetMinStoreCheckpoint() Checkpoint { initialized := false @@ -195,6 +205,7 @@ func (p *printByJSON) PrintTasks() { Name string `json:"name"` StartTS uint64 `json:"start_ts,omitempty"` EndTS uint64 `json:"end_ts,omitempty"` + Status string `json:"status"` TableFilter []string `json:"table_filter"` Progress []storeProgress `json:"progress"` Storage string `json:"storage"` @@ -224,6 +235,7 @@ func (p *printByJSON) PrintTasks() { Name: t.Info.GetName(), StartTS: t.Info.GetStartTs(), EndTS: t.Info.GetEndTs(), + Status: t.statusString(), TableFilter: t.Info.GetTableFilter(), Progress: sp, Storage: s.String(),