parent
60898d6e03
commit
2adef1f878
|
@ -195,6 +195,21 @@ func getSysHealth(core *vault.Core, r *http.Request) (int, *HealthResponse, erro
|
|||
ClusterID: clusterID,
|
||||
}
|
||||
|
||||
licenseState, err := vault.LicenseSummary(core)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, nil, err
|
||||
}
|
||||
|
||||
if licenseState != nil {
|
||||
body.License = &HealthResponseLicense{
|
||||
State: licenseState.State,
|
||||
Terminated: licenseState.Terminated,
|
||||
}
|
||||
if !licenseState.ExpiryTime.IsZero() {
|
||||
body.License.ExpiryTime = licenseState.ExpiryTime.Format(time.RFC3339)
|
||||
}
|
||||
}
|
||||
|
||||
if init && !sealed && !standby {
|
||||
body.LastWAL = vault.LastWAL(core)
|
||||
}
|
||||
|
@ -202,16 +217,23 @@ func getSysHealth(core *vault.Core, r *http.Request) (int, *HealthResponse, erro
|
|||
return code, body, nil
|
||||
}
|
||||
|
||||
type HealthResponse struct {
|
||||
Initialized bool `json:"initialized"`
|
||||
Sealed bool `json:"sealed"`
|
||||
Standby bool `json:"standby"`
|
||||
PerformanceStandby bool `json:"performance_standby"`
|
||||
ReplicationPerformanceMode string `json:"replication_performance_mode"`
|
||||
ReplicationDRMode string `json:"replication_dr_mode"`
|
||||
ServerTimeUTC int64 `json:"server_time_utc"`
|
||||
Version string `json:"version"`
|
||||
ClusterName string `json:"cluster_name,omitempty"`
|
||||
ClusterID string `json:"cluster_id,omitempty"`
|
||||
LastWAL uint64 `json:"last_wal,omitempty"`
|
||||
type HealthResponseLicense struct {
|
||||
State string `json:"state"`
|
||||
ExpiryTime string `json:"expiry_time"`
|
||||
Terminated bool `json:"terminated"`
|
||||
}
|
||||
|
||||
type HealthResponse struct {
|
||||
Initialized bool `json:"initialized"`
|
||||
Sealed bool `json:"sealed"`
|
||||
Standby bool `json:"standby"`
|
||||
PerformanceStandby bool `json:"performance_standby"`
|
||||
ReplicationPerformanceMode string `json:"replication_performance_mode"`
|
||||
ReplicationDRMode string `json:"replication_dr_mode"`
|
||||
ServerTimeUTC int64 `json:"server_time_utc"`
|
||||
Version string `json:"version"`
|
||||
ClusterName string `json:"cluster_name,omitempty"`
|
||||
ClusterID string `json:"cluster_id,omitempty"`
|
||||
LastWAL uint64 `json:"last_wal,omitempty"`
|
||||
License *HealthResponseLicense `json:"license,omitempty"`
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ func TestSysHealth_get(t *testing.T) {
|
|||
} else {
|
||||
expected["cluster_id"] = actual["cluster_id"]
|
||||
}
|
||||
delete(actual, "license")
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Fatalf("bad: expected:%#v\nactual:%#v", expected, actual)
|
||||
}
|
||||
|
@ -77,6 +78,7 @@ func TestSysHealth_get(t *testing.T) {
|
|||
} else {
|
||||
expected["cluster_id"] = actual["cluster_id"]
|
||||
}
|
||||
delete(actual, "license")
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Fatalf("bad: expected:%#v\nactual:%#v", expected, actual)
|
||||
}
|
||||
|
@ -114,6 +116,7 @@ func TestSysHealth_get(t *testing.T) {
|
|||
} else {
|
||||
expected["cluster_id"] = actual["cluster_id"]
|
||||
}
|
||||
delete(actual, "license")
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Fatalf("bad: expected:%#v\nactual:%#v", expected, actual)
|
||||
}
|
||||
|
@ -157,6 +160,7 @@ func TestSysHealth_customcodes(t *testing.T) {
|
|||
} else {
|
||||
expected["cluster_id"] = actual["cluster_id"]
|
||||
}
|
||||
delete(actual, "license")
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Fatalf("bad: expected:%#v\nactual:%#v", expected, actual)
|
||||
}
|
||||
|
@ -191,6 +195,7 @@ func TestSysHealth_customcodes(t *testing.T) {
|
|||
} else {
|
||||
expected["cluster_id"] = actual["cluster_id"]
|
||||
}
|
||||
delete(actual, "license")
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Fatalf("bad: expected:%#v\nactual:%#v", expected, actual)
|
||||
}
|
||||
|
@ -228,6 +233,7 @@ func TestSysHealth_customcodes(t *testing.T) {
|
|||
} else {
|
||||
expected["cluster_id"] = actual["cluster_id"]
|
||||
}
|
||||
delete(actual, "license")
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Fatalf("bad: expected:%#v\nactual:%#v", expected, actual)
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ var (
|
|||
storedLicenseCheck = func(c *Core, conf *CoreConfig) error { return nil }
|
||||
LicenseAutoloaded = func(*Core) bool { return false }
|
||||
LicenseInitCheck = func(*Core) error { return nil }
|
||||
LicenseSummary = func(*Core) (*LicenseState, error) { return nil, nil }
|
||||
)
|
||||
|
||||
// NonFatalError is an error that can be returned during NewCore that should be
|
||||
|
@ -2866,3 +2867,9 @@ func ParseRequiredState(raw string, hmacKey []byte) (*logical.WALState, error) {
|
|||
ReplicatedIndex: replicatedIndex,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type LicenseState struct {
|
||||
State string
|
||||
ExpiryTime time.Time
|
||||
Terminated bool
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue