Skip to content

Conversation

@ProjectMoon
Copy link

New version of #924, but on the right branch with the commits squashed.

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.

@ProjectMoon
Copy link
Author

Added the license header to the MockUsageEventDao class to fix rat report error.

@rafaelweingartner
Copy link
Member

Hi @ProjectMoon ,
Out of curiosity, why did you create the "server/test/com/cloud/user/MockUsageEventDao.java" class?

@ProjectMoon
Copy link
Author

I'm not the original author of this work, but I think it was just because a class for testing was needed. Looking at it now I'm not really sure why it can't just be the regular UsageEventDao with @Mock. I will try to find out the intention behind it, and then remove the class if it's not needed.

Edit: reason I got back is that she was following the pattern of other tests (AccountManager tests specifically).

@ProjectMoon
Copy link
Author

@rafaelweingartner I have removed the MockUsageEventDao and replaced it with a normal Mockito mock of the UsageEventDao interface.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think you need this kind of comment.

@rafaelweingartner
Copy link
Member

@ProjectMoon that is great,
Your code is ok,
I would just suggest you extracting the code from "AccountManagerImpl" lines 769-778 to a method. Then you would be able to add proper java documentation and test cases.

The logic about volume deletion was 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.

This was causing problems when deleting accounts which had running
resources. The resources are stopped and destroyed, but we never get a
usage event indicating so. 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.

This commits adds 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. It also adds the volume status to the
event emitted on the event bus, for distinguishing between pre- and
post- state transitions.
@ProjectMoon
Copy link
Author

I added the suggested changes. Also, now that #1382 has been merged to 4.6, the checks should succeed.

@rafaelweingartner
Copy link
Member

Congratulations, the code is much better now.
I can give LGTM now without doubt

@DaanHoogland
Copy link
Contributor

1373.network.results.txt
1373.vpc.results.txt

the errors in the network tests are due to moved tests en not related to volumes. I am satisfied with these results: LGTM

@ProjectMoon
Copy link
Author

Who gets to be the authority on merging this?

@wido
Copy link
Contributor

wido commented Feb 10, 2016

@ProjectMoon Currently waiting for a new Release Manager for version 4.9 to pick this up

@ProjectMoon
Copy link
Author

Even for forward-merged bug fixes?

@bvbharatk
Copy link
Contributor

ACS CI BVT Run

Sumarry:
Build Number 110
Hypervisor xenserver
NetworkType Advanced
Passed=104
Failed=15
Skipped=4

The follwing tests have known issues
test_vpc_remote_access_vpn
test_vpc_site2site_vpn
test_01_test_vm_volume_snapshot
test_02_vpc_privategw_static_routes
test_03_rvpc_privategw_static_routes
test_04_change_offering_small
ContextSuite context=TestNiciraContoller>:setup
test_01_primary_storage_iscsi
test02_internallb_haproxy_stats_on_all_interfaces
test_01_internallb_roundrobin_1VPC_3VM_HTTP_port80
ContextSuite context=TestDeployVM>:setup
test_04_extract_template
test_04_extract_Iso
test_07_list_default_iso

Link to logs Folder (search by build_no): https://www.dropbox.com/sh/yj3wnzbceo9uef2/AAB6u-Iap-xztdm6jHX9SjPja?dl=0

Failed tests:

  • integration.smoke.test_guest_vlan_range.TestDedicateGuestVlanRange
    • test_dedicateGuestVlanRange Failed
    • ContextSuite context=TestDedicateGuestVlanRange>:teardown Failing since 3 runs
  • integration.smoke.test_non_contigiousvlan.TestUpdatePhysicalNetwork
    • test_extendPhysicalNetworkVlan Failed

Skipped tests:
test_vm_nic_adapter_vmxnet3
test_deploy_vgpu_enabled_vm
test_06_copy_template
test_06_copy_iso

Passed test suits:
integration.smoke.test_deploy_vm_with_userdata.TestDeployVmWithUserData
integration.smoke.test_affinity_groups_projects.TestDeployVmWithAffinityGroup
integration.smoke.test_portable_publicip.TestPortablePublicIPAcquire
integration.smoke.test_over_provisioning.TestUpdateOverProvision
integration.smoke.test_global_settings.TestUpdateConfigWithScope
integration.smoke.test_scale_vm.TestScaleVm
integration.smoke.test_service_offerings.TestCreateServiceOffering
integration.smoke.test_loadbalance.TestLoadBalance
integration.smoke.test_routers.TestRouterServices
integration.smoke.test_reset_vm_on_reboot.TestResetVmOnReboot
integration.smoke.test_snapshots.TestSnapshotRootDisk
integration.smoke.test_deploy_vms_with_varied_deploymentplanners.TestDeployVmWithVariedPlanners
integration.smoke.test_network.TestDeleteAccount
integration.smoke.test_deploy_vm_iso.TestDeployVMFromISO
integration.smoke.test_public_ip_range.TestDedicatePublicIPRange
integration.smoke.test_multipleips_per_nic.TestDeployVM
integration.smoke.test_regions.TestRegions
integration.smoke.test_affinity_groups.TestDeployVmWithAffinityGroup
integration.smoke.test_network_acl.TestNetworkACL
integration.smoke.test_pvlan.TestPVLAN
integration.smoke.test_volumes.TestCreateVolume
integration.smoke.test_ssvm.TestSSVMs
integration.smoke.test_nic.TestNic
integration.smoke.test_deploy_vm_root_resize.TestDeployVM
integration.smoke.test_resource_detail.TestResourceDetail
integration.smoke.test_secondary_storage.TestSecStorageServices
integration.smoke.test_vm_life_cycle.TestDeployVM
integration.smoke.test_disk_offerings.TestCreateDiskOffering

@ProjectMoon
Copy link
Author

We have found that this fix actually does not work on 4.7+. We are going to submit a new pull request based on 4.7 with a working fix.

@ProjectMoon ProjectMoon deleted the pr-volume-usage-events-fixes-4.6 branch April 13, 2016 11:10
asfgit pushed a commit that referenced this pull request Oct 22, 2016
…-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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants