diff --git a/api/sys_health.go b/api/sys_health.go index bd74e8269dfc..e4c60d44606d 100644 --- a/api/sys_health.go +++ b/api/sys_health.go @@ -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"` } diff --git a/api/sys_leader.go b/api/sys_leader.go index dfef8345cc5a..8846dcdfae9e 100644 --- a/api/sys_leader.go +++ b/api/sys_leader.go @@ -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"` } diff --git a/command/format.go b/command/format.go index 10244a8aa2ec..93f12a04bef6 100644 --- a/command/format.go +++ b/command/format.go @@ -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 } diff --git a/http/sys_health.go b/http/sys_health.go index 089b9949a5d5..02136ceca0dc 100644 --- a/http/sys_health.go +++ b/http/sys_health.go @@ -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 } @@ -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"` } diff --git a/http/sys_leader.go b/http/sys_leader.go index 0f5305a3fff3..76ba92b2ba83 100644 --- a/http/sys_leader.go +++ b/http/sys_leader.go @@ -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) @@ -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"` } diff --git a/vault/core.go b/vault/core.go index 5fa03e76d393..f1f54451cb28 100644 --- a/vault/core.go +++ b/vault/core.go @@ -86,6 +86,7 @@ var ( enterprisePreSeal = enterprisePreSealImpl startReplication = startReplicationImpl stopReplication = stopReplicationImpl + LastWAL = lastWALImpl LastRemoteWAL = lastRemoteWALImpl WaitUntilWALShipped = waitUntilWALShippedImpl ) @@ -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 }