From 3312394154c1ee42b3ff014eadc277a0c39b97cf Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Wed, 18 Jun 2014 09:59:23 -0700 Subject: [PATCH] CLOUDSTACK-6934: don't try to detach volume from host when volume was never allocated to a primary storage --- .../engine/orchestration/VolumeOrchestrator.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java index eea931e2712..050143cd8e9 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java @@ -894,9 +894,11 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati if (volumesForVm != null) { for (VolumeVO volumeForVm : volumesForVm) { VolumeInfo volumeInfo = volFactory.getVolume(volumeForVm.getId()); - DataStore dataStore = dataStoreMgr.getDataStore(volumeForVm.getPoolId(), DataStoreRole.Primary); - - volService.disconnectVolumeFromHost(volumeInfo, host, dataStore); + // pool id can be null for the VM's volumes in Allocated state + if (volumeForVm.getPoolId() != null) { + DataStore dataStore = dataStoreMgr.getDataStore(volumeForVm.getPoolId(), DataStoreRole.Primary); + volService.disconnectVolumeFromHost(volumeInfo, host, dataStore); + } } } }