You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "julien-vaz (via GitHub)" <gi...@apache.org> on 2025/02/27 18:28:44 UTC
[PR] Launch RESIZE event on volume snapshot revert [cloudstack]
julien-vaz opened a new pull request, #10482:
URL: https://github.com/apache/cloudstack/pull/10482
### Description
On volume snapshot revert, if its logical size was changed after the snapshot creation, its size is updated to the previous one, yet, no event is launched on the Usage server pointing to this change.
This behavior was modified, so that a RESIZE event is launched on the Usage server, if the volume's size has been changed after a snapshot revert.
### Types of changes
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] 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
- [x] Minor
### How Has This Been Tested?
1. A volume snapshot was created;
2. The resize operation was done;
3. The snapshot was reverted;
4. On the `usage_event` table the `VOLUME.RESIZE` event was launched with the previous size.
--
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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#issuecomment-2791958109
@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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#issuecomment-2703646857
@DaanHoogland 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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "JoaoJandre (via GitHub)" <gi...@apache.org>.
JoaoJandre commented on code in PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#discussion_r1979561857
##########
server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java:
##########
@@ -390,10 +390,19 @@ public Snapshot revertSnapshot(Long snapshotId) {
boolean result = snapshotStrategy.revertSnapshot(snapshotInfo);
if (result) {
+ Long differenceBetweenVolumeAndSnapshotSize = new Long(volume.getSize() - snapshot.getSize());
// update volume size and primary storage count
- _resourceLimitMgr.decrementResourceCount(snapshot.getAccountId(), ResourceType.primary_storage, new Long(volume.getSize() - snapshot.getSize()));
- volume.setSize(snapshot.getSize());
- _volsDao.update(volume.getId(), volume);
+ if (differenceBetweenVolumeAndSnapshotSize != 0) {
+ if (differenceBetweenVolumeAndSnapshotSize > 0) {
+ _resourceLimitMgr.decrementResourceCount(snapshot.getAccountId(), ResourceType.primary_storage, differenceBetweenVolumeAndSnapshotSize);
+ } else if (differenceBetweenVolumeAndSnapshotSize < 0) {
+ _resourceLimitMgr.incrementResourceCount(snapshot.getAccountId(), ResourceType.primary_storage, differenceBetweenVolumeAndSnapshotSize * -1L);
+ }
+ volume.setSize(snapshot.getSize());
+ _volsDao.update(volume.getId(), volume);
+ UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_RESIZE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(),
+ volume.getDiskOfferingId(), volume.getTemplateId(), volume.getSize(), Volume.class.getName(), volume.getUuid());
+ }
Review Comment:
+1 on creating a new method for it
--
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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "JoaoJandre (via GitHub)" <gi...@apache.org>.
JoaoJandre commented on PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#issuecomment-2790799016
@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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#issuecomment-2701530048
@julien-vaz 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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "julien-vaz (via GitHub)" <gi...@apache.org>.
julien-vaz commented on PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#issuecomment-2701525409
@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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#issuecomment-2701698397
Packaging result [SF]: ✔️ el8 ✔️ el9 ✖️ debian ✔️ suse15. SL-JID 12666
--
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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#issuecomment-2703645549
@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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#issuecomment-2690480894
## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/10482?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 4.00%. Comparing base [(`24b7c66`)](https://app.codecov.io/gh/apache/cloudstack/commit/24b7c66251998a7a8ce74bcc704ca551b8590a05?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`7b6edb1`)](https://app.codecov.io/gh/apache/cloudstack/commit/7b6edb1acc8430874b4665f30bb9b09f58db9585?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 14 commits behind head on main.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #10482 +/- ##
=========================================
- Coverage 4.00% 4.00% -0.01%
=========================================
Files 396 396
Lines 32530 32535 +5
Branches 5766 5767 +1
=========================================
Hits 1302 1302
- Misses 31078 31083 +5
Partials 150 150
```
| [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/10482/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/10482/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `4.00% <ø> (-0.01%)` | :arrow_down: |
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/10482?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).
--
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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on code in PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#discussion_r1979646781
##########
utils/src/test/java/com/cloud/utils/UriUtilsTest.java:
##########
@@ -276,8 +276,8 @@ public void testIsUrlForCompressedFile() {
@Test
public void validateUrl() {
- Pair<String, Integer> url1 = UriUtils.validateUrl("https://www.cloudstack.org");
- Assert.assertEquals(url1.first(), "www.cloudstack.org");
+ Pair<String, Integer> url1 = UriUtils.validateUrl("https://www.cloudstack.apache.org/");
+ Assert.assertEquals(url1.first(), "www.cloudstack.apache.org");
Review Comment:
to be completely realistic:
```suggestion
Pair<String, Integer> url1 = UriUtils.validateUrl("https://cloudstack.apache.org/");
Assert.assertEquals(url1.first(), "cloudstack.apache.org");
```
--
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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "julien-vaz (via GitHub)" <gi...@apache.org>.
julien-vaz commented on code in PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#discussion_r1981807410
##########
server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java:
##########
@@ -390,10 +390,19 @@ public Snapshot revertSnapshot(Long snapshotId) {
boolean result = snapshotStrategy.revertSnapshot(snapshotInfo);
if (result) {
+ Long differenceBetweenVolumeAndSnapshotSize = new Long(volume.getSize() - snapshot.getSize());
// update volume size and primary storage count
- _resourceLimitMgr.decrementResourceCount(snapshot.getAccountId(), ResourceType.primary_storage, new Long(volume.getSize() - snapshot.getSize()));
- volume.setSize(snapshot.getSize());
- _volsDao.update(volume.getId(), volume);
+ if (differenceBetweenVolumeAndSnapshotSize != 0) {
+ if (differenceBetweenVolumeAndSnapshotSize > 0) {
+ _resourceLimitMgr.decrementResourceCount(snapshot.getAccountId(), ResourceType.primary_storage, differenceBetweenVolumeAndSnapshotSize);
+ } else if (differenceBetweenVolumeAndSnapshotSize < 0) {
+ _resourceLimitMgr.incrementResourceCount(snapshot.getAccountId(), ResourceType.primary_storage, differenceBetweenVolumeAndSnapshotSize * -1L);
+ }
+ volume.setSize(snapshot.getSize());
+ _volsDao.update(volume.getId(), volume);
+ UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_RESIZE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(),
+ volume.getDiskOfferingId(), volume.getTemplateId(), volume.getSize(), Volume.class.getName(), volume.getUuid());
+ }
Review Comment:
Sure! I've just added it!
--
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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on code in PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#discussion_r1974885170
##########
server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java:
##########
@@ -390,10 +390,19 @@ public Snapshot revertSnapshot(Long snapshotId) {
boolean result = snapshotStrategy.revertSnapshot(snapshotInfo);
if (result) {
+ Long differenceBetweenVolumeAndSnapshotSize = new Long(volume.getSize() - snapshot.getSize());
// update volume size and primary storage count
- _resourceLimitMgr.decrementResourceCount(snapshot.getAccountId(), ResourceType.primary_storage, new Long(volume.getSize() - snapshot.getSize()));
- volume.setSize(snapshot.getSize());
- _volsDao.update(volume.getId(), volume);
+ if (differenceBetweenVolumeAndSnapshotSize != 0) {
+ if (differenceBetweenVolumeAndSnapshotSize > 0) {
+ _resourceLimitMgr.decrementResourceCount(snapshot.getAccountId(), ResourceType.primary_storage, differenceBetweenVolumeAndSnapshotSize);
+ } else if (differenceBetweenVolumeAndSnapshotSize < 0) {
+ _resourceLimitMgr.incrementResourceCount(snapshot.getAccountId(), ResourceType.primary_storage, differenceBetweenVolumeAndSnapshotSize * -1L);
+ }
+ volume.setSize(snapshot.getSize());
+ _volsDao.update(volume.getId(), volume);
+ UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_RESIZE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(),
+ volume.getDiskOfferingId(), volume.getTemplateId(), volume.getSize(), Volume.class.getName(), volume.getUuid());
+ }
Review Comment:
can this go in a new method @julien-vaz ?
--
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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#issuecomment-2790802331
@JoaoJandre 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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#issuecomment-2791959743
@DaanHoogland 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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#issuecomment-2790970439
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13000
--
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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland merged PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482
--
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] Launch RESIZE event on volume snapshot revert [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10482:
URL: https://github.com/apache/cloudstack/pull/10482#issuecomment-2703827850
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 12683
--
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