Add LastWAL in leader/health output (#5523)

This commit is contained in:
Jeff Mitchell 2018-10-16 09:38:44 -04:00 committed by GitHub
parent 5fc44ea9e3
commit 04e3f9b0f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 0 deletions

View File

@ -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"`
}

View File

@ -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"`
}

View File

@ -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
}

View File

@ -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"`
}

View File

@ -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"`
}

View File

@ -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
}