{"action":"created","comment":{"url":"https://api.github.com/repos/apache/cloudstack/pulls/comments/74314062","id":74314062,"diff_hunk":"@@ -0,0 +1,356 @@\n+// Licensed to the Apache Software Foundation (ASF) under one\n+// or more contributor license agreements.  See the NOTICE file\n+// distributed with this work for additional information\n+// regarding copyright ownership.  The ASF licenses this file\n+// to you under the Apache License, Version 2.0 (the\n+// \"License\"); you may not use this file except in compliance\n+// with the License.  You may obtain a copy of the License at\n+//\n+//   http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing,\n+// software distributed under the License is distributed on an\n+// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+// KIND, either express or implied.  See the License for the\n+// specific language governing permissions and limitations\n+// under the License.\n+package com.cloud.user;\n+\n+import java.util.ArrayList;\n+import java.util.Date;\n+import java.util.List;\n+import java.util.Map;\n+\n+import javax.naming.ConfigurationException;\n+\n+import com.cloud.event.UsageEventVO;\n+import com.cloud.event.dao.UsageEventDao;\n+import com.cloud.utils.Pair;\n+import com.cloud.utils.db.Attribute;\n+import com.cloud.utils.db.Filter;\n+import com.cloud.utils.db.GenericSearchBuilder;\n+import com.cloud.utils.db.SearchBuilder;\n+import com.cloud.utils.db.SearchCriteria;\n+\n+public class MockUsageEventDao implements UsageEventDao{\n+\n+    List<UsageEventVO> persistedItems;\n+\n+    public MockUsageEventDao() {\n+        persistedItems = new ArrayList<UsageEventVO>();\n+    }\n+\n+    @Override\n+    public UsageEventVO findById(Long id) {\n+        // TODO Auto-generated method stub\n+        return null;\n+    }\n+\n+    @Override\n+    public UsageEventVO findByIdIncludingRemoved(Long id) {\n+        // TODO Auto-generated method stub","path":"server/test/com/cloud/user/MockUsageEventDao.java","position":51,"original_position":51,"commit_id":"c861e1a4922ce9030d0a0d8542572d3a444c1509","original_commit_id":"c861e1a4922ce9030d0a0d8542572d3a444c1509","user":{"login":"jburwell","id":285646,"avatar_url":"https://avatars.githubusercontent.com/u/285646?v=3","gravatar_id":"","url":"https://api.github.com/users/jburwell","html_url":"https://github.com/jburwell","followers_url":"https://api.github.com/users/jburwell/followers","following_url":"https://api.github.com/users/jburwell/following{/other_user}","gists_url":"https://api.github.com/users/jburwell/gists{/gist_id}","starred_url":"https://api.github.com/users/jburwell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jburwell/subscriptions","organizations_url":"https://api.github.com/users/jburwell/orgs","repos_url":"https://api.github.com/users/jburwell/repos","events_url":"https://api.github.com/users/jburwell/events{/privacy}","received_events_url":"https://api.github.com/users/jburwell/received_events","type":"User","site_admin":false},"body":"Is there a TODO to be resolved?","created_at":"2016-08-10T19:32:54Z","updated_at":"2016-08-10T19:32:54Z","html_url":"https://github.com/apache/cloudstack/pull/1624#discussion_r74314062","pull_request_url":"https://api.github.com/repos/apache/cloudstack/pulls/1624","_links":{"self":{"href":"https://api.github.com/repos/apache/cloudstack/pulls/comments/74314062"},"html":{"href":"https://github.com/apache/cloudstack/pull/1624#discussion_r74314062"},"pull_request":{"href":"https://api.github.com/repos/apache/cloudstack/pulls/1624"}}},"pull_request":{"url":"https://api.github.com/repos/apache/cloudstack/pulls/1624","id":79747281,"html_url":"https://github.com/apache/cloudstack/pull/1624","diff_url":"https://github.com/apache/cloudstack/pull/1624.diff","patch_url":"https://github.com/apache/cloudstack/pull/1624.patch","issue_url":"https://api.github.com/repos/apache/cloudstack/issues/1624","number":1624,"state":"open","locked":false,"title":"Fixes regarding VOLUME_DELETE events resulting from account deletion","user":{"login":"ProjectMoon","id":183856,"avatar_url":"https://avatars.githubusercontent.com/u/183856?v=3","gravatar_id":"","url":"https://api.github.com/users/ProjectMoon","html_url":"https://github.com/ProjectMoon","followers_url":"https://api.github.com/users/ProjectMoon/followers","following_url":"https://api.github.com/users/ProjectMoon/following{/other_user}","gists_url":"https://api.github.com/users/ProjectMoon/gists{/gist_id}","starred_url":"https://api.github.com/users/ProjectMoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ProjectMoon/subscriptions","organizations_url":"https://api.github.com/users/ProjectMoon/orgs","repos_url":"https://api.github.com/users/ProjectMoon/repos","events_url":"https://api.github.com/users/ProjectMoon/events{/privacy}","received_events_url":"https://api.github.com/users/ProjectMoon/received_events","type":"User","site_admin":false},"body":"New version of #1491.\r\n\r\n**Original Description**\r\nNew 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.\r\n\r\nOriginal pull request:\r\nFixes regarding usage event emission.\r\n\r\nUsageEventUtils 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.\r\n\r\nFurthermore, 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.\r\n\r\nTo 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. \r\nCreate 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.","created_at":"2016-08-02T14:40:50Z","updated_at":"2016-08-10T19:32:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9b3f33cbe228ad5d940b4843f8586792fa912dbc","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/cloudstack/pulls/1624/commits","review_comments_url":"https://api.github.com/repos/apache/cloudstack/pulls/1624/comments","review_comment_url":"https://api.github.com/repos/apache/cloudstack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/cloudstack/issues/1624/comments","statuses_url":"https://api.github.com/repos/apache/cloudstack/statuses/c861e1a4922ce9030d0a0d8542572d3a444c1509","head":{"label":"greenqloud:pr-volume-usage-events-fixes-4.8","ref":"pr-volume-usage-events-fixes-4.8","sha":"c861e1a4922ce9030d0a0d8542572d3a444c1509","user":{"login":"greenqloud","id":228758,"avatar_url":"https://avatars.githubusercontent.com/u/228758?v=3","gravatar_id":"","url":"https://api.github.com/users/greenqloud","html_url":"https://github.com/greenqloud","followers_url":"https://api.github.com/users/greenqloud/followers","following_url":"https://api.github.com/users/greenqloud/following{/other_user}","gists_url":"https://api.github.com/users/greenqloud/gists{/gist_id}","starred_url":"https://api.github.com/users/greenqloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/greenqloud/subscriptions","organizations_url":"https://api.github.com/users/greenqloud/orgs","repos_url":"https://api.github.com/users/greenqloud/repos","events_url":"https://api.github.com/users/greenqloud/events{/privacy}","received_events_url":"https://api.github.com/users/greenqloud/received_events","type":"Organization","site_admin":false},"repo":{"id":36817746,"name":"cloudstack","full_name":"greenqloud/cloudstack","owner":{"login":"greenqloud","id":228758,"avatar_url":"https://avatars.githubusercontent.com/u/228758?v=3","gravatar_id":"","url":"https://api.github.com/users/greenqloud","html_url":"https://github.com/greenqloud","followers_url":"https://api.github.com/users/greenqloud/followers","following_url":"https://api.github.com/users/greenqloud/following{/other_user}","gists_url":"https://api.github.com/users/greenqloud/gists{/gist_id}","starred_url":"https://api.github.com/users/greenqloud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/greenqloud/subscriptions","organizations_url":"https://api.github.com/users/greenqloud/orgs","repos_url":"https://api.github.com/users/greenqloud/repos","events_url":"https://api.github.com/users/greenqloud/events{/privacy}","received_events_url":"https://api.github.com/users/greenqloud/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/greenqloud/cloudstack","description":"Mirror of Apache Cloudstack","fork":true,"url":"https://api.github.com/repos/greenqloud/cloudstack","forks_url":"https://api.github.com/repos/greenqloud/cloudstack/forks","keys_url":"https://api.github.com/repos/greenqloud/cloudstack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/greenqloud/cloudstack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/greenqloud/cloudstack/teams","hooks_url":"https://api.github.com/repos/greenqloud/cloudstack/hooks","issue_events_url":"https://api.github.com/repos/greenqloud/cloudstack/issues/events{/number}","events_url":"https://api.github.com/repos/greenqloud/cloudstack/events","assignees_url":"https://api.github.com/repos/greenqloud/cloudstack/assignees{/user}","branches_url":"https://api.github.com/repos/greenqloud/cloudstack/branches{/branch}","tags_url":"https://api.github.com/repos/greenqloud/cloudstack/tags","blobs_url":"https://api.github.com/repos/greenqloud/cloudstack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/greenqloud/cloudstack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/greenqloud/cloudstack/git/refs{/sha}","trees_url":"https://api.github.com/repos/greenqloud/cloudstack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/greenqloud/cloudstack/statuses/{sha}","languages_url":"https://api.github.com/repos/greenqloud/cloudstack/languages","stargazers_url":"https://api.github.com/repos/greenqloud/cloudstack/stargazers","contributors_url":"https://api.github.com/repos/greenqloud/cloudstack/contributors","subscribers_url":"https://api.github.com/repos/greenqloud/cloudstack/subscribers","subscription_url":"https://api.github.com/repos/greenqloud/cloudstack/subscription","commits_url":"https://api.github.com/repos/greenqloud/cloudstack/commits{/sha}","git_commits_url":"https://api.github.com/repos/greenqloud/cloudstack/git/commits{/sha}","comments_url":"https://api.github.com/repos/greenqloud/cloudstack/comments{/number}","issue_comment_url":"https://api.github.com/repos/greenqloud/cloudstack/issues/comments{/number}","contents_url":"https://api.github.com/repos/greenqloud/cloudstack/contents/{+path}","compare_url":"https://api.github.com/repos/greenqloud/cloudstack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/greenqloud/cloudstack/merges","archive_url":"https://api.github.com/repos/greenqloud/cloudstack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/greenqloud/cloudstack/downloads","issues_url":"https://api.github.com/repos/greenqloud/cloudstack/issues{/number}","pulls_url":"https://api.github.com/repos/greenqloud/cloudstack/pulls{/number}","milestones_url":"https://api.github.com/repos/greenqloud/cloudstack/milestones{/number}","notifications_url":"https://api.github.com/repos/greenqloud/cloudstack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/greenqloud/cloudstack/labels{/name}","releases_url":"https://api.github.com/repos/greenqloud/cloudstack/releases{/id}","deployments_url":"https://api.github.com/repos/greenqloud/cloudstack/deployments","created_at":"2015-06-03T16:58:20Z","updated_at":"2016-01-25T10:38:02Z","pushed_at":"2016-08-08T14:19:18Z","git_url":"git://github.com/greenqloud/cloudstack.git","ssh_url":"git@github.com:greenqloud/cloudstack.git","clone_url":"https://github.com/greenqloud/cloudstack.git","svn_url":"https://github.com/greenqloud/cloudstack","homepage":null,"size":507732,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:4.8","ref":"4.8","sha":"01758ee867f75f2fc7487793a892e86952dc843d","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":9759448,"name":"cloudstack","full_name":"apache/cloudstack","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/cloudstack","description":"Mirror of Apache Cloudstack","fork":false,"url":"https://api.github.com/repos/apache/cloudstack","forks_url":"https://api.github.com/repos/apache/cloudstack/forks","keys_url":"https://api.github.com/repos/apache/cloudstack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/cloudstack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/cloudstack/teams","hooks_url":"https://api.github.com/repos/apache/cloudstack/hooks","issue_events_url":"https://api.github.com/repos/apache/cloudstack/issues/events{/number}","events_url":"https://api.github.com/repos/apache/cloudstack/events","assignees_url":"https://api.github.com/repos/apache/cloudstack/assignees{/user}","branches_url":"https://api.github.com/repos/apache/cloudstack/branches{/branch}","tags_url":"https://api.github.com/repos/apache/cloudstack/tags","blobs_url":"https://api.github.com/repos/apache/cloudstack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/cloudstack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/cloudstack/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/cloudstack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/cloudstack/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/cloudstack/languages","stargazers_url":"https://api.github.com/repos/apache/cloudstack/stargazers","contributors_url":"https://api.github.com/repos/apache/cloudstack/contributors","subscribers_url":"https://api.github.com/repos/apache/cloudstack/subscribers","subscription_url":"https://api.github.com/repos/apache/cloudstack/subscription","commits_url":"https://api.github.com/repos/apache/cloudstack/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/cloudstack/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/cloudstack/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/cloudstack/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/cloudstack/contents/{+path}","compare_url":"https://api.github.com/repos/apache/cloudstack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/cloudstack/merges","archive_url":"https://api.github.com/repos/apache/cloudstack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/cloudstack/downloads","issues_url":"https://api.github.com/repos/apache/cloudstack/issues{/number}","pulls_url":"https://api.github.com/repos/apache/cloudstack/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/cloudstack/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/cloudstack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/cloudstack/labels{/name}","releases_url":"https://api.github.com/repos/apache/cloudstack/releases{/id}","deployments_url":"https://api.github.com/repos/apache/cloudstack/deployments","created_at":"2013-04-29T22:27:12Z","updated_at":"2016-08-04T16:58:06Z","pushed_at":"2016-08-10T18:20:37Z","git_url":"git://github.com/apache/cloudstack.git","ssh_url":"git@github.com:apache/cloudstack.git","clone_url":"https://github.com/apache/cloudstack.git","svn_url":"https://github.com/apache/cloudstack","homepage":null,"size":549267,"stargazers_count":393,"watchers_count":393,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":506,"mirror_url":"git://git.apache.org/cloudstack.git","open_issues_count":159,"forks":506,"open_issues":159,"watchers":393,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/cloudstack/pulls/1624"},"html":{"href":"https://github.com/apache/cloudstack/pull/1624"},"issue":{"href":"https://api.github.com/repos/apache/cloudstack/issues/1624"},"comments":{"href":"https://api.github.com/repos/apache/cloudstack/issues/1624/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/cloudstack/pulls/1624/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/cloudstack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/cloudstack/pulls/1624/commits"},"statuses":{"href":"https://api.github.com/repos/apache/cloudstack/statuses/c861e1a4922ce9030d0a0d8542572d3a444c1509"}}}}
{"actor":{"display_login":"jburwell"}}