Skip to content

Conversation

@sureshanaparti
Copy link
Contributor

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)

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • 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
  • 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:

DeleteStoragePool_Issue

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:

DeleteStoragePool_AfterFix

How did you try to break this feature and the system with this change?

@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 16.23%. Comparing base (f1f779a) to head (7b88ab6).

Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #12451   +/-   ##
=========================================
  Coverage     16.23%   16.23%           
- Complexity    13381    13383    +2     
=========================================
  Files          5657     5657           
  Lines        499024   499026    +2     
  Branches      60562    60564    +2     
=========================================
+ Hits          81029    81031    +2     
+ Misses       408959   408958    -1     
- Partials       9036     9037    +1     
Flag Coverage Δ
uitests 4.03% <ø> (ø)
unittests 17.09% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a NullPointerException that occurred when deleting a storage pool containing detached volumes. The bug was in a logging method that attempted to retrieve VM information for volumes without checking if the volume had an associated VM instance.

Changes:

  • Added null check for volume instance ID before attempting to retrieve VM information in logging code

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16395

@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16398

@DaanHoogland
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-15201)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 50168 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12451-t15201-kvm-ol8.zip
Smoke tests completed. 141 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants