Skip to content

Commit 15ffec2

Browse files
Alena ProkharchykDaanHoogland
authored andcommitted
CLOUDSTACK-6934: don't try to detach volume from host when volume was never allocated to a primary storage
(cherry picked from commit 92fea03)
1 parent e988c91 commit 15ffec2

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -866,9 +866,11 @@ public void disconnectVolumesFromHost(long vmId, long hostId) {
866866
if (volumesForVm != null) {
867867
for (VolumeVO volumeForVm : volumesForVm) {
868868
VolumeInfo volumeInfo = volFactory.getVolume(volumeForVm.getId());
869-
DataStore dataStore = dataStoreMgr.getDataStore(volumeForVm.getPoolId(), DataStoreRole.Primary);
870-
871-
volService.disconnectVolumeFromHost(volumeInfo, host, dataStore);
869+
// pool id can be null for the VM's volumes in Allocated state
870+
if (volumeForVm.getPoolId() != null) {
871+
DataStore dataStore = dataStoreMgr.getDataStore(volumeForVm.getPoolId(), DataStoreRole.Primary);
872+
volService.disconnectVolumeFromHost(volumeInfo, host, dataStore);
873+
}
872874
}
873875
}
874876
}

0 commit comments

Comments
 (0)