{"action":"created","comment":{"url":"https://api.github.com/repos/sequenceiq/cloudbreak/pulls/comments/33354525","id":33354525,"diff_hunk":"@@ -195,6 +196,28 @@ public void delete(Long id, CbUser user) {\n     }\n \n     @Override\n+    public void removeInstance(CbUser user, Long stackId, String instanceId) {\n+        Stack stack = stackRepository.findById(stackId);\n+        InstanceMetaData instanceMetaData = instanceMetaDataRepository.findByInstanceId(stackId, instanceId);\n+        if (stack == null) {\n+            throw new NotFoundException(String.format(\"Not found stack with id '%s'\", stackId.toString()));\n+        }\n+        if (instanceMetaData == null) {\n+            throw new NotFoundException(String.format(\"Not found instance metadata with id '%s'\", instanceId));\n+        }\n+        if (stack.getCluster() == null) {\n+            throw new NotFoundException(String.format(\"Not found cluster for stack '%s'\", stack.getId()));\n+        }\n+        if (!stack.getAccount().equals(user.getAccount())) {\n+            throw new BadRequestException(String.format(\"Stack %s is not accessible from this account.\", stackId));\n+        }\n+        if (!stack.isPublicInAccount() && !stack.getOwner().equals(user.getUserId())) {\n+            throw new BadRequestException(String.format(\"Private stack (%s) only modifiable by the owner.\", stackId));\n+        }","path":"core/src/main/java/com/sequenceiq/cloudbreak/service/stack/DefaultStackService.java","position":29,"original_position":29,"commit_id":"615fc27341b616bf7a954e7b235dad7a6b470ea9","original_commit_id":"615fc27341b616bf7a954e7b235dad7a6b470ea9","user":{"login":"martonsereg","id":1568469,"avatar_url":"https://avatars.githubusercontent.com/u/1568469?v=3","gravatar_id":"","url":"https://api.github.com/users/martonsereg","html_url":"https://github.com/martonsereg","followers_url":"https://api.github.com/users/martonsereg/followers","following_url":"https://api.github.com/users/martonsereg/following{/other_user}","gists_url":"https://api.github.com/users/martonsereg/gists{/gist_id}","starred_url":"https://api.github.com/users/martonsereg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martonsereg/subscriptions","organizations_url":"https://api.github.com/users/martonsereg/orgs","repos_url":"https://api.github.com/users/martonsereg/repos","events_url":"https://api.github.com/users/martonsereg/events{/privacy}","received_events_url":"https://api.github.com/users/martonsereg/received_events","type":"User","site_admin":false},"body":"If the findOne method is used instead of findById, it is not needed to check the user and the owner because the OwnerBasedPermissionEvaluator class does this through the PostAuthorize annotation.","created_at":"2015-06-26T13:19:29Z","updated_at":"2015-06-26T13:19:29Z","html_url":"https://github.com/sequenceiq/cloudbreak/pull/764#discussion_r33354525","pull_request_url":"https://api.github.com/repos/sequenceiq/cloudbreak/pulls/764","_links":{"self":{"href":"https://api.github.com/repos/sequenceiq/cloudbreak/pulls/comments/33354525"},"html":{"href":"https://github.com/sequenceiq/cloudbreak/pull/764#discussion_r33354525"},"pull_request":{"href":"https://api.github.com/repos/sequenceiq/cloudbreak/pulls/764"}}},"pull_request":{"url":"https://api.github.com/repos/sequenceiq/cloudbreak/pulls/764","id":38567196,"html_url":"https://github.com/sequenceiq/cloudbreak/pull/764","diff_url":"https://github.com/sequenceiq/cloudbreak/pull/764.diff","patch_url":"https://github.com/sequenceiq/cloudbreak/pull/764.patch","issue_url":"https://api.github.com/repos/sequenceiq/cloudbreak/issues/764","number":764,"state":"open","locked":false,"title":"CLOUD-878 added host metadata state for sync","user":{"login":"oleewere","id":1231814,"avatar_url":"https://avatars.githubusercontent.com/u/1231814?v=3","gravatar_id":"","url":"https://api.github.com/users/oleewere","html_url":"https://github.com/oleewere","followers_url":"https://api.github.com/users/oleewere/followers","following_url":"https://api.github.com/users/oleewere/following{/other_user}","gists_url":"https://api.github.com/users/oleewere/gists{/gist_id}","starred_url":"https://api.github.com/users/oleewere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oleewere/subscriptions","organizations_url":"https://api.github.com/users/oleewere/orgs","repos_url":"https://api.github.com/users/oleewere/repos","events_url":"https://api.github.com/users/oleewere/events{/privacy}","received_events_url":"https://api.github.com/users/oleewere/received_events","type":"User","site_admin":false},"body":"note: try this before merging.\r\ntest case: ssh into an instance (slave node), stop ambari-client with docker stop, after a few minutes, sync the cluster. -> state of the stopped host will be changed.\r\nthen: case 1 - start/fix the stopped ambari client -> sync again, case 2 - terminate the instance (use the new endpoint)","created_at":"2015-06-25T16:34:36Z","updated_at":"2015-06-26T13:19:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a8dde2241b231d53e1b274de04ffc6a59e078535","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sequenceiq/cloudbreak/pulls/764/commits","review_comments_url":"https://api.github.com/repos/sequenceiq/cloudbreak/pulls/764/comments","review_comment_url":"https://api.github.com/repos/sequenceiq/cloudbreak/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sequenceiq/cloudbreak/issues/764/comments","statuses_url":"https://api.github.com/repos/sequenceiq/cloudbreak/statuses/615fc27341b616bf7a954e7b235dad7a6b470ea9","head":{"label":"sequenceiq:host-metadata-state","ref":"host-metadata-state","sha":"615fc27341b616bf7a954e7b235dad7a6b470ea9","user":{"login":"sequenceiq","id":6003133,"avatar_url":"https://avatars.githubusercontent.com/u/6003133?v=3","gravatar_id":"","url":"https://api.github.com/users/sequenceiq","html_url":"https://github.com/sequenceiq","followers_url":"https://api.github.com/users/sequenceiq/followers","following_url":"https://api.github.com/users/sequenceiq/following{/other_user}","gists_url":"https://api.github.com/users/sequenceiq/gists{/gist_id}","starred_url":"https://api.github.com/users/sequenceiq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sequenceiq/subscriptions","organizations_url":"https://api.github.com/users/sequenceiq/orgs","repos_url":"https://api.github.com/users/sequenceiq/repos","events_url":"https://api.github.com/users/sequenceiq/events{/privacy}","received_events_url":"https://api.github.com/users/sequenceiq/received_events","type":"Organization","site_admin":false},"repo":{"id":19638422,"name":"cloudbreak","full_name":"sequenceiq/cloudbreak","owner":{"login":"sequenceiq","id":6003133,"avatar_url":"https://avatars.githubusercontent.com/u/6003133?v=3","gravatar_id":"","url":"https://api.github.com/users/sequenceiq","html_url":"https://github.com/sequenceiq","followers_url":"https://api.github.com/users/sequenceiq/followers","following_url":"https://api.github.com/users/sequenceiq/following{/other_user}","gists_url":"https://api.github.com/users/sequenceiq/gists{/gist_id}","starred_url":"https://api.github.com/users/sequenceiq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sequenceiq/subscriptions","organizations_url":"https://api.github.com/users/sequenceiq/orgs","repos_url":"https://api.github.com/users/sequenceiq/repos","events_url":"https://api.github.com/users/sequenceiq/events{/privacy}","received_events_url":"https://api.github.com/users/sequenceiq/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sequenceiq/cloudbreak","description":"Cloudbreak is a cloud agnostic Hadoop as a Service API.","fork":false,"url":"https://api.github.com/repos/sequenceiq/cloudbreak","forks_url":"https://api.github.com/repos/sequenceiq/cloudbreak/forks","keys_url":"https://api.github.com/repos/sequenceiq/cloudbreak/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sequenceiq/cloudbreak/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sequenceiq/cloudbreak/teams","hooks_url":"https://api.github.com/repos/sequenceiq/cloudbreak/hooks","issue_events_url":"https://api.github.com/repos/sequenceiq/cloudbreak/issues/events{/number}","events_url":"https://api.github.com/repos/sequenceiq/cloudbreak/events","assignees_url":"https://api.github.com/repos/sequenceiq/cloudbreak/assignees{/user}","branches_url":"https://api.github.com/repos/sequenceiq/cloudbreak/branches{/branch}","tags_url":"https://api.github.com/repos/sequenceiq/cloudbreak/tags","blobs_url":"https://api.github.com/repos/sequenceiq/cloudbreak/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sequenceiq/cloudbreak/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sequenceiq/cloudbreak/git/refs{/sha}","trees_url":"https://api.github.com/repos/sequenceiq/cloudbreak/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sequenceiq/cloudbreak/statuses/{sha}","languages_url":"https://api.github.com/repos/sequenceiq/cloudbreak/languages","stargazers_url":"https://api.github.com/repos/sequenceiq/cloudbreak/stargazers","contributors_url":"https://api.github.com/repos/sequenceiq/cloudbreak/contributors","subscribers_url":"https://api.github.com/repos/sequenceiq/cloudbreak/subscribers","subscription_url":"https://api.github.com/repos/sequenceiq/cloudbreak/subscription","commits_url":"https://api.github.com/repos/sequenceiq/cloudbreak/commits{/sha}","git_commits_url":"https://api.github.com/repos/sequenceiq/cloudbreak/git/commits{/sha}","comments_url":"https://api.github.com/repos/sequenceiq/cloudbreak/comments{/number}","issue_comment_url":"https://api.github.com/repos/sequenceiq/cloudbreak/issues/comments{/number}","contents_url":"https://api.github.com/repos/sequenceiq/cloudbreak/contents/{+path}","compare_url":"https://api.github.com/repos/sequenceiq/cloudbreak/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sequenceiq/cloudbreak/merges","archive_url":"https://api.github.com/repos/sequenceiq/cloudbreak/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sequenceiq/cloudbreak/downloads","issues_url":"https://api.github.com/repos/sequenceiq/cloudbreak/issues{/number}","pulls_url":"https://api.github.com/repos/sequenceiq/cloudbreak/pulls{/number}","milestones_url":"https://api.github.com/repos/sequenceiq/cloudbreak/milestones{/number}","notifications_url":"https://api.github.com/repos/sequenceiq/cloudbreak/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sequenceiq/cloudbreak/labels{/name}","releases_url":"https://api.github.com/repos/sequenceiq/cloudbreak/releases{/id}","created_at":"2014-05-10T10:03:07Z","updated_at":"2015-06-25T02:09:07Z","pushed_at":"2015-06-26T13:04:20Z","git_url":"git://github.com/sequenceiq/cloudbreak.git","ssh_url":"git@github.com:sequenceiq/cloudbreak.git","clone_url":"https://github.com/sequenceiq/cloudbreak.git","svn_url":"https://github.com/sequenceiq/cloudbreak","homepage":"https://cloudbreak.sequenceiq.com/","size":20922,"stargazers_count":96,"watchers_count":96,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":15,"mirror_url":null,"open_issues_count":13,"forks":15,"open_issues":13,"watchers":96,"default_branch":"master"}},"base":{"label":"sequenceiq:master","ref":"master","sha":"ea42b034c11134bafe1244d0d0133c5ba796ed41","user":{"login":"sequenceiq","id":6003133,"avatar_url":"https://avatars.githubusercontent.com/u/6003133?v=3","gravatar_id":"","url":"https://api.github.com/users/sequenceiq","html_url":"https://github.com/sequenceiq","followers_url":"https://api.github.com/users/sequenceiq/followers","following_url":"https://api.github.com/users/sequenceiq/following{/other_user}","gists_url":"https://api.github.com/users/sequenceiq/gists{/gist_id}","starred_url":"https://api.github.com/users/sequenceiq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sequenceiq/subscriptions","organizations_url":"https://api.github.com/users/sequenceiq/orgs","repos_url":"https://api.github.com/users/sequenceiq/repos","events_url":"https://api.github.com/users/sequenceiq/events{/privacy}","received_events_url":"https://api.github.com/users/sequenceiq/received_events","type":"Organization","site_admin":false},"repo":{"id":19638422,"name":"cloudbreak","full_name":"sequenceiq/cloudbreak","owner":{"login":"sequenceiq","id":6003133,"avatar_url":"https://avatars.githubusercontent.com/u/6003133?v=3","gravatar_id":"","url":"https://api.github.com/users/sequenceiq","html_url":"https://github.com/sequenceiq","followers_url":"https://api.github.com/users/sequenceiq/followers","following_url":"https://api.github.com/users/sequenceiq/following{/other_user}","gists_url":"https://api.github.com/users/sequenceiq/gists{/gist_id}","starred_url":"https://api.github.com/users/sequenceiq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sequenceiq/subscriptions","organizations_url":"https://api.github.com/users/sequenceiq/orgs","repos_url":"https://api.github.com/users/sequenceiq/repos","events_url":"https://api.github.com/users/sequenceiq/events{/privacy}","received_events_url":"https://api.github.com/users/sequenceiq/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sequenceiq/cloudbreak","description":"Cloudbreak is a cloud agnostic Hadoop as a Service API.","fork":false,"url":"https://api.github.com/repos/sequenceiq/cloudbreak","forks_url":"https://api.github.com/repos/sequenceiq/cloudbreak/forks","keys_url":"https://api.github.com/repos/sequenceiq/cloudbreak/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sequenceiq/cloudbreak/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sequenceiq/cloudbreak/teams","hooks_url":"https://api.github.com/repos/sequenceiq/cloudbreak/hooks","issue_events_url":"https://api.github.com/repos/sequenceiq/cloudbreak/issues/events{/number}","events_url":"https://api.github.com/repos/sequenceiq/cloudbreak/events","assignees_url":"https://api.github.com/repos/sequenceiq/cloudbreak/assignees{/user}","branches_url":"https://api.github.com/repos/sequenceiq/cloudbreak/branches{/branch}","tags_url":"https://api.github.com/repos/sequenceiq/cloudbreak/tags","blobs_url":"https://api.github.com/repos/sequenceiq/cloudbreak/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sequenceiq/cloudbreak/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sequenceiq/cloudbreak/git/refs{/sha}","trees_url":"https://api.github.com/repos/sequenceiq/cloudbreak/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sequenceiq/cloudbreak/statuses/{sha}","languages_url":"https://api.github.com/repos/sequenceiq/cloudbreak/languages","stargazers_url":"https://api.github.com/repos/sequenceiq/cloudbreak/stargazers","contributors_url":"https://api.github.com/repos/sequenceiq/cloudbreak/contributors","subscribers_url":"https://api.github.com/repos/sequenceiq/cloudbreak/subscribers","subscription_url":"https://api.github.com/repos/sequenceiq/cloudbreak/subscription","commits_url":"https://api.github.com/repos/sequenceiq/cloudbreak/commits{/sha}","git_commits_url":"https://api.github.com/repos/sequenceiq/cloudbreak/git/commits{/sha}","comments_url":"https://api.github.com/repos/sequenceiq/cloudbreak/comments{/number}","issue_comment_url":"https://api.github.com/repos/sequenceiq/cloudbreak/issues/comments{/number}","contents_url":"https://api.github.com/repos/sequenceiq/cloudbreak/contents/{+path}","compare_url":"https://api.github.com/repos/sequenceiq/cloudbreak/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sequenceiq/cloudbreak/merges","archive_url":"https://api.github.com/repos/sequenceiq/cloudbreak/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sequenceiq/cloudbreak/downloads","issues_url":"https://api.github.com/repos/sequenceiq/cloudbreak/issues{/number}","pulls_url":"https://api.github.com/repos/sequenceiq/cloudbreak/pulls{/number}","milestones_url":"https://api.github.com/repos/sequenceiq/cloudbreak/milestones{/number}","notifications_url":"https://api.github.com/repos/sequenceiq/cloudbreak/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sequenceiq/cloudbreak/labels{/name}","releases_url":"https://api.github.com/repos/sequenceiq/cloudbreak/releases{/id}","created_at":"2014-05-10T10:03:07Z","updated_at":"2015-06-25T02:09:07Z","pushed_at":"2015-06-26T13:04:20Z","git_url":"git://github.com/sequenceiq/cloudbreak.git","ssh_url":"git@github.com:sequenceiq/cloudbreak.git","clone_url":"https://github.com/sequenceiq/cloudbreak.git","svn_url":"https://github.com/sequenceiq/cloudbreak","homepage":"https://cloudbreak.sequenceiq.com/","size":20922,"stargazers_count":96,"watchers_count":96,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":15,"mirror_url":null,"open_issues_count":13,"forks":15,"open_issues":13,"watchers":96,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sequenceiq/cloudbreak/pulls/764"},"html":{"href":"https://github.com/sequenceiq/cloudbreak/pull/764"},"issue":{"href":"https://api.github.com/repos/sequenceiq/cloudbreak/issues/764"},"comments":{"href":"https://api.github.com/repos/sequenceiq/cloudbreak/issues/764/comments"},"review_comments":{"href":"https://api.github.com/repos/sequenceiq/cloudbreak/pulls/764/comments"},"review_comment":{"href":"https://api.github.com/repos/sequenceiq/cloudbreak/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sequenceiq/cloudbreak/pulls/764/commits"},"statuses":{"href":"https://api.github.com/repos/sequenceiq/cloudbreak/statuses/615fc27341b616bf7a954e7b235dad7a6b470ea9"}}}}