| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
revertSnapshot looked up the snapshot's volume with findById(), which does not return removed volumes, and used it without a null check. Any snapshot of a deleted volume therefore failed with an NPE on VolumeVO.getState(). It now fails with an error saying the volume no longer exists. The same pattern elsewhere: - copySnapshot without sourcezoneid took the source zone from the volume, found the same way. For a deleted volume it now falls back to the snapshot's own zone, which is the zone it was taken in. - createVolume and createTemplate from a snapshot look the volume up including removed rows, but still failed with an NPE when the row itself is missing. They now refuse with a clear error. Fixes apache#14644 Signed-off-by: Brad House <bhouse@nexthop.ai>
Codecov Report❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review. @@ Coverage Diff @@
## 4.22 #14646 +/- ##
==========================================
Coverage 18.32% 18.33%
- Complexity 16644 16655 +11
==========================================
Files 5939 5939
Lines 537768 537934 +166
Branches 65929 65998 +69
==========================================
+ Hits 98551 98615 +64
- Misses 428008 428093 +85
- Partials 11209 11226 +17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness.
|
Sorry, something went wrong.
Test report: snapshot operations when the snapshot's volume is goneSummary: for a snapshot whose volume was deleted, revertSnapshot is refused with a clear error, and createVolume and createTemplate from it work. When the volume row itself is missing, as in #14599, all three are refused with clear errors and nothing is left behind. No NPE was logged on any of these paths. Environment
Case 1: the volume was deleted (deleteVolume; the row stays, Expunged, with removed set)
Before this PR, revertSnapshot here failed with Cannot invoke "com.cloud.storage.VolumeVO.getState()" because "volume" is null. I saw that while testing #14600. Case 2: the volume row is missing (as in #14599)
After the refusals there was no template record and no volume left with the requested names. The template refusal happens before a template record is written, as the PR says.
Result: pass. Side note, not from this PR: taking a snapshot of a detached volume on the zone-wide RBD pool logged a caught NPE at DEBUG: post process snapshot failed java.lang.NullPointerException: Cannot invoke "java.lang.Long.longValue()" because "clusterId" is null at SnapshotManagerImpl.postCreateSnapshot. That is the kvmIncrementalSnapshot.valueIn(clusterId) / endLastChainIfNeeded(clusterId, ...) branch. The snapshot itself was BackedUp. This code is unchanged by the PR. Not covered
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Description
revertSnapshot failed with Cannot invoke "com.cloud.storage.VolumeVO.getState()" because "volume" is null for any snapshot whose volume has been deleted. A few other snapshot APIs had the same missing null check.
Fixes #14644
Changes
This complements #14600, which stops listSnapshots from failing on the same kind of snapshot. Neither PR depends on the other.
Not changed here
Deploying a VM from a snapshot whose volume row is missing still fails, in VolumeOrchestrator.allocateTemplatedVolume, which reads the size from the volume. UserVmManagerImpl accepts that case when a template id is given, so the right fix there is to make the deploy work, not to refuse it. That needs a live test, so I've left it for a separate change.
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
The revertSnapshot NPE was seen on a KVM + Ceph RBD lab while testing #14600. This fix has not yet been run there; it is covered by unit tests.
New tests:
Without the fix, the first three fail with the NPEs from the issue. The fourth fails further on, because the record path went past the missing volume.
Updated tests:
SnapshotManagerTest, SnapshotManagerImplTest, TemplateManagerImplTest and VolumeApiServiceImplTest all pass (259 tests). Checkstyle is clean for server.
How did you try to break this feature and the system with this change?