Skip to content

Commit 9af08a1

Browse files
authored
Remove unneeded fields from state output (#11073) (#11074)
1 parent 78df554 commit 9af08a1

File tree

7 files changed

+21
-87
lines changed

7 files changed

+21
-87
lines changed

api/sys_raft.go

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,14 @@ func (ac *AutopilotConfig) UnmarshalJSON(b []byte) error {
6868
return nil
6969
}
7070

71-
// AutopilotExecutionStatus represents the current status of the autopilot background go routines
72-
type AutopilotExecutionStatus string
73-
74-
const (
75-
AutopilotNotRunning AutopilotExecutionStatus = "not-running"
76-
AutopilotRunning AutopilotExecutionStatus = "running"
77-
AutopilotShuttingDown AutopilotExecutionStatus = "shutting-down"
78-
)
79-
8071
// AutopilotState represents the response of the raft autopilot state API
8172
type AutopilotState struct {
82-
ExecutionStatus AutopilotExecutionStatus `mapstructure:"execution_status"`
83-
Healthy bool `mapstructure:"healthy"`
84-
FailureTolerance int `mapstructure:"failure_tolerance"`
85-
OptimisticFailureTolerance int `mapstructure:"optimistic_failure_tolerance"`
86-
Servers map[string]*AutopilotServer `mapstructure:"servers"`
87-
Leader string `mapstructure:"leader"`
88-
Voters []string `mapstructure:"voters"`
89-
NonVoters []string `mapstructure:"non_voters"`
73+
Healthy bool `mapstructure:"healthy"`
74+
FailureTolerance int `mapstructure:"failure_tolerance"`
75+
Servers map[string]*AutopilotServer `mapstructure:"servers"`
76+
Leader string `mapstructure:"leader"`
77+
Voters []string `mapstructure:"voters"`
78+
NonVoters []string `mapstructure:"non_voters"`
9079
}
9180

9281
// AutopilotServer represents the server blocks in the response of the raft

command/format.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ func (p PrettyFormatter) OutputAutopilotState(ui cli.Ui, data interface{}) {
182182
var buffer bytes.Buffer
183183
buffer.WriteString(fmt.Sprintf("Healthy: %t\n", state.Healthy))
184184
buffer.WriteString(fmt.Sprintf("Failure Tolerance: %d\n", state.FailureTolerance))
185-
buffer.WriteString(fmt.Sprintf("Optimistic Failure Tolerance: %d\n", state.OptimisticFailureTolerance))
186185
buffer.WriteString(fmt.Sprintf("Leader: %s\n", state.Leader))
187186
buffer.WriteString("Voters:\n")
188187
outputStringSlice(&buffer, " ", state.Voters)

physical/raft/raft_autopilot.go

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -464,26 +464,6 @@ func (b *RaftBackend) AutopilotDisabled() bool {
464464
return disabled
465465
}
466466

467-
// AutopilotExecutionStatus represents the current status of the autopilot background go routines
468-
type AutopilotExecutionStatus string
469-
470-
const (
471-
AutopilotNotRunning AutopilotExecutionStatus = "not-running"
472-
AutopilotRunning AutopilotExecutionStatus = "running"
473-
AutopilotShuttingDown AutopilotExecutionStatus = "shutting-down"
474-
)
475-
476-
func autopilotStatusToStatus(status autopilot.ExecutionStatus) AutopilotExecutionStatus {
477-
switch status {
478-
case autopilot.Running:
479-
return AutopilotRunning
480-
case autopilot.ShuttingDown:
481-
return AutopilotShuttingDown
482-
default:
483-
return AutopilotNotRunning
484-
}
485-
}
486-
487467
func (b *RaftBackend) startFollowerHeartbeatTracker() {
488468
b.l.RLock()
489469
tickerCh := b.followerHeartbeatTicker.C
@@ -523,10 +503,8 @@ func (b *RaftBackend) StopAutopilot() {
523503

524504
// AutopilotState represents the health information retrieved from autopilot.
525505
type AutopilotState struct {
526-
ExecutionStatus AutopilotExecutionStatus `json:"execution_status"`
527-
Healthy bool `json:"healthy"`
528-
FailureTolerance int `json:"failure_tolerance"`
529-
OptimisticFailureTolerance int `json:"optimistic_failure_tolerance"`
506+
Healthy bool `json:"healthy"`
507+
FailureTolerance int `json:"failure_tolerance"`
530508

531509
Servers map[string]*AutopilotServer `json:"servers"`
532510
Leader string `json:"leader"`
@@ -620,10 +598,6 @@ func autopilotToAPIState(state *autopilot.State) (*AutopilotState, error) {
620598
out.Servers[string(id)] = autopilotToAPIServer(srv)
621599
}
622600

623-
if err := autopilotToAPIStateEnterprise(state, out); err != nil {
624-
return out, err
625-
}
626-
627601
return out, nil
628602
}
629603

@@ -666,15 +640,7 @@ func (b *RaftBackend) GetAutopilotServerState(ctx context.Context) (*AutopilotSt
666640
return nil, nil
667641
}
668642

669-
state, err := autopilotToAPIState(apState)
670-
if err != nil {
671-
return nil, err
672-
}
673-
674-
apStatus, _ := b.autopilot.IsRunning()
675-
state.ExecutionStatus = autopilotStatusToStatus(apStatus)
676-
677-
return state, nil
643+
return autopilotToAPIState(apState)
678644
}
679645

680646
func (b *RaftBackend) DisableAutopilot() {

physical/raft/raft_util.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ func autopilotToAPIServerEnterprise(_ *autopilot.ServerState, _ *AutopilotServer
2424
// noop in oss
2525
}
2626

27-
func autopilotToAPIStateEnterprise(state *autopilot.State, apiState *AutopilotState) error {
28-
// Both are same in OSS
29-
apiState.OptimisticFailureTolerance = state.FailureTolerance
30-
return nil
31-
}
32-
3327
func (d *Delegate) autopilotConfigExt() interface{} {
3428
return nil
3529
}

vault/external_tests/raft/raft_autopilot_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ func TestRaft_Autopilot_Stabilization_And_State(t *testing.T) {
4646
client := cluster.Cores[0].Client
4747
state, err := client.Sys().RaftAutopilotState()
4848
require.NoError(t, err)
49-
require.Equal(t, api.AutopilotRunning, state.ExecutionStatus)
5049
require.Equal(t, true, state.Healthy)
5150
require.Len(t, state.Servers, 1)
5251
require.Equal(t, "core-0", state.Servers["core-0"].ID)

vault/logical_system_raft.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -418,14 +418,12 @@ func (b *SystemBackend) handleStorageRaftAutopilotState() framework.OperationFun
418418

419419
return &logical.Response{
420420
Data: map[string]interface{}{
421-
"execution_status": state.ExecutionStatus,
422-
"healthy": state.Healthy,
423-
"failure_tolerance": state.FailureTolerance,
424-
"optimistic_failure_tolerance": state.OptimisticFailureTolerance,
425-
"servers": state.Servers,
426-
"leader": state.Leader,
427-
"voters": state.Voters,
428-
"non_voters": state.NonVoters,
421+
"healthy": state.Healthy,
422+
"failure_tolerance": state.FailureTolerance,
423+
"servers": state.Servers,
424+
"leader": state.Leader,
425+
"voters": state.Voters,
426+
"non_voters": state.NonVoters,
429427
},
430428
}, nil
431429
}

vendor/github.com/hashicorp/vault/api/sys_raft.go

Lines changed: 6 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)