Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When scaling a VM, the new details of the compute resources (memory, CPU speed, and CPU cores) are updated in the database after generating the usage event. This way, the usage events are generated with outdated details. Usage uses those events while generating entries in
cloud_usage.usage_vm_instance
andcloud_usage.cloud_usage
, however, as in the scaling the details are updated after generating the events, the entries for the VM incloud_usage.usage_vm_instance
are always outdated after the scaling, as well the entries incloud_usage.cloud_usage
. In order to make Usage generate the proper entries, operators must stop and start the VM again (generating events of stop and start with the current VM compute resources' state).This PR intends to fix this behavior by updating the details before generating the usage event, making the events synchronized with the current VM compute resources' state.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
I set the
usage.stats.job.aggregation.range
setting to 1 minute to speed up the testing process, then I created a new VM with a constrained offering, and started scaling it.Before this change, the entries in
cloud_usage.usage_vm_instance
andcloud_usage.cloud_usage
would contain the memory, CPU speed, and CPU cores of the VM from before the last scaling, e.g., after the first scaling, the entries would have the original details, after the second scaling, the entries would have the details from the first scaling, and so on.After this change, when dynamic scaling a VM, the events and entries in
cloud_usage.usage_vm_instance
andcloud_usage.cloud_usage
are generated properly.