Remove unneeded fields from state output (#11073)
This commit is contained in:
parent
170a0800e6
commit
9839e76192
|
@ -68,25 +68,14 @@ func (ac *AutopilotConfig) UnmarshalJSON(b []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AutopilotExecutionStatus represents the current status of the autopilot background go routines
|
|
||||||
type AutopilotExecutionStatus string
|
|
||||||
|
|
||||||
const (
|
|
||||||
AutopilotNotRunning AutopilotExecutionStatus = "not-running"
|
|
||||||
AutopilotRunning AutopilotExecutionStatus = "running"
|
|
||||||
AutopilotShuttingDown AutopilotExecutionStatus = "shutting-down"
|
|
||||||
)
|
|
||||||
|
|
||||||
// AutopilotState represents the response of the raft autopilot state API
|
// AutopilotState represents the response of the raft autopilot state API
|
||||||
type AutopilotState struct {
|
type AutopilotState struct {
|
||||||
ExecutionStatus AutopilotExecutionStatus `mapstructure:"execution_status"`
|
Healthy bool `mapstructure:"healthy"`
|
||||||
Healthy bool `mapstructure:"healthy"`
|
FailureTolerance int `mapstructure:"failure_tolerance"`
|
||||||
FailureTolerance int `mapstructure:"failure_tolerance"`
|
Servers map[string]*AutopilotServer `mapstructure:"servers"`
|
||||||
OptimisticFailureTolerance int `mapstructure:"optimistic_failure_tolerance"`
|
Leader string `mapstructure:"leader"`
|
||||||
Servers map[string]*AutopilotServer `mapstructure:"servers"`
|
Voters []string `mapstructure:"voters"`
|
||||||
Leader string `mapstructure:"leader"`
|
NonVoters []string `mapstructure:"non_voters"`
|
||||||
Voters []string `mapstructure:"voters"`
|
|
||||||
NonVoters []string `mapstructure:"non_voters"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AutopilotServer represents the server blocks in the response of the raft
|
// AutopilotServer represents the server blocks in the response of the raft
|
||||||
|
|
|
@ -182,7 +182,6 @@ func (p PrettyFormatter) OutputAutopilotState(ui cli.Ui, data interface{}) {
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
buffer.WriteString(fmt.Sprintf("Healthy: %t\n", state.Healthy))
|
buffer.WriteString(fmt.Sprintf("Healthy: %t\n", state.Healthy))
|
||||||
buffer.WriteString(fmt.Sprintf("Failure Tolerance: %d\n", state.FailureTolerance))
|
buffer.WriteString(fmt.Sprintf("Failure Tolerance: %d\n", state.FailureTolerance))
|
||||||
buffer.WriteString(fmt.Sprintf("Optimistic Failure Tolerance: %d\n", state.OptimisticFailureTolerance))
|
|
||||||
buffer.WriteString(fmt.Sprintf("Leader: %s\n", state.Leader))
|
buffer.WriteString(fmt.Sprintf("Leader: %s\n", state.Leader))
|
||||||
buffer.WriteString("Voters:\n")
|
buffer.WriteString("Voters:\n")
|
||||||
outputStringSlice(&buffer, " ", state.Voters)
|
outputStringSlice(&buffer, " ", state.Voters)
|
||||||
|
|
|
@ -464,26 +464,6 @@ func (b *RaftBackend) AutopilotDisabled() bool {
|
||||||
return disabled
|
return disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
// AutopilotExecutionStatus represents the current status of the autopilot background go routines
|
|
||||||
type AutopilotExecutionStatus string
|
|
||||||
|
|
||||||
const (
|
|
||||||
AutopilotNotRunning AutopilotExecutionStatus = "not-running"
|
|
||||||
AutopilotRunning AutopilotExecutionStatus = "running"
|
|
||||||
AutopilotShuttingDown AutopilotExecutionStatus = "shutting-down"
|
|
||||||
)
|
|
||||||
|
|
||||||
func autopilotStatusToStatus(status autopilot.ExecutionStatus) AutopilotExecutionStatus {
|
|
||||||
switch status {
|
|
||||||
case autopilot.Running:
|
|
||||||
return AutopilotRunning
|
|
||||||
case autopilot.ShuttingDown:
|
|
||||||
return AutopilotShuttingDown
|
|
||||||
default:
|
|
||||||
return AutopilotNotRunning
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *RaftBackend) startFollowerHeartbeatTracker() {
|
func (b *RaftBackend) startFollowerHeartbeatTracker() {
|
||||||
b.l.RLock()
|
b.l.RLock()
|
||||||
tickerCh := b.followerHeartbeatTicker.C
|
tickerCh := b.followerHeartbeatTicker.C
|
||||||
|
@ -523,10 +503,8 @@ func (b *RaftBackend) StopAutopilot() {
|
||||||
|
|
||||||
// AutopilotState represents the health information retrieved from autopilot.
|
// AutopilotState represents the health information retrieved from autopilot.
|
||||||
type AutopilotState struct {
|
type AutopilotState struct {
|
||||||
ExecutionStatus AutopilotExecutionStatus `json:"execution_status"`
|
Healthy bool `json:"healthy"`
|
||||||
Healthy bool `json:"healthy"`
|
FailureTolerance int `json:"failure_tolerance"`
|
||||||
FailureTolerance int `json:"failure_tolerance"`
|
|
||||||
OptimisticFailureTolerance int `json:"optimistic_failure_tolerance"`
|
|
||||||
|
|
||||||
Servers map[string]*AutopilotServer `json:"servers"`
|
Servers map[string]*AutopilotServer `json:"servers"`
|
||||||
Leader string `json:"leader"`
|
Leader string `json:"leader"`
|
||||||
|
@ -620,10 +598,6 @@ func autopilotToAPIState(state *autopilot.State) (*AutopilotState, error) {
|
||||||
out.Servers[string(id)] = autopilotToAPIServer(srv)
|
out.Servers[string(id)] = autopilotToAPIServer(srv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := autopilotToAPIStateEnterprise(state, out); err != nil {
|
|
||||||
return out, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,15 +640,7 @@ func (b *RaftBackend) GetAutopilotServerState(ctx context.Context) (*AutopilotSt
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
state, err := autopilotToAPIState(apState)
|
return autopilotToAPIState(apState)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
apStatus, _ := b.autopilot.IsRunning()
|
|
||||||
state.ExecutionStatus = autopilotStatusToStatus(apStatus)
|
|
||||||
|
|
||||||
return state, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *RaftBackend) DisableAutopilot() {
|
func (b *RaftBackend) DisableAutopilot() {
|
||||||
|
|
|
@ -24,12 +24,6 @@ func autopilotToAPIServerEnterprise(_ *autopilot.ServerState, _ *AutopilotServer
|
||||||
// noop in oss
|
// noop in oss
|
||||||
}
|
}
|
||||||
|
|
||||||
func autopilotToAPIStateEnterprise(state *autopilot.State, apiState *AutopilotState) error {
|
|
||||||
// Both are same in OSS
|
|
||||||
apiState.OptimisticFailureTolerance = state.FailureTolerance
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *Delegate) autopilotConfigExt() interface{} {
|
func (d *Delegate) autopilotConfigExt() interface{} {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,6 @@ func TestRaft_Autopilot_Stabilization_And_State(t *testing.T) {
|
||||||
client := cluster.Cores[0].Client
|
client := cluster.Cores[0].Client
|
||||||
state, err := client.Sys().RaftAutopilotState()
|
state, err := client.Sys().RaftAutopilotState()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, api.AutopilotRunning, state.ExecutionStatus)
|
|
||||||
require.Equal(t, true, state.Healthy)
|
require.Equal(t, true, state.Healthy)
|
||||||
require.Len(t, state.Servers, 1)
|
require.Len(t, state.Servers, 1)
|
||||||
require.Equal(t, "core-0", state.Servers["core-0"].ID)
|
require.Equal(t, "core-0", state.Servers["core-0"].ID)
|
||||||
|
|
|
@ -418,14 +418,12 @@ func (b *SystemBackend) handleStorageRaftAutopilotState() framework.OperationFun
|
||||||
|
|
||||||
return &logical.Response{
|
return &logical.Response{
|
||||||
Data: map[string]interface{}{
|
Data: map[string]interface{}{
|
||||||
"execution_status": state.ExecutionStatus,
|
"healthy": state.Healthy,
|
||||||
"healthy": state.Healthy,
|
"failure_tolerance": state.FailureTolerance,
|
||||||
"failure_tolerance": state.FailureTolerance,
|
"servers": state.Servers,
|
||||||
"optimistic_failure_tolerance": state.OptimisticFailureTolerance,
|
"leader": state.Leader,
|
||||||
"servers": state.Servers,
|
"voters": state.Voters,
|
||||||
"leader": state.Leader,
|
"non_voters": state.NonVoters,
|
||||||
"voters": state.Voters,
|
|
||||||
"non_voters": state.NonVoters,
|
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,25 +68,14 @@ func (ac *AutopilotConfig) UnmarshalJSON(b []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AutopilotExecutionStatus represents the current status of the autopilot background go routines
|
|
||||||
type AutopilotExecutionStatus string
|
|
||||||
|
|
||||||
const (
|
|
||||||
AutopilotNotRunning AutopilotExecutionStatus = "not-running"
|
|
||||||
AutopilotRunning AutopilotExecutionStatus = "running"
|
|
||||||
AutopilotShuttingDown AutopilotExecutionStatus = "shutting-down"
|
|
||||||
)
|
|
||||||
|
|
||||||
// AutopilotState represents the response of the raft autopilot state API
|
// AutopilotState represents the response of the raft autopilot state API
|
||||||
type AutopilotState struct {
|
type AutopilotState struct {
|
||||||
ExecutionStatus AutopilotExecutionStatus `mapstructure:"execution_status"`
|
Healthy bool `mapstructure:"healthy"`
|
||||||
Healthy bool `mapstructure:"healthy"`
|
FailureTolerance int `mapstructure:"failure_tolerance"`
|
||||||
FailureTolerance int `mapstructure:"failure_tolerance"`
|
Servers map[string]*AutopilotServer `mapstructure:"servers"`
|
||||||
OptimisticFailureTolerance int `mapstructure:"optimistic_failure_tolerance"`
|
Leader string `mapstructure:"leader"`
|
||||||
Servers map[string]*AutopilotServer `mapstructure:"servers"`
|
Voters []string `mapstructure:"voters"`
|
||||||
Leader string `mapstructure:"leader"`
|
NonVoters []string `mapstructure:"non_voters"`
|
||||||
Voters []string `mapstructure:"voters"`
|
|
||||||
NonVoters []string `mapstructure:"non_voters"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AutopilotServer represents the server blocks in the response of the raft
|
// AutopilotServer represents the server blocks in the response of the raft
|
||||||
|
|
Loading…
Reference in New Issue