From 3cb4c801fb4dfffa5e0f18ccdb1aa453db74ef19 Mon Sep 17 00:00:00 2001 From: Marcus Sorensen Date: Mon, 8 May 2023 00:37:41 -0600 Subject: [PATCH] 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 --- .../src/main/java/com/cloud/storage/VolumeApiServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java index d259ad871dc..b02dac051cb 100644 --- a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java @@ -4260,7 +4260,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic _volsDao.update(volumeToAttach.getId(), volumeToAttach); } - if (host != null && volumeToAttachStoragePool.getPoolType() == Storage.StoragePoolType.PowerFlex) { + if (host != null && volumeToAttachStoragePool != null && volumeToAttachStoragePool.getPoolType() == Storage.StoragePoolType.PowerFlex) { // Unmap the volume on PowerFlex/ScaleIO pool for stopped VM volService.revokeAccess(volFactory.getVolume(volumeToAttach.getId()), host, dataStore); }