Skip to content

Commit a4e256b

Browse files
committed
CLOUDSTACK-4040: [Object_store_refactor] System VMs are not spinning up
if S3 storage configuration is not part of zone creation wizard.
1 parent 7522f81 commit a4e256b

1 file changed

Lines changed: 60 additions & 58 deletions

File tree

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

Lines changed: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ public List<? extends Cluster> discoverCluster(AddClusterCmd cmd) throws Illegal
367367
// Check if the zone exists in the system
368368
DataCenterVO zone = _dcDao.findById(dcId);
369369
if (zone == null) {
370-
InvalidParameterValueException ex = new InvalidParameterValueException(
371-
"Can't find zone by the id specified");
370+
InvalidParameterValueException ex = new InvalidParameterValueException(
371+
"Can't find zone by the id specified");
372372
ex.addProxyObject(String.valueOf(dcId), "dcId");
373373
throw ex;
374374
}
@@ -392,8 +392,8 @@ public List<? extends Cluster> discoverCluster(AddClusterCmd cmd) throws Illegal
392392
}
393393
// check if pod belongs to the zone
394394
if (!Long.valueOf(pod.getDataCenterId()).equals(dcId)) {
395-
InvalidParameterValueException ex = new InvalidParameterValueException(
396-
"Pod with specified id doesn't belong to the zone " + dcId);
395+
InvalidParameterValueException ex = new InvalidParameterValueException(
396+
"Pod with specified id doesn't belong to the zone " + dcId);
397397
ex.addProxyObject(pod.getUuid(), "podId");
398398
ex.addProxyObject(zone.getUuid(), "dcId");
399399
throw ex;
@@ -564,8 +564,8 @@ public List<? extends Host> discoverHosts(AddHostCmd cmd) throws IllegalArgument
564564
if (clusterId != null) {
565565
ClusterVO cluster = _clusterDao.findById(clusterId);
566566
if (cluster == null) {
567-
InvalidParameterValueException ex = new InvalidParameterValueException(
568-
"can not find cluster for specified clusterId");
567+
InvalidParameterValueException ex = new InvalidParameterValueException(
568+
"can not find cluster for specified clusterId");
569569
ex.addProxyObject(clusterId.toString(), "clusterId");
570570
throw ex;
571571
} else {
@@ -587,7 +587,7 @@ public List<? extends Host> discoverHosts(AddHostCmd cmd) throws IllegalArgument
587587

588588
@Override
589589
public List<? extends Host> discoverHosts(AddSecondaryStorageCmd cmd) throws IllegalArgumentException, DiscoveryException,
590-
InvalidParameterValueException {
590+
InvalidParameterValueException {
591591
Long dcId = cmd.getZoneId();
592592
String url = cmd.getUrl();
593593
return discoverHostsFull(dcId, null, null, null, url, null, null, "SecondaryStorage", null, null, false);
@@ -620,11 +620,11 @@ private List<HostVO> discoverHostsFull(Long dcId, Long podId, Long clusterId, St
620620
}
621621
// check if pod belongs to the zone
622622
if (!Long.valueOf(pod.getDataCenterId()).equals(dcId)) {
623-
InvalidParameterValueException ex = new InvalidParameterValueException(
624-
"Pod with specified podId"
625-
+ podId
626-
+ " doesn't belong to the zone with specified zoneId"
627-
+ dcId);
623+
InvalidParameterValueException ex = new InvalidParameterValueException(
624+
"Pod with specified podId"
625+
+ podId
626+
+ " doesn't belong to the zone with specified zoneId"
627+
+ dcId);
628628
ex.addProxyObject(pod.getUuid(), "podId");
629629
ex.addProxyObject(zone.getUuid(), "dcId");
630630
throw ex;
@@ -683,11 +683,11 @@ private List<HostVO> discoverHostsFull(Long dcId, Long podId, Long clusterId, St
683683
} catch (Exception e) {
684684
cluster = _clusterDao.findBy(clusterName, podId);
685685
if (cluster == null) {
686-
CloudRuntimeException ex = new CloudRuntimeException(
687-
"Unable to create cluster "
688-
+ clusterName
689-
+ " in pod with specified podId and data center with specified dcID",
690-
e);
686+
CloudRuntimeException ex = new CloudRuntimeException(
687+
"Unable to create cluster "
688+
+ clusterName
689+
+ " in pod with specified podId and data center with specified dcID",
690+
e);
691691
ex.addProxyObject(pod.getUuid(), "podId");
692692
ex.addProxyObject(zone.getUuid(), "dcId");
693693
throw ex;
@@ -959,11 +959,11 @@ public boolean deleteCluster(DeleteClusterCmd cmd) {
959959
if (hypervisorType == HypervisorType.VMware && Boolean.parseBoolean(_configDao.getValue(Config.VmwareUseNexusVSwitch.toString()))) {
960960
_clusterVSMMapDao.removeByClusterId(cmd.getId());
961961
}
962-
// remove from dedicated resources
963-
DedicatedResourceVO dr = _dedicatedDao.findByClusterId(cluster.getId());
964-
if (dr != null) {
965-
_dedicatedDao.remove(dr.getId());
966-
}
962+
// remove from dedicated resources
963+
DedicatedResourceVO dr = _dedicatedDao.findByClusterId(cluster.getId());
964+
if (dr != null) {
965+
_dedicatedDao.remove(dr.getId());
966+
}
967967
}
968968

969969
txn.commit();
@@ -1427,8 +1427,8 @@ private Object dispatchToStateAdapters(ResourceStateAdapter.Event event, boolean
14271427
Iterator<Map.Entry<String, ResourceStateAdapter>> it = _resourceStateAdapters.entrySet().iterator();
14281428
Object result = null;
14291429
while (it.hasNext()) {
1430-
Map.Entry<String, ResourceStateAdapter> item = it
1431-
.next();
1430+
Map.Entry<String, ResourceStateAdapter> item = it
1431+
.next();
14321432
ResourceStateAdapter adapter = item.getValue();
14331433

14341434
String msg = new String("Dispatching resource state event " + event + " to " + item.getKey());
@@ -1671,7 +1671,7 @@ private boolean isFirstHostInCluster(HostVO host) {
16711671

16721672
private void markHostAsDisconnected(HostVO host, StartupCommand[] cmds) {
16731673
if (host == null) { // in case host is null due to some errors, try
1674-
// reloading the host from db
1674+
// reloading the host from db
16751675
if (cmds != null) {
16761676
StartupCommand firstCmd = cmds[0];
16771677
host = findHostByGuid(firstCmd.getGuid());
@@ -1721,13 +1721,13 @@ private Host createHostAndAgent(ServerResource resource, Map<String, String> det
17211721
host = findHostByGuid(firstCmd.getGuidWithoutResource());
17221722
}
17231723
if (host != null && host.getRemoved() == null) { // host already
1724-
// added, no
1725-
// need to add
1726-
// again
1724+
// added, no
1725+
// need to add
1726+
// again
17271727
s_logger.debug("Found the host " + host.getId() + " by guid: " + firstCmd.getGuid() + ", old host reconnected as new");
17281728
hostExists = true; // ensures that host status is left
1729-
// unchanged in case of adding same one
1730-
// again
1729+
// unchanged in case of adding same one
1730+
// again
17311731
return null;
17321732
}
17331733
}
@@ -1793,13 +1793,13 @@ private Host createHostAndAgentDeferred(ServerResource resource, Map<String, Str
17931793
host = findHostByGuid(firstCmd.getGuidWithoutResource());
17941794
}
17951795
if (host != null && host.getRemoved() == null) { // host already
1796-
// added, no
1797-
// need to add
1798-
// again
1796+
// added, no
1797+
// need to add
1798+
// again
17991799
s_logger.debug("Found the host " + host.getId() + " by guid: " + firstCmd.getGuid() + ", old host reconnected as new");
18001800
hostExists = true; // ensures that host status is left
1801-
// unchanged in case of adding same one
1802-
// again
1801+
// unchanged in case of adding same one
1802+
// again
18031803
return null;
18041804
}
18051805
}
@@ -1808,29 +1808,29 @@ private Host createHostAndAgentDeferred(ServerResource resource, Map<String, Str
18081808
GlobalLock addHostLock = GlobalLock.getInternLock("AddHostLock");
18091809
try {
18101810
if (addHostLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION)) { // to
1811-
// safely
1812-
// determine
1813-
// first
1814-
// host
1815-
// in
1816-
// cluster
1817-
// in
1818-
// multi-MS
1819-
// scenario
1811+
// safely
1812+
// determine
1813+
// first
1814+
// host
1815+
// in
1816+
// cluster
1817+
// in
1818+
// multi-MS
1819+
// scenario
18201820
try {
18211821
host = createHostVO(cmds, resource, details, hostTags, ResourceStateAdapter.Event.CREATE_HOST_VO_FOR_DIRECT_CONNECT);
18221822
if (host != null) {
18231823
deferAgentCreation = !isFirstHostInCluster(host); // if
1824-
// first
1825-
// host
1826-
// in
1827-
// cluster
1828-
// no
1829-
// need
1830-
// to
1831-
// defer
1832-
// agent
1833-
// creation
1824+
// first
1825+
// host
1826+
// in
1827+
// cluster
1828+
// no
1829+
// need
1830+
// to
1831+
// defer
1832+
// agent
1833+
// creation
18341834
}
18351835
} finally {
18361836
addHostLock.unlock();
@@ -1842,8 +1842,8 @@ private Host createHostAndAgentDeferred(ServerResource resource, Map<String, Str
18421842

18431843
if (host != null) {
18441844
if (!deferAgentCreation) { // if first host in cluster then
1845-
// create agent otherwise defer it to
1846-
// scan task
1845+
// create agent otherwise defer it to
1846+
// scan task
18471847
attache = _agentMgr.handleDirectConnectAgent(host, cmds, resource, forRebalance);
18481848
host = _hostDao.findById(host.getId()); // reload
18491849
} else {
@@ -2380,7 +2380,9 @@ public List<HypervisorType> listAvailHypervisorInZone(Long hostId, Long zoneId)
23802380
sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, zoneId);
23812381
}
23822382
if (hostId != null) {
2383-
sc.addAnd(sc.getEntity().getId(), Op.EQ, hostId);
2383+
// exclude the given host, since we want to check what hypervisor is already handled
2384+
// in adding this new host
2385+
sc.addAnd(sc.getEntity().getId(), Op.NEQ, hostId);
23842386
}
23852387
sc.addAnd(sc.getEntity().getType(), Op.EQ, Host.Type.Routing);
23862388
List<HostVO> hosts = sc.list();
@@ -2499,7 +2501,7 @@ public List<HostVO> listAllUpAndEnabledHostsInOneZoneByHypervisor(HypervisorType
24992501
sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
25002502
sc.addAnd(sc.getEntity().getResourceState(), Op.EQ, ResourceState.Enabled);
25012503
return sc.list();
2502-
}
2504+
}
25032505

25042506
@Override
25052507
@DB

0 commit comments

Comments
 (0)