Skip to content

Commit 5c54178

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 2df1ac5 commit 5c54178

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;
@@ -409,6 +413,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
409413
ResourceCleanupService resourceCleanupService;
410414
@Inject
411415
VmWorkJobDao vmWorkJobDao;
416+
@Inject
417+
DataStoreProviderManager dataStoreProviderManager;
412418

413419
private SingleCache<List<Long>> vmIdsInProgressCache;
414420

@@ -1224,6 +1230,11 @@ public void orchestrateStart(final String vmUuid, final Map<VirtualMachineProfil
12241230
planChangedByVolume = true;
12251231
}
12261232
}
1233+
DataStoreProvider storeProvider = dataStoreProviderManager.getDataStoreProvider(pool.getStorageProviderName());
1234+
DataStoreDriver storeDriver = storeProvider.getDataStoreDriver();
1235+
if (storeDriver instanceof PrimaryDataStoreDriver) {
1236+
((PrimaryDataStoreDriver)storeDriver).detachVolumeFromAllStorageNodes(vol);
1237+
}
12271238
}
12281239
}
12291240

0 commit comments

Comments
 (0)