GitHub user ProjectMoon reopened a pull request:

    Fixes regarding VOLUME_DELETE events resulting from account deletion

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

You can merge this pull request into a Git repository by running:

    $ git pull 

Alternatively you can review and apply these changes as the patch at:

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1624
commit 24a194939b46488e38af6913f417d7e08ebf5eb3
Author: nnesic <>
Date:   2015-10-12T13:15:30Z

    Emit a VOLUME_DELETE usage event when account deletion destroys an instance.
    Currently the logic about volume deletion seems to be that an event
    should be emitted when the volume delete is requested, not when the
    deletion completes.
    The VolumeStateListener specifically ignores destroy events for ROOT
    volumes, assuming that the ROOT volume only gets deleted when the
    instance is destroyed and the UserVmManager should take care of it.
    When deleting an account, all of its resources get destroyed, but the
    instance expunging circumvents the UserVmManager, and thus we miss the
    VOLUME_DESTROY usage event.  Added a check in the AccountManager to
    emit the deletion event for ROOT volumes belonging to instances which
    weren't destroyed prior to the account deletion.

commit 609c3bb17be96c68cd3652fb1e8439e1907a8176
Author: nnesic <>
Date:   2016-09-13T10:01:50Z

    Instead of emitting volume delete events directly, account manager
    now attempts to propperly destroy the vm before expunging it. This
    way the destroy logic is respected, including the event emission.
    Unit tests have been modified accordingly.


If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

Reply via email to