Skip to content

Commit 0a77eb7

Browse files
authored
deal with NPE during host reconnect (#10158)
* log to see what command is being processed * exception names
1 parent 4787885 commit 0a77eb7

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
5353
import org.apache.cloudstack.outofbandmanagement.dao.OutOfBandManagementDao;
5454
import org.apache.cloudstack.utils.identity.ManagementServerNode;
55+
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
5556
import org.apache.commons.lang3.BooleanUtils;
5657
import org.apache.log4j.Logger;
5758
import org.apache.log4j.MDC;
@@ -569,27 +570,27 @@ protected AgentAttache notifyMonitorsOfConnection(final AgentAttache attache, fi
569570
}
570571
for (int i = 0; i < cmd.length; i++) {
571572
try {
573+
if (s_logger.isDebugEnabled()) {
574+
s_logger.debug("process connection to issue " + ReflectionToStringBuilderUtils.reflectCollection(cmd[i]) + " forRebalance == " + forRebalance);
575+
}
572576
monitor.second().processConnect(host, cmd[i], forRebalance);
573-
} catch (final Exception e) {
574-
if (e instanceof ConnectionException) {
575-
final ConnectionException ce = (ConnectionException)e;
576-
if (ce.isSetupError()) {
577-
s_logger.warn("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + " due to " + e.getMessage());
578-
handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true, true);
579-
throw ce;
580-
} else {
581-
s_logger.info("Monitor " + monitor.second().getClass().getSimpleName() + " says not to continue the connect process for " + hostId + " due to " + e.getMessage());
582-
handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested, true, true);
583-
return attache;
584-
}
585-
} else if (e instanceof HypervisorVersionChangedException) {
586-
handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested, true, true);
587-
throw new CloudRuntimeException("Unable to connect " + attache.getId(), e);
588-
} else {
589-
s_logger.error("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + " due to " + e.getMessage(), e);
577+
} catch (final ConnectionException ce) {
578+
if (ce.isSetupError()) {
579+
s_logger.warn("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + " due to " + ce.getMessage());
590580
handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true, true);
591-
throw new CloudRuntimeException("Unable to connect " + attache.getId(), e);
581+
throw ce;
582+
} else {
583+
s_logger.info("Monitor " + monitor.second().getClass().getSimpleName() + " says not to continue the connect process for " + hostId + " due to " + ce.getMessage());
584+
handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested, true, true);
585+
return attache;
592586
}
587+
} catch (final HypervisorVersionChangedException hvce) {
588+
handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested, true, true);
589+
throw new CloudRuntimeException("Unable to connect " + attache.getId(), hvce);
590+
} catch (final Exception e) {
591+
s_logger.error("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + " due to " + e.getMessage(), e);
592+
handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true, true);
593+
throw new CloudRuntimeException("Unable to connect " + attache.getId(), e);
593594
}
594595
}
595596
}

0 commit comments

Comments
 (0)