Merge pull request #1624 from greenqloud/pr-volume-usage-events-fixes-4.8

Fixes regarding VOLUME_DELETE events resulting from account deletionNew version 
of #1491.

**Original Description**
New version of #1373, but updated for the 4.7 branch with another fix that 
allows it to properly find expunged root volumes. This is a bug fix, which is 
why we target the 4.7 branch.

Original pull request:
Fixes regarding usage event emission.

UsageEventUtils was previously not checking deleted accounts, which meant that 
if an account was deleted that had some resources running on it, those 
resources would get destroyed without emitting any events.

Furthermore, the VOLUME_DELETE event of ROOT volumes is the responsibility of 
the UserVmManager, which gets circumvented when expunging resources following 
the account deletion. Added a check to the AccountManager which catches the 
ROOT volumes that need to be deleted and emits events for them.

To test this: Create a new user. As that user, create and destroy an instance. 
This should cause the VM_CREATE, VM_START, VM_STOP, VM_DESTROY, VOLUME_CREATE, 
and VOLUME_DELETE events to be emitted.
Create a new instance as the same user. Log in as admin, and delete the user. 
The same set of events should be emitted, and there should be no duplicate 
DELETE events for the ROOT volume of the previous instance.

* pr/1624:
  Emit a VOLUME_DELETE usage event when account deletion destroys an instance.

Signed-off-by: Rajani Karuturi <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/fae90341
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/fae90341
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/fae90341

Branch: refs/heads/4.8
Commit: fae90341beb51fd0daa1814ec2f8700c0894e551
Parents: a664e03 d989c5d
Author: Rajani Karuturi <[email protected]>
Authored: Sat Oct 22 19:42:20 2016 +0530
Committer: Rajani Karuturi <[email protected]>
Committed: Sat Oct 22 19:42:20 2016 +0530

----------------------------------------------------------------------
 .../src/com/cloud/user/AccountManagerImpl.java  |  12 +-
 .../com/cloud/user/AccountManagerImplTest.java  | 220 ++-----------
 ...AccountManagerImplVolumeDeleteEventTest.java | 209 +++++++++++++
 .../cloud/user/AccountManagetImplTestBase.java  | 242 +++++++++++++++
 .../test/com/cloud/user/MockUsageEventDao.java  | 307 +++++++++++++++++++
 5 files changed, 787 insertions(+), 203 deletions(-)
----------------------------------------------------------------------


Reply via email to