Skip to content

Commit

Permalink
Add LastWAL in leader/health output (#5523)
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferai committed Oct 16, 2018
1 parent 6647b35 commit bc33dbd
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/sys_health.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ type HealthResponse struct {
Version string `json:"version"`
ClusterName string `json:"cluster_name,omitempty"`
ClusterID string `json:"cluster_id,omitempty"`
LastWAL uint64 `json:"last_wal,omitempty"`
}
1 change: 1 addition & 0 deletions api/sys_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ type LeaderResponse struct {
LeaderClusterAddress string `json:"leader_cluster_address"`
PerfStandby bool `json:"performance_standby"`
PerfStandbyLastRemoteWAL uint64 `json:"performance_standby_last_remote_wal"`
LastWAL uint64 `json:"last_wal"`
}
4 changes: 4 additions & 0 deletions command/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ func OutputSealStatus(ui cli.Ui, client *api.Client, status *api.SealStatusRespo
}
}

if leaderStatus.LastWAL != 0 {
out = append(out, fmt.Sprintf("Last WAL | %d", leaderStatus.LastWAL))
}

ui.Output(tableOutput(out, nil))
return 0
}
Expand Down
6 changes: 6 additions & 0 deletions http/sys_health.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ func getSysHealth(core *vault.Core, r *http.Request) (int, *HealthResponse, erro
ClusterName: clusterName,
ClusterID: clusterID,
}

if init && !sealed && !standby {
body.LastWAL = vault.LastWAL(core)
}

return code, body, nil
}

Expand All @@ -193,4 +198,5 @@ type HealthResponse struct {
Version string `json:"version"`
ClusterName string `json:"cluster_name,omitempty"`
ClusterID string `json:"cluster_id,omitempty"`
LastWAL uint64 `json:"last_wal,omitempty"`
}
3 changes: 3 additions & 0 deletions http/sys_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func handleSysLeaderGet(core *vault.Core, w http.ResponseWriter, r *http.Request
}
if resp.PerfStandby {
resp.PerfStandbyLastRemoteWAL = vault.LastRemoteWAL(core)
} else if isLeader || !haEnabled {
resp.LastWAL = vault.LastWAL(core)
}

respondOk(w, resp)
Expand All @@ -50,4 +52,5 @@ type LeaderResponse struct {
LeaderClusterAddress string `json:"leader_cluster_address"`
PerfStandby bool `json:"performance_standby"`
PerfStandbyLastRemoteWAL uint64 `json:"performance_standby_last_remote_wal"`
LastWAL uint64 `json:"last_wal,omitempty"`
}
5 changes: 5 additions & 0 deletions vault/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ var (
enterprisePreSeal = enterprisePreSealImpl
startReplication = startReplicationImpl
stopReplication = stopReplicationImpl
LastWAL = lastWALImpl
LastRemoteWAL = lastRemoteWALImpl
WaitUntilWALShipped = waitUntilWALShippedImpl
)
Expand Down Expand Up @@ -1514,6 +1515,10 @@ func waitUntilWALShippedImpl(ctx context.Context, c *Core, index uint64) bool {
return true
}

func lastWALImpl(c *Core) uint64 {
return 0
}

func lastRemoteWALImpl(c *Core) uint64 {
return 0
}
Expand Down

0 comments on commit bc33dbd

Please sign in to comment.