You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "Yuliia7-1 (via GitHub)" <gi...@apache.org> on 2026/07/07 10:04:21 UTC

[I] Volume resize usage event may record incorrect size in cloud_usage [cloudstack]

Yuliia7-1 opened a new issue, #13555:
URL: https://github.com/apache/cloudstack/issues/13555

   ### problem
   
   When a volume is resized, CloudStack publishes a EVENT_VOLUME_RESIZE usage event that is later used for billing calculations and stored in cloud_usage.
   
   In VolumeApiServiceImpl.orchestrateResizeVolume(), the volume size is updated before the usage event is published:
   
   ```
   if (currentSize == volume.getSize() && currentSize != newSize) {
       volume.setSize(newSize);
   } else if (volume.getSize() != newSize) {
       newSize = volume.getSize();
   }
   
   _volsDao.update(volume.getId(), volume);
   ```
   
   The usage event is then published using:
   ```
   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()
   );
   ```
   **Observed Behaviour**
   
   The resize event uses `volume.getSize()` instead of the final resize target value (newSize).
   
   In environments where billing is calculated from cloud_usage, we have observed discrepancies between:
   the current volume size reported by CloudStack APIs/UI, and the size stored in cloud_usage following resize operations.
   
   As a result, billing records may not accurately reflect the expected volume size history after one or more resize operations.
   
   ### versions
   
   4.19.1
   
   ### The steps to reproduce the bug
   
   1.
   2.
   3.
   ...
   
   
   ### What to do about it?
   
   The resize usage event should be published using the actual final resized value (newSize) that was determined during the resize workflow.
   
   For example:
   
   ```
   UsageEventUtils.publishUsageEvent(
       EventTypes.EVENT_VOLUME_RESIZE,
       volume.getAccountId(),
       volume.getDataCenterId(),
       volume.getId(),
       volume.getName(),
       volume.getDiskOfferingId(),
       volume.getTemplateId(),
       newSize,
       Volume.class.getName(),
       volume.getUuid()
   );
   ```
   
   This would ensure that usage records and billing calculations are based on the intended resize value.
   
   Affected Code: `server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java`
   
   Method: `orchestrateResizeVolume(...)`


-- 
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.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Volume resize usage event may record incorrect size in cloud_usage [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on issue #13555:
URL: https://github.com/apache/cloudstack/issues/13555#issuecomment-4960830069

   @sureshanaparti , can you have a look?


-- 
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: [I] Volume resize usage event may record incorrect size in cloud_usage [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on issue #13555:
URL: https://github.com/apache/cloudstack/issues/13555#issuecomment-4960822922

   sounds like a bug to me
   
   > the volume size is updated before the usage event is published:
   > 
   > ```
   > 
   > ```
   
   this description would indicate it works as expected, but I think the update is not happening before the event publishing.


-- 
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: [I] Volume resize usage event may record incorrect size in cloud_usage [cloudstack]

Posted by "nvazquez (via GitHub)" <gi...@apache.org>.
nvazquez commented on issue #13555:
URL: https://github.com/apache/cloudstack/issues/13555#issuecomment-4982970051

   Hi @Yuliia7-1 @DaanHoogland it seems like this fix could solve this issue? https://github.com/apache/cloudstack/pull/9459 (already present on 4.19.2)


-- 
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: [I] Volume resize usage event may record incorrect size in cloud_usage [cloudstack]

Posted by "Yuliia7-1 (via GitHub)" <gi...@apache.org>.
Yuliia7-1 closed issue #13555: Volume resize usage event may record incorrect size in cloud_usage
URL: https://github.com/apache/cloudstack/issues/13555


-- 
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: [I] Volume resize usage event may record incorrect size in cloud_usage [cloudstack]

Posted by "Yuliia7-1 (via GitHub)" <gi...@apache.org>.
Yuliia7-1 commented on issue #13555:
URL: https://github.com/apache/cloudstack/issues/13555#issuecomment-4989802741

   Yes, it does seem like this could be exactly what I need. Thank you for the update.


-- 
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: [I] Volume resize usage event may record incorrect size in cloud_usage [cloudstack]

Posted by "Yuliia7-1 (via GitHub)" <gi...@apache.org>.
Yuliia7-1 commented on issue #13555:
URL: https://github.com/apache/cloudstack/issues/13555#issuecomment-4902616702

   Hi @DaanHoogland 
   Would you mind taking a look at this issue when you have a chance and sharing your thoughts? This is a high-priority issue for us, so we'd appreciate any feedback you may have.
   
   Many thanks.


-- 
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