Skip to content

Commit e1b3f0c

Browse files
Prachi DamleAlex Huang
authored andcommitted
CS-16258: Load Test - 1 host stuck in "Rebalancing" state forever. "java.lang.NullPointerException" seen in "Cluster-Worker" thread that was handling this process.
- Using temp to not affect the return value for the method.
1 parent 4e29e0d commit e1b3f0c

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎server/src/com/cloud/resource/ResourceManagerImpl.java‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,19 +1639,21 @@ private Host createHostAndAgent(ServerResource resource, Map<String, String> det
16391639
if (cmds != null) {
16401640
resource.disconnected();
16411641
}
1642-
if(host == null){
1642+
//In case of some db errors, we may land with the sitaution that host is null. We need to reload host from db and call disconnect on it so that it will be loaded for reconnection next time
1643+
HostVO tempHost = host;
1644+
if(tempHost == null){
16431645
if (cmds != null) {
16441646
StartupCommand firstCmd = cmds[0];
1645-
host = findHostByGuid(firstCmd.getGuid());
1646-
if (host == null) {
1647-
host = findHostByGuid(firstCmd.getGuidWithoutResource());
1647+
tempHost = findHostByGuid(firstCmd.getGuid());
1648+
if (tempHost == null) {
1649+
tempHost = findHostByGuid(firstCmd.getGuidWithoutResource());
16481650
}
16491651
}
16501652
}
16511653

1652-
if (host != null) {
1654+
if (tempHost != null) {
16531655
/* Change agent status to Alert */
1654-
_agentMgr.agentStatusTransitTo(host, Status.Event.AgentDisconnected, _nodeId);
1656+
_agentMgr.agentStatusTransitTo(tempHost, Status.Event.AgentDisconnected, _nodeId);
16551657
/* Don't change resource state here since HostVO is already in database, which means resource state has had an appropriate value*/
16561658
}
16571659
}

0 commit comments

Comments
 (0)