You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "abh1sar (via GitHub)" <gi...@apache.org> on 2026/03/25 04:22:20 UTC
[PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
abh1sar opened a new pull request, #12885:
URL: https://github.com/apache/cloudstack/pull/12885
### Description
This PR fixes a regression in Revert VM to Snapshot with Dynamic/Custom service offering.
<!--- Describe your changes in DETAIL - And how has behaviour functionally changed. -->
<!-- For new features, provide link to FS, dev ML discussion etc. -->
<!-- In case of bug fix, the expected and actual behaviours, steps to reproduce. -->
<!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be closed when this PR gets merged -->
<!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
<!-- Fixes: # -->
<!--- ******************************************************************************* -->
<!--- NOTE: AUTOMATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE DOCUMENTATION. -->
<!--- PLEASE PUT AN 'X' in only **ONE** box -->
<!--- ******************************************************************************* -->
### Types of changes
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] New feature (non-breaking change which adds functionality)
- [x] 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
- [x] BLOCKER
- [ ] Critical
- [ ] Major
- [ ] Minor
- [ ] Trivial
### Screenshots (if appropriate):
### How Has This Been Tested?
1. Create an Instance with Custom service offering
2. Take a VM snapshot
3. Revert the snapshot
Before fix :
```
2026-03-24 10:26:04,056 ERROR [c.c.a.ApiAsyncJobDispatcher] (API-Job-Executor-5:[ctx-a2bbedfa, job-76]) (logid:5c30faaa) Unexpected exception while executing org.apache.cloudstack.api.command.admin.vmsnapshot.RevertToVMSnapshotCmdByAdmin com.cloud.utils.exception.CloudRuntimeException: While the VM is running, only scalling up it is supported. New service offering {"memory": 512, "speed": 500, "cpu": 1} should have at least one value (ram, speed or cpu) greater than the current values {"memory": 512, "speed": 500, "cpu": 1}.
at com.cloud.vm.snapshot.VMSnapshotManagerImpl.orchestrateRevertToVMSnapshot(VMSnapshotManagerImpl.java:954)
```
After fix:
Revert was successful.
<!-- Please describe in detail how you tested your changes. -->
<!-- Include details of your testing environment, and the tests you ran to -->
#### How did you try to break this feature and the system with this change?
<!-- see how your change affects other areas of the code, etc. -->
<!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) document -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "abh1sar (via GitHub)" <gi...@apache.org>.
abh1sar commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4123400360
@blueorangutan package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "abh1sar (via GitHub)" <gi...@apache.org>.
abh1sar commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4123224805
@blueorangutan package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4132157034
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17247
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4123413130
@abh1sar 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "abh1sar (via GitHub)" <gi...@apache.org>.
abh1sar commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4131169572
@blueorangutan test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4127801938
@abh1sar a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4131911150
@abh1sar 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4141869434
<b>[SF] Trillian test result (tid-15747)</b>
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 64223 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12885-t15747-kvm-ol8.zip
Smoke tests completed. 138 look OK, 3 have errors, 0 did not run
Only failed and skipped tests results shown below:
Test | Result | Time (s) | Test File
--- | --- | --- | ---
test_08_upgrade_kubernetes_ha_cluster | `Failure` | 3687.89 | test_kubernetes_clusters.py
test_01_deployVMInSharedNetwork | `Failure` | 282.62 | test_network.py
test_02_list_cpvm_vm | `Failure` | 0.04 | test_ssvm.py
test_04_cpvm_internals | `Failure` | 0.06 | test_ssvm.py
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4131383745
<b>[SF] Trillian Build Failed (tid-15743)<b/>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "abh1sar (via GitHub)" <gi...@apache.org>.
abh1sar closed pull request #12885: Fix Revert Instance to Snapshot with custom service offering
URL: https://github.com/apache/cloudstack/pull/12885
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "abh1sar (via GitHub)" <gi...@apache.org>.
abh1sar commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4136428757
@blueorangutan test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "abh1sar (via GitHub)" <gi...@apache.org>.
abh1sar merged PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4131177502
@abh1sar a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4136436127
@abh1sar a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4123355635
## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/12885?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 4.15%. Comparing base ([`c19630f`](https://app.codecov.io/gh/apache/cloudstack/commit/c19630f0a4f34a82a9414b9b6d16b5ec44b86860?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`fcd2160`](https://app.codecov.io/gh/apache/cloudstack/commit/fcd2160df2f0b2eb1d346e9e53a82681527a35c8?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
> :exclamation: There is a different number of reports uploaded between BASE (c19630f) and HEAD (fcd2160). Click for more details.
>
> <details><summary>HEAD has 1 upload less than BASE</summary>
>
>| Flag | BASE (c19630f) | HEAD (fcd2160) |
>|------|------|------|
>|unittests|1|0|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## 4.20 #12885 +/- ##
=============================================
- Coverage 16.25% 4.15% -12.10%
=============================================
Files 5664 404 -5260
Lines 500465 32966 -467499
Branches 60780 5893 -54887
=============================================
- Hits 81338 1370 -79968
+ Misses 410031 31420 -378611
+ Partials 9096 176 -8920
```
| [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/12885/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/12885/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `4.15% <ø> (ø)` | |
| [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/12885/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/cloudstack/pull/12885?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#discussion_r2985654179
##########
server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java:
##########
@@ -754,11 +754,17 @@ public UserVm revertToSnapshot(Long vmSnapshotId) throws InsufficientCapacityExc
"Instance Snapshot reverting failed because the Instance is not in Running or Stopped state.");
}
- if (userVm.getState() == VirtualMachine.State.Running && vmSnapshotVo.getType() == VMSnapshot.Type.Disk || userVm.getState() == VirtualMachine.State.Stopped
- && vmSnapshotVo.getType() == VMSnapshot.Type.DiskAndMemory) {
+ if (userVm.getState() == VirtualMachine.State.Running && vmSnapshotVo.getType() == VMSnapshot.Type.Disk) {
throw new InvalidParameterValueException(
- "Reverting to the Instance Snapshot is not allowed for running Instances as this would result in a Instance state change. For running Instances only Snapshots with memory can be reverted. In order to revert to a Snapshot without memory you need to first stop the Instance."
- + " Snapshot");
+ "Reverting to the Instance Snapshot is not allowed for running Instances as this would result in a Instance state change." +
+ "For running Instances only Snapshots with memory can be reverted." +
+ "In order to revert to a Snapshot without memory you need to first stop the Instance.");
Review Comment:
The concatenated error message is missing spaces between sentences (e.g., "change.For running…"), and it also uses incorrect grammar ("a Instance" -> "an Instance"). This reduces readability for API users; please add proper spacing/punctuation (or use a formatted string) so the message renders as intended.
```suggestion
"Reverting to the Instance Snapshot is not allowed for running Instances as this would result in an Instance state change." +
" For running Instances only Snapshots with memory can be reverted." +
" In order to revert to a Snapshot without memory you need to first stop the Instance.");
```
##########
server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java:
##########
@@ -811,20 +817,36 @@ else if (jobResult instanceof Throwable)
}
/**
- * If snapshot was taken with a different service offering than actual used in vm, should change it back to it.
- * We also call <code>changeUserVmServiceOffering</code> in case the service offering is dynamic in order to
- * perform resource limit validation, as the amount of CPUs or memory may have been changed.
- * @param vmSnapshotVo vm snapshot
+ * Check if service offering change is needed for user vm when reverting to vm snapshot.
+ * Service offering change is needed when snapshot was taken with a different service offering than actual used in vm.
+ * Service offering change is also needed when service offering is dynamic and the amount of cpu, memory or cpu speed
+ * has been changed since snapshot was taken.
+ * @param userVm
+ * @param vmSnapshotVo
+ * @return true if service offering change is needed; false otherwise
*/
- protected void updateUserVmServiceOffering(UserVm userVm, VMSnapshotVO vmSnapshotVo) {
+ private boolean userVmServiceOfferingNeedsChange(UserVm userVm, VMSnapshotVO vmSnapshotVo) {
if (vmSnapshotVo.getServiceOfferingId() != userVm.getServiceOfferingId()) {
- changeUserVmServiceOffering(userVm, vmSnapshotVo);
- return;
+ return true;
}
- ServiceOfferingVO serviceOffering = _serviceOfferingDao.findById(userVm.getServiceOfferingId());
- if (serviceOffering.isDynamic()) {
- changeUserVmServiceOffering(userVm, vmSnapshotVo);
+
+ ServiceOfferingVO currentServiceOffering = _serviceOfferingDao.findByIdIncludingRemoved(userVm.getId(), userVm.getServiceOfferingId());
+ if (currentServiceOffering.isDynamic()) {
+ Map<String, String> vmDetails = getVmMapDetails(vmSnapshotVo);
+ ServiceOfferingVO newServiceOffering = _serviceOfferingDao.getComputeOffering(currentServiceOffering, vmDetails);
+
+ int newCpu = newServiceOffering.getCpu();
+ int newMemory = newServiceOffering.getRamSize();
+ int newSpeed = newServiceOffering.getSpeed();
+ int currentCpu = currentServiceOffering.getCpu();
+ int currentMemory = currentServiceOffering.getRamSize();
+ int currentSpeed = currentServiceOffering.getSpeed();
+
+ if (newCpu != currentCpu || newMemory != currentMemory || newSpeed != currentSpeed) {
+ return true;
Review Comment:
`ServiceOfferingVO#getCpu()`, `getRamSize()`, and `getSpeed()` return boxed `Integer`s. In a dynamic offering, `getComputeOffering(...)` can legitimately leave some of these values null when the corresponding custom parameter is absent, and unboxing them into `int` here will throw a NullPointerException during revert. Please avoid primitive unboxing and compare using `Objects.equals(...)` (or explicit null-safe handling) for cpu/ram/speed.
##########
server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java:
##########
@@ -754,11 +754,17 @@ public UserVm revertToSnapshot(Long vmSnapshotId) throws InsufficientCapacityExc
"Instance Snapshot reverting failed because the Instance is not in Running or Stopped state.");
}
- if (userVm.getState() == VirtualMachine.State.Running && vmSnapshotVo.getType() == VMSnapshot.Type.Disk || userVm.getState() == VirtualMachine.State.Stopped
- && vmSnapshotVo.getType() == VMSnapshot.Type.DiskAndMemory) {
+ if (userVm.getState() == VirtualMachine.State.Running && vmSnapshotVo.getType() == VMSnapshot.Type.Disk) {
throw new InvalidParameterValueException(
- "Reverting to the Instance Snapshot is not allowed for running Instances as this would result in a Instance state change. For running Instances only Snapshots with memory can be reverted. In order to revert to a Snapshot without memory you need to first stop the Instance."
- + " Snapshot");
+ "Reverting to the Instance Snapshot is not allowed for running Instances as this would result in a Instance state change." +
+ "For running Instances only Snapshots with memory can be reverted." +
+ "In order to revert to a Snapshot without memory you need to first stop the Instance.");
+ }
+
+ if ( userVm.getState() == VirtualMachine.State.Stopped && vmSnapshotVo.getType() == VMSnapshot.Type.DiskAndMemory) {
+ throw new InvalidParameterValueException(
+ "Reverting to the Instance Snapshot is not allowed for stopped Instances if the Snapshot contains memory." +
Review Comment:
The stopped-instance revert error message is also missing a space between sentences ("memory.In order…"). Please ensure there is whitespace/punctuation between concatenated literals so the message is human-readable.
```suggestion
"Reverting to the Instance Snapshot is not allowed for running Instances as this would result in a Instance state change. " +
"For running Instances only Snapshots with memory can be reverted. " +
"In order to revert to a Snapshot without memory you need to first stop the Instance.");
}
if ( userVm.getState() == VirtualMachine.State.Stopped && vmSnapshotVo.getType() == VMSnapshot.Type.DiskAndMemory) {
throw new InvalidParameterValueException(
"Reverting to the Instance Snapshot is not allowed for stopped Instances if the Snapshot contains memory. " +
```
##########
server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java:
##########
@@ -811,20 +817,36 @@ else if (jobResult instanceof Throwable)
}
/**
- * If snapshot was taken with a different service offering than actual used in vm, should change it back to it.
- * We also call <code>changeUserVmServiceOffering</code> in case the service offering is dynamic in order to
- * perform resource limit validation, as the amount of CPUs or memory may have been changed.
- * @param vmSnapshotVo vm snapshot
+ * Check if service offering change is needed for user vm when reverting to vm snapshot.
+ * Service offering change is needed when snapshot was taken with a different service offering than actual used in vm.
+ * Service offering change is also needed when service offering is dynamic and the amount of cpu, memory or cpu speed
+ * has been changed since snapshot was taken.
+ * @param userVm
+ * @param vmSnapshotVo
+ * @return true if service offering change is needed; false otherwise
*/
Review Comment:
This change removes/renames the previously `protected` `updateUserVmServiceOffering(...)` method and makes the new helper `private`. There is an existing unit test (`server/src/test/java/com/cloud/vm/snapshot/VMSnapshotManagerTest.java`) that directly calls `updateUserVmServiceOffering`, so the test suite will no longer compile. Either update the tests to the new behavior (preferred), or keep a `protected` wrapper method for backward compatibility in tests/possible subclasses.
```suggestion
*/
protected boolean updateUserVmServiceOffering(UserVm userVm, VMSnapshotVO vmSnapshotVo) {
return userVmServiceOfferingNeedsChange(userVm, vmSnapshotVo);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4128182785
<b>[SF] Trillian Build Failed (tid-15737)<b/>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "abh1sar (via GitHub)" <gi...@apache.org>.
abh1sar commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4127795311
@blueorangutan test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4123853434
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17238
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "winterhazel (via GitHub)" <gi...@apache.org>.
winterhazel commented on code in PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#discussion_r2992107434
##########
server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java:
##########
@@ -754,11 +754,17 @@ public UserVm revertToSnapshot(Long vmSnapshotId) throws InsufficientCapacityExc
"Instance Snapshot reverting failed because the Instance is not in Running or Stopped state.");
}
- if (userVm.getState() == VirtualMachine.State.Running && vmSnapshotVo.getType() == VMSnapshot.Type.Disk || userVm.getState() == VirtualMachine.State.Stopped
- && vmSnapshotVo.getType() == VMSnapshot.Type.DiskAndMemory) {
+ if (userVm.getState() == VirtualMachine.State.Running && vmSnapshotVo.getType() == VMSnapshot.Type.Disk) {
throw new InvalidParameterValueException(
- "Reverting to the Instance Snapshot is not allowed for running Instances as this would result in a Instance state change. For running Instances only Snapshots with memory can be reverted. In order to revert to a Snapshot without memory you need to first stop the Instance."
- + " Snapshot");
+ "Reverting to the Instance Snapshot is not allowed for running Instances as this would result in an Instance state change. " +
+ "For running Instances only Snapshots with memory can be reverted. " +
+ "In order to revert to a Snapshot without memory you need to first stop the Instance.");
+ }
+
+ if ( userVm.getState() == VirtualMachine.State.Stopped && vmSnapshotVo.getType() == VMSnapshot.Type.DiskAndMemory) {
+ throw new InvalidParameterValueException(
+ "Reverting to the Instance Snapshot is not allowed for stopped Instances if the Snapshot contains memory. " +
+ "In order to revert to a Snapshot with memory you need to first start the Instance.");
Review Comment:
```suggestion
if (userVm.getState() == VirtualMachine.State.Stopped && vmSnapshotVo.getType() == VMSnapshot.Type.DiskAndMemory) {
throw new InvalidParameterValueException(
"Reverting to the Instance Snapshot is not allowed for stopped Instances when the Snapshot contains memory as this would result in an Instance state change. " +
"In order to revert to a Snapshot with memory you need to first start the Instance.");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Revert Instance to Snapshot with custom service offering [cloudstack]
Posted by "abh1sar (via GitHub)" <gi...@apache.org>.
abh1sar commented on PR #12885:
URL: https://github.com/apache/cloudstack/pull/12885#issuecomment-4131908329
@blueorangutan package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org