Skip to content

Commit

Permalink
fix(eureka): getInstanceToModify calculation was incorrect with mul…
Browse files Browse the repository at this point in the history
…tiple health statuses (#2384)

Previously it was iterating through each `health` and double counting
instances that had both eureka and non-eureka health statuses.
  • Loading branch information
ajordens authored Feb 21, 2018
1 parent c1477b1 commit 40842e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,15 @@ abstract class AbstractEurekaSupport {

instances.each { instanceId ->
def instanceInExistingServerGroup = serverGroup.instances.find { it.name == instanceId }
instanceInExistingServerGroup?.health?.each { Map<String, String> health ->
if (DiscoveryStatus.Enable.value.equalsIgnoreCase(health?.eurekaStatus)) {
if (instanceInExistingServerGroup) {
boolean isUp = false
instanceInExistingServerGroup.health?.flatten()?.each { Map<String, String> health ->
if (DiscoveryStatus.Enable.value.equalsIgnoreCase(health?.eurekaStatus)) {
isUp = true
}
}

if (isUp) {
unmodified.add(instanceId)
} else {
modified.add(instanceId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AbstractEurekaSupportSpec extends Specification {
1 * clusterProvider.getServerGroup("test", "us-west-2", "asg-v001") >> {
return serverGroup(
instancesInServerGroup.collect {
instance(it.key, ["eurekaStatus": it.value])
instance(it.key, [["eurekaStatus": it.value], ["notEurekaStatus": it.value]])
}
)
}
Expand All @@ -63,10 +63,10 @@ class AbstractEurekaSupportSpec extends Specification {
}
}

Instance instance(String name, Map<String, String> health) {
Instance instance(String name, List<Map<String, String>> healths) {
return Mock(Instance) {
_ * getName() >> { return name }
_ * getHealth() >> { return [health] }
_ * getHealth() >> { return healths }
}
}

Expand Down

0 comments on commit 40842e0

Please sign in to comment.