sureshanaparti opened a new pull request, #12451:
URL: https://github.com/apache/cloudstack/pull/12451
### Description
This PR fixes NPE issue while deleting storage pool when pool has detached
volumes.
Noticed the below exception while deleting the pool:
```
2026-01-16 08:37:10,817 ERROR [c.c.a.ApiServer]
(qtp253011924-22:[ctx-b62d6305, ctx-eae6e42c]) (logid:95645b16) unhandled
exception executing api command: [Ljava.lang.String;@47cdfd8e
java.lang.NullPointerException: Cannot invoke
"com.cloud.vm.VMInstanceVO.getUuid()" because "volInstance" is null
at
com.cloud.storage.StorageManagerImpl.getStoragePoolNonDestroyedVolumesLog(StorageManagerImpl.java:1568)
at
com.cloud.storage.StorageManagerImpl.lambda$deleteDataStoreInternal$2(StorageManagerImpl.java:1535)
at org.apache.logging.log4j.util.LambdaUtil.get(LambdaUtil.java:63)
at org.apache.logging.log4j.util.LambdaUtil.getAll(LambdaUtil.java:47)
at
org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2097)
at
org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1883)
at
org.apache.logging.log4j.spi.AbstractLogger.debug(AbstractLogger.java:367)
at
com.cloud.storage.StorageManagerImpl.deleteDataStoreInternal(StorageManagerImpl.java:1535)
at
com.cloud.storage.StorageManagerImpl.deletePool(StorageManagerImpl.java:1459)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
at jdk.proxy3/jdk.proxy3.$Proxy130.deletePool(Unknown Source)
at
org.apache.cloudstack.api.command.admin.storage.DeletePoolCmd.execute(DeletePoolCmd.java:71)
at com.cloud.api.ApiDispatcher.dispatch(ApiDispatcher.java:173)
at com.cloud.api.ApiServer.queueCommand(ApiServer.java:830)
at com.cloud.api.ApiServer.handleRequest(ApiServer.java:654)
at com.cloud.api.ApiServlet.processRequestInContext(ApiServlet.java:351)
at com.cloud.api.ApiServlet$1.run(ApiServlet.java:154)
at
org.apache.cloudstack.managed.context.impl.DefaultManagedContext$1.call(DefaultManagedContext.java:56)
at
org.apache.cloudstack.managed.context.impl.DefaultManagedContext.callWithContext(DefaultManagedContext.java:103)
at
org.apache.cloudstack.managed.context.impl.DefaultManagedContext.runWithContext(DefaultManagedContext.java:53)
at com.cloud.api.ApiServlet.processRequest(ApiServlet.java:151)
at com.cloud.api.ApiServlet.doGet(ApiServlet.java:105)
```
<!--- Describe your changes in DETAIL - And how has behaviour functionally
changed. -->
<!-- For new features, provide link to FS, dev ML discussion etc. -->
<!-- In case of bug fix, the expected and actual behaviours, steps to
reproduce. -->
<!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be
closed when this PR gets merged -->
<!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
<!-- Fixes: # -->
<!---
*******************************************************************************
-->
<!--- NOTE: AUTOMATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE
DOCUMENTATION. -->
<!--- PLEASE PUT AN 'X' in only **ONE** box -->
<!---
*******************************************************************************
-->
### Types of changes
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] Enhancement (improves an existing feature and functionality)
- [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
- [ ] Build/CI
- [ ] Test (unit or integration test code)
### Feature/Enhancement Scale or Bug Severity
#### Feature/Enhancement Scale
- [ ] Major
- [ ] Minor
#### Bug Severity
- [ ] BLOCKER
- [ ] Critical
- [x] Major
- [ ] Minor
- [ ] Trivial
### Screenshots (if appropriate):
### How Has This Been Tested?
Deleted storage pool when pool has detached volumes on it. Expunged the
volumes later and able to delete the pool.
**BEFORE CHANGES:**
<img width="1450" height="685" alt="DeleteStoragePool_Issue"
src="https://github.com/user-attachments/assets/77c2c261-83c4-41f8-8de5-fd9ce502330c"
/>
DB:
```
mysql> SELECT id, uuid, name, state, disk_type, format, path, instance_id,
removed FROM volumes WHERE pool_id = 5;
+----+--------------------------------------+-------------+----------+-----------+--------+-----------------------------------+-------------+---------------------+
| id | uuid | name | state |
disk_type | format | path | instance_id | removed
|
+----+--------------------------------------+-------------+----------+-----------+--------+-----------------------------------+-------------+---------------------+
| 8 | 943a0630-1f48-426a-88e6-6ff40f544516 | ROOT-8 | Expunged | NULL
| QCOW2 | 9fdf334300000002:vol-8-f2e5-dee6 | 8 | 2025-10-22
09:29:58 |
| 10 | 3847c1a5-d05b-4576-add8-c0454d78fe7c | ROOT-8 | Expunged | NULL
| RAW | 9fdf334400000002:vol-10-f2e5-dee6 | 8 | 2026-01-16
08:34:56 |
| 16 | 6de44955-dde3-4044-a52d-4ca2e2b558a7 | PFlexData01 | Ready | NULL
| QCOW2 | 9fdf5a5100000004:vol-16-f2e5-dee6 | NULL | NULL
|
+----+--------------------------------------+-------------+----------+-----------+--------+-----------------------------------+-------------+---------------------+
3 rows in set (0.00 sec)
```
**AFTER CHANGES:**
<img width="1450" height="695" alt="DeleteStoragePool_AfterFix"
src="https://github.com/user-attachments/assets/101c65ea-2f57-4fba-8a7e-af0dc87ccf8c"
/>
<!-- Please describe in detail how you tested your changes. -->
<!-- Include details of your testing environment, and the tests you ran to
-->
#### How did you try to break this feature and the system with this change?
<!-- see how your change affects other areas of the code, etc. -->
<!-- Please read the
[CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
document -->
--
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]