Skip to content

Commit 6354604

Browse files
SakshamsPrachi Damle
authored andcommitted
CLOUDSTACK-4572: findHostsForMigration API does not return correct host list
Changes: Expected behavior: The api should return the list of suitable/unsuitable hosts Added fix that creates a deep copy of the the variable allHosts and prevents faulty host list return.
1 parent e362f51 commit 6354604

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎server/src/com/cloud/server/ManagementServerImpl.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,8 +1161,10 @@ public Pair<List<? extends Host>, Integer> searchForServers(ListHostsCmd cmd) {
11611161
null, null, null);
11621162
}
11631163

1164-
Pair<List<? extends Host>, Integer> otherHosts = new Pair<List <? extends Host>, Integer>(allHosts,
1165-
new Integer(allHosts.size()));
1164+
//'otherHosts' must use the current value of allHosts as allHosts may get modified later in the allocator
1165+
List<HostVO> allHostsCpy = new ArrayList<HostVO>(allHosts);
1166+
Pair<List<? extends Host>, Integer> otherHosts = new Pair<List <? extends Host>, Integer>(allHostsCpy,
1167+
new Integer(allHostsCpy.size()));
11661168
List<Host> suitableHosts = new ArrayList<Host>();
11671169
ExcludeList excludes = new ExcludeList();
11681170
excludes.addHost(srcHostId);

0 commit comments

Comments
 (0)