Skip to content

Commit d660bc7

Browse files
rajesh-battalasudison
authored andcommitted
CLOUDSTACK-3089 [ZWPS] NPE while cancelling the Storage Maintenance
Signed-off-by: Edison Su <sudison@gmail.com>
1 parent 2bc4cbf commit d660bc7

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

server/src/com/cloud/storage/StoragePoolAutomationImpl.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@
2323

2424
import javax.inject.Inject;
2525

26-
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
27-
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
28-
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
29-
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
30-
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
31-
import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
26+
import org.apache.cloudstack.engine.subsystem.api.storage.*;
3227
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
3328
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
3429
import org.apache.log4j.Logger;
@@ -137,6 +132,7 @@ public boolean maintain(DataStore store) {
137132
//Handeling the Zone wide and cluster wide primay storage
138133
List<HostVO> hosts = new ArrayList<HostVO>();
139134
// if the storage scope is ZONE wide, then get all the hosts for which hypervisor ZWSP created to send Modifystoragepoolcommand
135+
//TODO: if it's zone wide, this code will list a lot of hosts in the zone, which may cause performance/OOM issue.
140136
if (pool.getScope().equals(ScopeType.ZONE)) {
141137
hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(pool.getHypervisor() , pool.getDataCenterId());
142138
} else {
@@ -366,8 +362,16 @@ public boolean cancelMaintain(DataStore store) {
366362
.findById(store.getId());
367363
StoragePool pool = (StoragePool)store;
368364

369-
List<HostVO> hosts = _resourceMgr.listHostsInClusterByStatus(
365+
//Handeling the Zone wide and cluster wide primay storage
366+
List<HostVO> hosts = new ArrayList<HostVO>();
367+
// if the storage scope is ZONE wide, then get all the hosts for which hypervisor ZWSP created to send Modifystoragepoolcommand
368+
if (poolVO.getScope().equals(ScopeType.ZONE)) {
369+
hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(poolVO.getHypervisor(), pool.getDataCenterId());
370+
} else {
371+
hosts = _resourceMgr.listHostsInClusterByStatus(
370372
pool.getClusterId(), Status.Up);
373+
}
374+
371375
if (hosts == null || hosts.size() == 0) {
372376
return true;
373377
}

0 commit comments

Comments
 (0)