revertSnapshot fails with an NPE when the snapshot's volume has been deleted
維護者通常 1 天內回覆
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 55/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- java
研究方向
Start by reading SnapshotManagerImpl.revertSnapshot and the snapshot copy path that chooses a source zone; the issue identifies findById() as the lookup that returns null for removed volumes. Then inspect VolumeApiServiceImpl.allocVolume and TemplateManagerImpl.createPrivateTemplate for snapshot based creation when the volume row is missing. Add clear errors for the missing volume cases and use the snapshot's recorded zone for copy; done when all four API paths handle these cases without an NPE.
由索引模型根據 Issue 內容生成。
描述
problem
revertSnapshot fails with a NullPointerException when the snapshot's volume has been deleted:
Cannot invoke "com.cloud.storage.VolumeVO.getState()" because "volume" is null
at com.cloud.storage.snapshot.SnapshotManagerImpl.revertSnapshot
SnapshotManagerImpl.revertSnapshot looks the volume up with findById(), which does not return removed volumes, and uses the result without a null check. Volume snapshots outlive their volume, so any snapshot of a deleted volume hits this. The caller gets an internal error instead of being told why the snapshot cannot be reverted.
A few other snapshot APIs have the same gap:
copySnapshotwithoutsourcezoneidtakes the source zone from the volume, also looked up withfindById(). For a snapshot of a deleted volume it fails withCannot invoke "com.cloud.storage.Volume.getDataCenterId()" because "volume" is null. The copy itself does not need the volume, and the same copy works whensourcezoneidis passed.createVolumefrom a snapshot andcreateTemplatefrom a snapshot look the volume up including removed rows, so a deleted volume is fine. They still NPE when the volume row itself is gone (parentVolume.getPassphraseId()inVolumeApiServiceImpl.allocVolume; forcreateTemplate, the template record is created and the job then fails inTemplateManagerImpl.createPrivateTemplate). A missing row is the case in #14599.
versions
4.22, and main.
The steps to reproduce the bug
- Create a data volume, attach it to a VM, and take a volume snapshot of it.
- Detach and delete the volume. The snapshot remains.
- Call
revertSnapshot id=<snapshot>. It fails with the NPE above. - Call
copySnapshot id=<snapshot> destzoneids=<another zone>withoutsourcezoneid. It fails with thegetDataCenterId()NPE.
For createVolume snapshotid= and createTemplate snapshotid=, the volume row has to be missing from the volumes table.
What to do about it?
revertSnapshot: refuse with a clear error when the snapshot's volume no longer exists.copySnapshot: when the volume is gone, take the source zone from the snapshot, which records the zone it was taken in.createVolumeandcreateTemplatefrom a snapshot: refuse with a clear error when the volume row is missing, instead of failing with an NPE.
- 主要語言
- Java
- 星號
- 3.1k
- 分支
- 1.4k
- 平均合併
- 7 天 16 小時
- 30 天內合併 PR
- 15
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
apache/cloudstack 的其他 Issue
-
resizeVolume of a running system VM's volume is accepted but the VM never sees the new size可能已有人在做 @bhouse-nexthop 於 3 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
apache/cloudstack#14645 · 1 則留言 ·
維護者通常 1 天內回覆
-
VR reports a load balancer change as applied when haproxy.cfg cannot be replaced可能已有人在做 @bhouse-nexthop 於 3 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
apache/cloudstack#14633 · 1 則留言 ·
維護者通常 1 天內回覆
-
restartNetwork reports a ResourceUnavailableException as an unexpected error (530), unlike restartVPC (534)可能已有人在做 @bhouse-nexthop 於 3 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
apache/cloudstack#14631 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
apache/cloudstack#14625 · 1 則留言 ·
維護者通常 1 天內回覆
-
Remote access VPN users are disconnected on every LB, ACL, port forward or firewall change (xl2tpd restarted on every iptables pass)可能已有人在做 @willbennett-devops 於 12 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
apache/cloudstack#14545 · 1 則留言 ·
維護者通常 1 天內回覆
查看 apache/cloudstack 的全部 Issue
相似的 Issue
-
[Bug]: Nullable implicit operator on string extensible enums still throws for a null string可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉bug emitter:client:csharp
難度 2/5 1-3 小時 新手友好度 84/100
microsoft/typespec#12572 · 1 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
[BUG]: Java SDK MountRequest always sends update-optional fields, resetting stored mount settings未關閉bug
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)未關閉
難度 2/5 1-3 小時 新手友好度 73/100
維護者通常 1 天內回覆
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configuration可能已有人在做 @amalsaidov 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
needs-area-label
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 2 天內回覆