This is an automated email from the ASF dual-hosted git repository.
weizhou pushed a commit to branch 4.19
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.19 by this push:
new d32065fd38a backport #10500 framework/cluster: fix NPE for ms-host
status when mgr stops (#10653)
d32065fd38a is described below
commit d32065fd38a2b9216efa28a6890ae6dfc504daca
Author: Bernardo De Marco Gonçalves <[email protected]>
AuthorDate: Wed Apr 9 09:20:51 2025 -0300
backport #10500 framework/cluster: fix NPE for ms-host status when mgr
stops (#10653)
---
.../java/com/cloud/cluster/ClusterManagerImpl.java | 24 ++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git
a/framework/cluster/src/main/java/com/cloud/cluster/ClusterManagerImpl.java
b/framework/cluster/src/main/java/com/cloud/cluster/ClusterManagerImpl.java
index d601c094ca7..e684f6fd42f 100644
--- a/framework/cluster/src/main/java/com/cloud/cluster/ClusterManagerImpl.java
+++ b/framework/cluster/src/main/java/com/cloud/cluster/ClusterManagerImpl.java
@@ -1052,12 +1052,24 @@ public class ClusterManagerImpl extends ManagerBase
implements ClusterManager, C
}
if (_mshostId != null) {
- final ManagementServerHostVO mshost = _mshostDao.findByMsid(_msId);
- final ManagementServerStatusVO mshostStatus =
mshostStatusDao.findByMsId(mshost.getUuid());
- mshost.setState(ManagementServerHost.State.Down);
- mshostStatus.setLastJvmStop(new Date());
- _mshostDao.update(_mshostId, mshost);
- mshostStatusDao.update(mshostStatus.getId(), mshostStatus);
+ ManagementServerHostVO mshost = _mshostDao.findByMsid(_msId);
+ if (mshost != null) {
+ ManagementServerStatusVO mshostStatus =
mshostStatusDao.findByMsId(mshost.getUuid());
+ if (mshostStatus != null) {
+ mshost.setState(ManagementServerHost.State.Down);
+ mshostStatus.setLastJvmStop(new Date());
+ _mshostDao.update(_mshostId, mshost);
+ mshostStatusDao.update(mshostStatus.getId(), mshostStatus);
+ } else {
+ s_logger.warn(String.format("Found a management server
host [%s] without a status. This should never happen!", mshost));
+ mshostStatus = new ManagementServerStatusVO();
+ mshostStatus.setMsId(mshost.getUuid());
+ mshostStatus.setLastSystemBoot(new Date());
+ mshostStatus.setLastJvmStart(new Date());
+ mshostStatus.setUpdated(new Date());
+ mshostStatusDao.persist(mshostStatus);
+ }
+ }
}
_heartbeatScheduler.shutdownNow();