Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add replication state to EchoReply #3810

Merged
merged 4 commits into from
Jan 18, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Replace ReplicationDRSecondary with string values to better convey st…
…ate in sys/health
  • Loading branch information
jefferai committed Jan 18, 2018
commit ddc821975f404a047b6ae7936996ca2345611d39
39 changes: 21 additions & 18 deletions http/sys_health.go
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import (
"strconv"
"time"

"github.com/hashicorp/vault/helper/consts"
"github.com/hashicorp/vault/vault"
"github.com/hashicorp/vault/version"
)
@@ -111,7 +112,7 @@ func getSysHealth(core *vault.Core, r *http.Request) (int, *HealthResponse, erro
// Check system status
sealed, _ := core.Sealed()
standby, _ := core.Standby()
drSecondary := core.IsDRSecondary()
replicationState := core.ReplicationState()
init, err := core.Initialized()
if err != nil {
return http.StatusInternalServerError, nil, err
@@ -124,7 +125,7 @@ func getSysHealth(core *vault.Core, r *http.Request) (int, *HealthResponse, erro
code = uninitCode
case sealed:
code = sealedCode
case drSecondary:
case replicationState.HasState(consts.ReplicationDRSecondary):
code = drSecondaryCode
case !standbyOK && standby:
code = standbyCode
@@ -146,25 +147,27 @@ func getSysHealth(core *vault.Core, r *http.Request) (int, *HealthResponse, erro

// Format the body
body := &HealthResponse{
Initialized: init,
Sealed: sealed,
Standby: standby,
ReplicationDRSecondary: drSecondary,
ServerTimeUTC: time.Now().UTC().Unix(),
Version: version.GetVersion().VersionNumber(),
ClusterName: clusterName,
ClusterID: clusterID,
Initialized: init,
Sealed: sealed,
Standby: standby,
ReplicationPerformanceState: replicationState.GetPerformanceString(),
ReplicationDRState: replicationState.GetDRString(),
ServerTimeUTC: time.Now().UTC().Unix(),
Version: version.GetVersion().VersionNumber(),
ClusterName: clusterName,
ClusterID: clusterID,
}
return code, body, nil
}

type HealthResponse struct {
Initialized bool `json:"initialized"`
Sealed bool `json:"sealed"`
Standby bool `json:"standby"`
ReplicationDRSecondary bool `json:"replication_dr_secondary"`
ServerTimeUTC int64 `json:"server_time_utc"`
Version string `json:"version"`
ClusterName string `json:"cluster_name,omitempty"`
ClusterID string `json:"cluster_id,omitempty"`
Initialized bool `json:"initialized"`
Sealed bool `json:"sealed"`
Standby bool `json:"standby"`
ReplicationPerformanceState string `json:"replication_performance_state"`
ReplicationDRState string `json:"replication_dr_state"`
ServerTimeUTC int64 `json:"server_time_utc"`
Version string `json:"version"`
ClusterName string `json:"cluster_name,omitempty"`
ClusterID string `json:"cluster_id,omitempty"`
}