Skip to content

Commit 4ed4f63

Browse files
committed
Prevent data corruption for StorPool volumes
Prevents data corruption in cases where a VM is started on a new host while it is already running on another host Scenario - if the host is down and the admin stops a VM with the option `force=true` the admin will be able to start it on another host. This may lead to a data corruption when the first host goes Up and the volume is attached on both hosts.
1 parent a4cce70 commit 4ed4f63

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@
6161
import org.apache.cloudstack.context.CallContext;
6262
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
6363
import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
64+
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
6465
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
66+
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
67+
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
68+
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
6569
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
6670
import org.apache.cloudstack.framework.ca.Certificate;
6771
import org.apache.cloudstack.framework.config.ConfigKey;
@@ -385,6 +389,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
385389
private DomainRouterJoinDao domainRouterJoinDao;
386390
@Inject
387391
private AnnotationDao annotationDao;
392+
@Inject
393+
DataStoreProviderManager dataStoreProviderManager;
388394

389395
VmWorkJobHandlerProxy _jobHandlerProxy = new VmWorkJobHandlerProxy(this);
390396

@@ -1204,6 +1210,11 @@ public void orchestrateStart(final String vmUuid, final Map<VirtualMachineProfil
12041210
planChangedByVolume = true;
12051211
}
12061212
}
1213+
DataStoreProvider storeProvider = dataStoreProviderManager.getDataStoreProvider(pool.getStorageProviderName());
1214+
DataStoreDriver storeDriver = storeProvider.getDataStoreDriver();
1215+
if (storeDriver instanceof PrimaryDataStoreDriver) {
1216+
((PrimaryDataStoreDriver)storeDriver).detachVolumeFromAllStorageNodes(vol);
1217+
}
12071218
}
12081219
}
12091220

0 commit comments

Comments
 (0)