This is an automated email from the ASF dual-hosted git repository.

Pearl1594 pushed a commit to branch fix-mshost-duplicate-registration
in repository https://gitbox.apache.org/repos/asf/cloudstack.git

commit 78516eae780a4e6ec39ea9e198e48afffd8ef4ba
Author: mprokopchuk <[email protected]>
AuthorDate: Mon Jul 6 14:15:18 2026 -0700

    Potential fix for pull request finding
    
    Co-authored-by: Copilot Autofix powered by AI 
<[email protected]>
---
 .../cluster/src/main/java/com/cloud/cluster/ClusterManagerImpl.java  | 5 +++--
 1 file changed, 3 insertions(+), 2 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 2856b0a23f2..bb11258f907 100644
--- a/framework/cluster/src/main/java/com/cloud/cluster/ClusterManagerImpl.java
+++ b/framework/cluster/src/main/java/com/cloud/cluster/ClusterManagerImpl.java
@@ -1048,8 +1048,9 @@ public class ClusterManagerImpl extends ManagerBase 
implements ClusterManager, C
 
                 ManagementServerHostVO mshost = _mshostDao.findByMsid(_msId);
 
-                // Look for duplicate hostname in the case of kubernetes setup 
where ip/mac changes but hostname is constant.
-                if (mshost == null && StringUtils.isNotBlank(currentHostname)) 
{
+                // Look for duplicate hostname in Kubernetes setups where 
IP/MAC changes but hostname is constant.
+                // Skip the default "localhost" hostname fallback to avoid 
removing other active nodes when hostname resolution fails.
+                if (mshost == null && StringUtils.isNotBlank(currentHostname) 
&& !StringUtils.equalsIgnoreCase(currentHostname, "localhost")) {
                     List<ManagementServerHostVO> activeEntries = 
_mshostDao.findAllByName(currentHostname);
                     for (ManagementServerHostVO activeEntry : activeEntries) {
                         // Found an active entry with this hostname but 
different MSID

Reply via email to