This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new aecfe6d server: save GUID for KVM cluster (#3398)
aecfe6d is described below
commit aecfe6d500dd3fa1b6bcef53f58dae7fa87c0447
Author: Rohit Yadav <[email protected]>
AuthorDate: Wed Jun 12 12:47:24 2019 +0530
server: save GUID for KVM cluster (#3398)
When a KVM host is added to a cluster, the cluster GUID is null. In case
the KVM host fails to be added, the GUID is not set to null and if any
other hosts are added an exception is thrown by the resource manager
that does not allow addition of hosts to a cluster with existing hosts
whose GUID is null.
In case of KVM, other hosts may be added in parallel therefore this
restriction can be safely removed.
Signed-off-by: Rohit Yadav <[email protected]>
---
.../kvm/discoverer/LibvirtServerDiscoverer.java | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git
a/server/src/main/java/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java
b/server/src/main/java/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java
index 0b8b40b..6c9bcac 100644
---
a/server/src/main/java/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java
+++
b/server/src/main/java/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java
@@ -210,6 +210,12 @@ public abstract class LibvirtServerDiscoverer extends
DiscovererBase implements
return null;
}
+ // Set cluster GUID based on cluster ID if null
+ if (cluster.getGuid() == null) {
+
cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
+ _clusterDao.update(clusterId, cluster);
+ }
+
Map<KvmDummyResourceBase, Map<String, String>> resources = new
HashMap<KvmDummyResourceBase, Map<String, String>>();
Map<String, String> details = new HashMap<String, String>();
if (!uri.getScheme().equals("http")) {
@@ -230,8 +236,9 @@ public abstract class LibvirtServerDiscoverer extends
DiscovererBase implements
if (existingHosts != null) {
for (HostVO existingHost : existingHosts) {
if
(existingHost.getGuid().toLowerCase().startsWith(guid.toLowerCase())) {
- s_logger.debug("Skipping " + agentIp + " because " +
guid + " is already in the database for resource " + existingHost.getGuid());
- return null;
+ final String msg = "Skipping host " + agentIp + "
because " + guid + " is already in the database for resource " +
existingHost.getGuid() + " with ID " + existingHost.getUuid();
+ s_logger.debug(msg);
+ throw new CloudRuntimeException(msg);
}
}
}
@@ -326,12 +333,6 @@ public abstract class LibvirtServerDiscoverer extends
DiscovererBase implements
details.put("guid", connectedHost.getGuid());
- // place a place holder guid derived from cluster ID
- if (cluster.getGuid() == null) {
-
cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
- _clusterDao.update(clusterId, cluster);
- }
-
// save user name and password
_hostDao.loadDetails(connectedHost);
Map<String, String> hostDetails = connectedHost.getDetails();