Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Potenial issue with isHealthy logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrencegripper authored and ldez committed Dec 15, 2017
1 parent c01c1ef commit ca1fb57
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion servicefabric.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func isPrimary(instance replicaInstance) bool {
}

func isHealthy(instanceData *sf.ReplicaItemBase) bool {
return instanceData != nil && (instanceData.ReplicaStatus == "Ready" || instanceData.HealthState != "Error")
return instanceData != nil && (instanceData.ReplicaStatus == "Ready" && instanceData.HealthState != "Error")
}

func hasHTTPEndpoint(instanceData *sf.ReplicaItemBase) bool {
Expand Down
16 changes: 16 additions & 0 deletions servicefabric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,22 @@ func TestIsHealthy(t *testing.T) {
},
expected: false,
},
{
desc: "When replica down but health only warning",
replica: &sf.ReplicaItem{
ReplicaItemBase: &sf.ReplicaItemBase{
Address: `{"Endpoints":{"":"localhost:30001+bce46a8c-b62d-4996-89dc-7ffc00a96902-131496928082309293"}}`,
HealthState: "Warning",
LastInBuildDurationInSeconds: "1",
NodeName: "_Node_0",
ReplicaRole: "Primary",
ReplicaStatus: "Down",
ServiceKind: "Stateful",
},
ID: "131496928082309293",
},
expected: false,
},
}

for _, test := range testCases {
Expand Down

0 comments on commit ca1fb57

Please sign in to comment.