CloudStack 4.22: `prepareHostForMaintenance` throws NPE when stale destroyed volume references removed storage pool
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 55/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- java, mariadb, mysql
- 领域
- backend, cloud, infrastructure
调研方向
从第 7558 行的 UserVmManagerImpl.isAnyVmVolumeUsingLocalStorage 开始,跟踪其在 isVMUsingLocalStorage 和 ResourceManagerImpl.doMaintain 中的调用方。重现已销毁的陈旧卷和已移除的存储池状态,然后验证维护不再引发未处理的 NullPointerException,并确认针对陈旧卷所选择的行为已由相关测试覆盖。
由索引模型根据 Issue 内容生成。
描述
problem
Description
While attempting to place a KVM host into Maintenance mode in CloudStack 4.22, the maintenance operation failed with a NullPointerException.
The issue appears to occur when a VM has a stale/destroyed volume entry in the volumes table that still references a removed storage pool.
Instead of gracefully ignoring the stale volume metadata or returning a user-facing validation error, CloudStack crashes during maintenance preparation.
Environment
- CloudStack version: 4.22
- Hypervisor: KVM
- Primary storage: NFS
- Database: MySQL/MariaDB
Steps to reproduce
-
Have a VM with:
- one valid active ROOT volume
- one stale/destroyed ROOT volume entry still present in the
volumestable
-
The stale volume references a storage pool which has already been removed.
-
Attempt to place the host running the VM into Maintenance mode.
Example problematic DB state:
VM
SELECT id, uuid, name, instance_id, pool_id, state, removed
FROM volumes
WHERE instance_id = 446
ORDER BY id;
Result:
+------+--------------------------------------+----------+-------------+---------+---------+---------+
| id | uuid | name | instance_id | pool_id | state | removed |
+------+--------------------------------------+----------+-------------+---------+---------+---------+
| 928 | 6dea3d6f-bd6d-4e8b-9524-6e99c029694c | ROOT-446 | 446 | 4 | Destroy | NULL |
| 1554 | 80acf9ae-b047-41b8-bded-cdceb6de7051 | ROOT-446 | 446 | 2 | Ready | NULL |
+------+--------------------------------------+----------+-------------+---------+---------+---------+
Storage pool state
The stale volume references storage pool ID 4, which is already removed:
storage_pool_name: Export-Domain
storage_pool_removed: 2026-04-23 13:44:08
Actual result
Host maintenance fails with:
java.lang.NullPointerException: Cannot invoke
"org.apache.cloudstack.storage.datastore.db.StoragePoolVO.isLocal()"
because "storagePool" is null
Relevant stack trace:
at com.cloud.vm.UserVmManagerImpl.isAnyVmVolumeUsingLocalStorage(UserVmManagerImpl.java:7558)
at com.cloud.vm.UserVmManagerImpl.isVMUsingLocalStorage(UserVmManagerImpl.java:7121)
at com.cloud.resource.ResourceManagerImpl.doMaintain(ResourceManagerImpl.java:1553)
at com.cloud.resource.ResourceManagerImpl.maintain(ResourceManagerImpl.java:1653)
at org.apache.cloudstack.api.command.admin.host.PrepareForHostMaintenanceCmd.execute(PrepareForHostMaintenanceCmd.java:99)
Expected result
CloudStack should not throw an unhandled NullPointerException.
Possible expected behavior:
- ignore destroyed/removed stale volumes during maintenance evaluation
- skip volumes attached to removed pools
- or return a proper validation error identifying the problematic VM/volume
Workaround
Marking the stale destroyed volume row as removed allowed maintenance to proceed:
UPDATE volumes
SET removed = NOW()
WHERE id = 928
AND instance_id = 446
AND state = 'Destroy'
AND removed IS NULL
AND pool_id = 4;
Additional notes
The issue appears to be triggered specifically by:
- stale destroyed volume rows
- still linked to an active/running VM
- referencing removed storage pools
- while evaluating VM local-storage usage during host maintenance
versions
The versions ACS 4.22, KVM (should not be relevant)
The steps to reproduce the bug
...
What to do about it?
No response
- 主要语言
- Java
- 星标
- 3.1k
- 派生
- 1.4k
- 平均合并
- 6 天 20 小时
- 30 天内合并 PR
- 27
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/cloudstack 的其他 Issue
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
apache/cloudstack#14222 ·
-
bug component:kubernetes
难度 1/5 1 小时以内 新手友好度 88/100
apache/cloudstack#14180 ·
-
bug component:projects component:UI
难度 1/5 1 小时以内 新手友好度 88/100
apache/cloudstack#14070 · 5 条评论 ·
-
component:backup
难度 2/5 1-3 小时 新手友好度 76/100
apache/cloudstack#14013 ·
-
KVM agent fails to connect to Ceph RBD storage pool after upgrading Ceph client to Tentacle 20.2.4 未关闭bug component:ceph
难度 2/5 1-3 小时 新手友好度 78/100
apache/cloudstack#13989 · 3 条评论 ·
查看 apache/cloudstack 的全部 Issue
相似的 Issue
-
bug untriaged
难度 2/5 1-3 小时 新手友好度 84/100
opensearch-project/ml-commons#5094 ·
-
bug
难度 2/5 1-3 小时 新手友好度 85/100
-
emitter:client:csharp feature
难度 2/5 1-3 小时 新手友好度 72/100
-
affects/8.10 affects/8.9 component/clients kind/bug likelihood/mid severity/mid
难度 2/5 1-3 小时 新手友好度 78/100
-
bug frontend maui-pilot
难度 2/5 1-3 小时 新手友好度 72/100