Skip to content

Commit 3cb4c80

Browse files
Marcus SorensenMarcus Sorensen
andauthored
server: fix null pointer on powerflex attach volume edge case (#7498)
This PR fixes a null pointer edge case where a PowerFlex volume is attached to a VM. In this edge case, a VM has been created, started, stopped, and then reimaged. VM has a last host ID but the newly attached volume does not yet have a storage pool assigned, it will be assigned on the VM start. However, we assume that if the VM's host is not null, we need to try to revoke access to the volume for the host. Since there is no storage pool yet for the volume, we hit a null pointer when checking to see if the volume's pool is PowerFlex. This was affecting all storage types, I could reproduce it with local storage, since the null pointer is at the check for pool's type. Co-authored-by: Marcus Sorensen <mls@apple.com>
1 parent bdd5363 commit 3cb4c80

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4260,7 +4260,7 @@ private VolumeVO sendAttachVolumeCommand(UserVmVO vm, VolumeVO volumeToAttach, L
42604260
_volsDao.update(volumeToAttach.getId(), volumeToAttach);
42614261
}
42624262

4263-
if (host != null && volumeToAttachStoragePool.getPoolType() == Storage.StoragePoolType.PowerFlex) {
4263+
if (host != null && volumeToAttachStoragePool != null && volumeToAttachStoragePool.getPoolType() == Storage.StoragePoolType.PowerFlex) {
42644264
// Unmap the volume on PowerFlex/ScaleIO pool for stopped VM
42654265
volService.revokeAccess(volFactory.getVolume(volumeToAttach.getId()), host, dataStore);
42664266
}

0 commit comments

Comments
 (0)