mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
*: add learner field in endpoint status
Added learner field to endpoint status API.
This commit is contained in:
@@ -60,7 +60,7 @@ func newEpStatusCommand() *cobra.Command {
|
||||
Use: "status",
|
||||
Short: "Prints out the status of endpoints specified in `--endpoints` flag",
|
||||
Long: `When --write-out is set to simple, this command prints out comma-separated status lists for each endpoint.
|
||||
The items in the lists are endpoint, ID, version, db size, is leader, raft term, raft index.
|
||||
The items in the lists are endpoint, ID, version, db size, is leader, is learner, raft term, raft index, raft applied index, errors.
|
||||
`,
|
||||
Run: epStatusCommandFunc,
|
||||
}
|
||||
|
||||
@@ -194,7 +194,8 @@ func makeEndpointHealthTable(healthList []epHealth) (hdr []string, rows [][]stri
|
||||
}
|
||||
|
||||
func makeEndpointStatusTable(statusList []epStatus) (hdr []string, rows [][]string) {
|
||||
hdr = []string{"endpoint", "ID", "version", "db size", "is leader", "raft term", "raft index", "raft applied index", "errors"}
|
||||
hdr = []string{"endpoint", "ID", "version", "db size", "is leader", "is learner", "raft term",
|
||||
"raft index", "raft applied index", "errors"}
|
||||
for _, status := range statusList {
|
||||
rows = append(rows, []string{
|
||||
status.Ep,
|
||||
@@ -202,6 +203,7 @@ func makeEndpointStatusTable(statusList []epStatus) (hdr []string, rows [][]stri
|
||||
status.Resp.Version,
|
||||
humanize.Bytes(uint64(status.Resp.DbSize)),
|
||||
fmt.Sprint(status.Resp.Leader == status.Resp.Header.MemberId),
|
||||
fmt.Sprint(status.Resp.IsLearner),
|
||||
fmt.Sprint(status.Resp.RaftTerm),
|
||||
fmt.Sprint(status.Resp.RaftIndex),
|
||||
fmt.Sprint(status.Resp.RaftAppliedIndex),
|
||||
|
||||
@@ -158,6 +158,7 @@ func (p *fieldsPrinter) EndpointStatus(eps []epStatus) {
|
||||
fmt.Printf("\"Version\" : %q\n", ep.Resp.Version)
|
||||
fmt.Println(`"DBSize" :`, ep.Resp.DbSize)
|
||||
fmt.Println(`"Leader" :`, ep.Resp.Leader)
|
||||
fmt.Println(`"IsLearner" :`, ep.Resp.IsLearner)
|
||||
fmt.Println(`"RaftIndex" :`, ep.Resp.RaftIndex)
|
||||
fmt.Println(`"RaftTerm" :`, ep.Resp.RaftTerm)
|
||||
fmt.Println(`"RaftAppliedIndex" :`, ep.Resp.RaftAppliedIndex)
|
||||
|
||||
Reference in New Issue
Block a user