revertSnapshot fails with an NPE when the snapshot's volume has been deleted

オープン
#14,644 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@bhouse-nexthop がすでに取り組んでいます。

2026年11月9日 から。

  • #14646 @bhouse-nexthop による — オープン

評価

難易度
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:

  • copySnapshot without sourcezoneid takes the source zone from the volume, also looked up with findById(). For a snapshot of a deleted volume it fails with Cannot invoke "com.cloud.storage.Volume.getDataCenterId()" because "volume" is null. The copy itself does not need the volume, and the same copy works when sourcezoneid is passed.
  • createVolume from a snapshot and createTemplate from 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() in VolumeApiServiceImpl.allocVolume; for createTemplate, the template record is created and the job then fails in TemplateManagerImpl.createPrivateTemplate). A missing row is the case in #14599.
versions

4.22, and main.

The steps to reproduce the bug
  1. Create a data volume, attach it to a VM, and take a volume snapshot of it.
  2. Detach and delete the volume. The snapshot remains.
  3. Call revertSnapshot id=<snapshot>. It fails with the NPE above.
  4. Call copySnapshot id=<snapshot> destzoneids=<another zone> without sourcezoneid. It fails with the getDataCenterId() 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.
  • createVolume and createTemplate from 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時間
マージ済み PR(30日)
15

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/cloudstack のほかの issue

apache/cloudstack の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。