DaanHoogland commented on code in PR #13125:
URL: https://github.com/apache/cloudstack/pull/13125#discussion_r3903342249
##########
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:
##########
@@ -7661,10 +7661,20 @@ private boolean isImplicitPlannerUsedByOffering(long
offeringId) {
protected boolean isAnyVmVolumeUsingLocalStorage(final List<VolumeVO>
volumes) {
for (VolumeVO vol : volumes) {
DiskOfferingVO diskOffering =
_diskOfferingDao.findById(vol.getDiskOfferingId());
- if (diskOffering.isUseLocalStorage()) {
+ if (diskOffering != null && diskOffering.isUseLocalStorage()) {
return true;
}
- StoragePoolVO storagePool =
_storagePoolDao.findById(vol.getPoolId());
+ Long poolId = vol.getPoolId();
+ if (poolId == null) {
+ logger.debug("Skipping volume without storage pool while
checking local storage usage: {}", vol);
+ continue;
+ }
+ StoragePoolVO storagePool = _storagePoolDao.findById(poolId);
+ if (storagePool == null || storagePool.getRemoved() != null) {
+ throw new CloudRuntimeException(String.format(
+ "Cannot determine local storage usage for active
volume %s because storage pool ID %s is missing or removed",
+ vol, poolId));
+ }
Review Comment:
how about when it is not attached to a running VM? might it be valid to
still have a already removed pool?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]