SURYAS1306 opened a new pull request, #12606:
URL: https://github.com/apache/cloudstack/pull/12606
### Description
Repeated `VM.START` events for the same VM could result in duplicate
`RUNNING_VM` helper usage records being created in the usage database.
This PR adds a defensive check in `UsageManagerImpl#createVMHelperEvent`
to detect an existing active `RUNNING_VM` usage record (same VM instance,
`endDate = NULL`) and skip helper record creation when a duplicate START
event is received.
A regression test has been added to ensure that duplicate `RUNNING_VM`
helper records are not created when repeated `VM.START` events are
processed.
### Expected behavior
Only one active `RUNNING_VM` usage helper record should exist per VM at
any given time.
### Actual behavior
Multiple `RUNNING_VM` helper records could be created for the same VM
when duplicate `VM.START` events were processed.
### Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [x] Test (unit or integration test code)
### Bug Severity
- [x] Minor
### How Has This Been Tested?
- Added a unit test in `UsageManagerImplTest` to verify that duplicate
`RUNNING_VM` helper records are not created when repeated `VM.START`
events are handled.
- Built and tested the `cloud-usage` module successfully using Maven.
#### How did you try to break this feature and the system with this change?
- Simulated repeated `VM.START` events for the same VM instance to ensure
that helper record creation is skipped when an active `RUNNING_VM`
record already exists.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]