Skip to content

Commit f0c6ed1

Browse files
authored
abriters report as healthy (#740)
1 parent 0df45f5 commit f0c6ed1

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

pkg/readiness/health/health.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ type StepStatus struct {
6262
}
6363

6464
// isReadyState will return true, meaning a *ready state* in the sense that this Process can
65-
// accept read operations. There are no other states in which the MongoDB server could that
66-
// would mean a Ready State.
65+
// accept read operations.
6766
// It returns true if the managed process is mongos or standalone (replicationStatusUndefined)
6867
// or if the agent doesn't publish the replica status (older agents)
6968
func (h processHealth) IsReadyState() bool {
@@ -75,5 +74,15 @@ func (h processHealth) IsReadyState() bool {
7574
return true
7675
}
7776

78-
return status == replicationStatusPrimary || status == replicationStatusSecondary
77+
switch status {
78+
case
79+
// There are no other states in which the MongoDB
80+
// server could that would mean a Ready State.
81+
replicationStatusPrimary,
82+
replicationStatusSecondary,
83+
replicationStatusArbiter:
84+
return true
85+
}
86+
87+
return false
7988
}

pkg/readiness/health/health_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import (
66
"github.com/stretchr/testify/assert"
77
)
88

9-
// TestIsReadyState checks that Primary, Secondary and Undefined always result
9+
// TestIsReadyState checks that Primary, Secondary, Arbiter, and Undefined always result
1010
// in Ready State.
1111
func TestIsReadyStateNotPrimaryNorSecondary(t *testing.T) {
12-
status := []replicationStatus{replicationStatusUndefined, replicationStatusPrimary, replicationStatusSecondary}
12+
status := []replicationStatus{replicationStatusUndefined, replicationStatusPrimary, replicationStatusSecondary, replicationStatusArbiter}
1313

1414
for i := range status {
1515
h := processHealth{ReplicaStatus: &status[i]}
@@ -21,7 +21,7 @@ func TestIsReadyStateNotPrimaryNorSecondary(t *testing.T) {
2121
func TestIsNotReady(t *testing.T) {
2222
status := []replicationStatus{
2323
replicationStatusStartup, replicationStatusRecovering, replicationStatusStartup2,
24-
replicationStatusUnknown, replicationStatusArbiter, replicationStatusDown,
24+
replicationStatusUnknown, replicationStatusDown,
2525
replicationStatusRollback, replicationStatusRemoved,
2626
}
2727

0 commit comments

Comments
 (0)