{"action":"created","comment":{"url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments/38043835","id":38043835,"diff_hunk":"@@ -244,6 +244,57 @@ func (a *allocator) RebalanceTarget(required proto.Attributes, existing []proto.\n \treturn s\n }\n \n+// RemoveTarget returns a suitable replica to remove from the provided replica\n+// set. It attempts to consider which of the provided replicas would be the best\n+// candidate for removal.\n+func (a *allocator) RemoveTarget(existing []proto.Replica) (proto.Replica, error) {","path":"storage/allocator.go","position":7,"original_position":7,"commit_id":"89d2d31eb660b48e858fd740b9ea25f49ce8b423","original_commit_id":"89d2d31eb660b48e858fd740b9ea25f49ce8b423","user":{"login":"spencerkimball","id":6147149,"avatar_url":"https://avatars.githubusercontent.com/u/6147149?v=3","gravatar_id":"","url":"https://api.github.com/users/spencerkimball","html_url":"https://github.com/spencerkimball","followers_url":"https://api.github.com/users/spencerkimball/followers","following_url":"https://api.github.com/users/spencerkimball/following{/other_user}","gists_url":"https://api.github.com/users/spencerkimball/gists{/gist_id}","starred_url":"https://api.github.com/users/spencerkimball/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spencerkimball/subscriptions","organizations_url":"https://api.github.com/users/spencerkimball/orgs","repos_url":"https://api.github.com/users/spencerkimball/repos","events_url":"https://api.github.com/users/spencerkimball/events{/privacy}","received_events_url":"https://api.github.com/users/spencerkimball/received_events","type":"User","site_admin":false},"body":"Add a TODO here. You're going to need to supply a slice of Attributes from the zone config. Based on that, you'll determine which replicas are appropriate to remove: first based on attributes, then based on the store statistics.\r\n\r\nAs a simple example, if the zone config requires three replicas:\r\n\r\n  [Attributes([]string{\"us-east-1a\"}), Attributes([]string{\"us-east-1b\"}), Attributes([]string{\"us-east-1c\"})]\r\n\r\nAnd you have one replica with \"us-east-1a\", one with \"us-east-1b\", and two with \"us-east-1c\", you're only going to want to consider the two \"us-east-1c\" replicas as targets.","created_at":"2015-08-26T22:36:08Z","updated_at":"2015-08-26T22:36:08Z","html_url":"https://github.com/cockroachdb/cockroach/pull/2277#discussion_r38043835","pull_request_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2277","_links":{"self":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments/38043835"},"html":{"href":"https://github.com/cockroachdb/cockroach/pull/2277#discussion_r38043835"},"pull_request":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2277"}}},"pull_request":{"url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2277","id":43458921,"html_url":"https://github.com/cockroachdb/cockroach/pull/2277","diff_url":"https://github.com/cockroachdb/cockroach/pull/2277.diff","patch_url":"https://github.com/cockroachdb/cockroach/pull/2277.patch","issue_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/2277","number":2277,"state":"open","locked":false,"title":"Implement allocator.RemoveTarget","user":{"login":"mrtracy","id":6969858,"avatar_url":"https://avatars.githubusercontent.com/u/6969858?v=3","gravatar_id":"","url":"https://api.github.com/users/mrtracy","html_url":"https://github.com/mrtracy","followers_url":"https://api.github.com/users/mrtracy/followers","following_url":"https://api.github.com/users/mrtracy/following{/other_user}","gists_url":"https://api.github.com/users/mrtracy/gists{/gist_id}","starred_url":"https://api.github.com/users/mrtracy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrtracy/subscriptions","organizations_url":"https://api.github.com/users/mrtracy/orgs","repos_url":"https://api.github.com/users/mrtracy/repos","events_url":"https://api.github.com/users/mrtracy/events{/privacy}","received_events_url":"https://api.github.com/users/mrtracy/received_events","type":"User","site_admin":false},"body":"`allocator.RemoveTarget()` will be used to determine which replica in a given\r\nreplica set is the best candidate to be removed. The criteria is currently very\r\nsimple: the replica with the least available capacity is chosen for removal.\r\n\r\nThis will be used by the replicate queue to remove replicas from ranges that are\r\nover-replicated.","created_at":"2015-08-26T22:17:03Z","updated_at":"2015-08-26T22:36:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0fe0cf234d81dcefc6f252b3582f87e124b09917","assignee":{"login":"BramGruneir","id":1614265,"avatar_url":"https://avatars.githubusercontent.com/u/1614265?v=3","gravatar_id":"","url":"https://api.github.com/users/BramGruneir","html_url":"https://github.com/BramGruneir","followers_url":"https://api.github.com/users/BramGruneir/followers","following_url":"https://api.github.com/users/BramGruneir/following{/other_user}","gists_url":"https://api.github.com/users/BramGruneir/gists{/gist_id}","starred_url":"https://api.github.com/users/BramGruneir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BramGruneir/subscriptions","organizations_url":"https://api.github.com/users/BramGruneir/orgs","repos_url":"https://api.github.com/users/BramGruneir/repos","events_url":"https://api.github.com/users/BramGruneir/events{/privacy}","received_events_url":"https://api.github.com/users/BramGruneir/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2277/commits","review_comments_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2277/comments","review_comment_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/2277/comments","statuses_url":"https://api.github.com/repos/cockroachdb/cockroach/statuses/89d2d31eb660b48e858fd740b9ea25f49ce8b423","head":{"label":"mrtracy:mtracy/replicate_queue_remove_replicas","ref":"mtracy/replicate_queue_remove_replicas","sha":"89d2d31eb660b48e858fd740b9ea25f49ce8b423","user":{"login":"mrtracy","id":6969858,"avatar_url":"https://avatars.githubusercontent.com/u/6969858?v=3","gravatar_id":"","url":"https://api.github.com/users/mrtracy","html_url":"https://github.com/mrtracy","followers_url":"https://api.github.com/users/mrtracy/followers","following_url":"https://api.github.com/users/mrtracy/following{/other_user}","gists_url":"https://api.github.com/users/mrtracy/gists{/gist_id}","starred_url":"https://api.github.com/users/mrtracy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrtracy/subscriptions","organizations_url":"https://api.github.com/users/mrtracy/orgs","repos_url":"https://api.github.com/users/mrtracy/repos","events_url":"https://api.github.com/users/mrtracy/events{/privacy}","received_events_url":"https://api.github.com/users/mrtracy/received_events","type":"User","site_admin":false},"repo":{"id":39856388,"name":"cockroach","full_name":"mrtracy/cockroach","owner":{"login":"mrtracy","id":6969858,"avatar_url":"https://avatars.githubusercontent.com/u/6969858?v=3","gravatar_id":"","url":"https://api.github.com/users/mrtracy","html_url":"https://github.com/mrtracy","followers_url":"https://api.github.com/users/mrtracy/followers","following_url":"https://api.github.com/users/mrtracy/following{/other_user}","gists_url":"https://api.github.com/users/mrtracy/gists{/gist_id}","starred_url":"https://api.github.com/users/mrtracy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrtracy/subscriptions","organizations_url":"https://api.github.com/users/mrtracy/orgs","repos_url":"https://api.github.com/users/mrtracy/repos","events_url":"https://api.github.com/users/mrtracy/events{/privacy}","received_events_url":"https://api.github.com/users/mrtracy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mrtracy/cockroach","description":"A Scalable, Geo-Replicated, Transactional Datastore","fork":true,"url":"https://api.github.com/repos/mrtracy/cockroach","forks_url":"https://api.github.com/repos/mrtracy/cockroach/forks","keys_url":"https://api.github.com/repos/mrtracy/cockroach/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mrtracy/cockroach/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mrtracy/cockroach/teams","hooks_url":"https://api.github.com/repos/mrtracy/cockroach/hooks","issue_events_url":"https://api.github.com/repos/mrtracy/cockroach/issues/events{/number}","events_url":"https://api.github.com/repos/mrtracy/cockroach/events","assignees_url":"https://api.github.com/repos/mrtracy/cockroach/assignees{/user}","branches_url":"https://api.github.com/repos/mrtracy/cockroach/branches{/branch}","tags_url":"https://api.github.com/repos/mrtracy/cockroach/tags","blobs_url":"https://api.github.com/repos/mrtracy/cockroach/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mrtracy/cockroach/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mrtracy/cockroach/git/refs{/sha}","trees_url":"https://api.github.com/repos/mrtracy/cockroach/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mrtracy/cockroach/statuses/{sha}","languages_url":"https://api.github.com/repos/mrtracy/cockroach/languages","stargazers_url":"https://api.github.com/repos/mrtracy/cockroach/stargazers","contributors_url":"https://api.github.com/repos/mrtracy/cockroach/contributors","subscribers_url":"https://api.github.com/repos/mrtracy/cockroach/subscribers","subscription_url":"https://api.github.com/repos/mrtracy/cockroach/subscription","commits_url":"https://api.github.com/repos/mrtracy/cockroach/commits{/sha}","git_commits_url":"https://api.github.com/repos/mrtracy/cockroach/git/commits{/sha}","comments_url":"https://api.github.com/repos/mrtracy/cockroach/comments{/number}","issue_comment_url":"https://api.github.com/repos/mrtracy/cockroach/issues/comments{/number}","contents_url":"https://api.github.com/repos/mrtracy/cockroach/contents/{+path}","compare_url":"https://api.github.com/repos/mrtracy/cockroach/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mrtracy/cockroach/merges","archive_url":"https://api.github.com/repos/mrtracy/cockroach/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mrtracy/cockroach/downloads","issues_url":"https://api.github.com/repos/mrtracy/cockroach/issues{/number}","pulls_url":"https://api.github.com/repos/mrtracy/cockroach/pulls{/number}","milestones_url":"https://api.github.com/repos/mrtracy/cockroach/milestones{/number}","notifications_url":"https://api.github.com/repos/mrtracy/cockroach/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mrtracy/cockroach/labels{/name}","releases_url":"https://api.github.com/repos/mrtracy/cockroach/releases{/id}","created_at":"2015-07-28T20:33:41Z","updated_at":"2015-07-28T20:33:42Z","pushed_at":"2015-08-26T22:16:35Z","git_url":"git://github.com/mrtracy/cockroach.git","ssh_url":"git@github.com:mrtracy/cockroach.git","clone_url":"https://github.com/mrtracy/cockroach.git","svn_url":"https://github.com/mrtracy/cockroach","homepage":null,"size":28767,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cockroachdb:master","ref":"master","sha":"cc59220639a71f1fb77e668e6b80f6d8d542c239","user":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars.githubusercontent.com/u/6748139?v=3","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"repo":{"id":16563587,"name":"cockroach","full_name":"cockroachdb/cockroach","owner":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars.githubusercontent.com/u/6748139?v=3","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cockroachdb/cockroach","description":"A Scalable, Geo-Replicated, Transactional Datastore","fork":false,"url":"https://api.github.com/repos/cockroachdb/cockroach","forks_url":"https://api.github.com/repos/cockroachdb/cockroach/forks","keys_url":"https://api.github.com/repos/cockroachdb/cockroach/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cockroachdb/cockroach/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cockroachdb/cockroach/teams","hooks_url":"https://api.github.com/repos/cockroachdb/cockroach/hooks","issue_events_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/events{/number}","events_url":"https://api.github.com/repos/cockroachdb/cockroach/events","assignees_url":"https://api.github.com/repos/cockroachdb/cockroach/assignees{/user}","branches_url":"https://api.github.com/repos/cockroachdb/cockroach/branches{/branch}","tags_url":"https://api.github.com/repos/cockroachdb/cockroach/tags","blobs_url":"https://api.github.com/repos/cockroachdb/cockroach/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cockroachdb/cockroach/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cockroachdb/cockroach/git/refs{/sha}","trees_url":"https://api.github.com/repos/cockroachdb/cockroach/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cockroachdb/cockroach/statuses/{sha}","languages_url":"https://api.github.com/repos/cockroachdb/cockroach/languages","stargazers_url":"https://api.github.com/repos/cockroachdb/cockroach/stargazers","contributors_url":"https://api.github.com/repos/cockroachdb/cockroach/contributors","subscribers_url":"https://api.github.com/repos/cockroachdb/cockroach/subscribers","subscription_url":"https://api.github.com/repos/cockroachdb/cockroach/subscription","commits_url":"https://api.github.com/repos/cockroachdb/cockroach/commits{/sha}","git_commits_url":"https://api.github.com/repos/cockroachdb/cockroach/git/commits{/sha}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/comments{/number}","issue_comment_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/comments{/number}","contents_url":"https://api.github.com/repos/cockroachdb/cockroach/contents/{+path}","compare_url":"https://api.github.com/repos/cockroachdb/cockroach/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cockroachdb/cockroach/merges","archive_url":"https://api.github.com/repos/cockroachdb/cockroach/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cockroachdb/cockroach/downloads","issues_url":"https://api.github.com/repos/cockroachdb/cockroach/issues{/number}","pulls_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls{/number}","milestones_url":"https://api.github.com/repos/cockroachdb/cockroach/milestones{/number}","notifications_url":"https://api.github.com/repos/cockroachdb/cockroach/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cockroachdb/cockroach/labels{/name}","releases_url":"https://api.github.com/repos/cockroachdb/cockroach/releases{/id}","created_at":"2014-02-06T00:18:47Z","updated_at":"2015-08-26T21:08:50Z","pushed_at":"2015-08-26T22:17:03Z","git_url":"git://github.com/cockroachdb/cockroach.git","ssh_url":"git@github.com:cockroachdb/cockroach.git","clone_url":"https://github.com/cockroachdb/cockroach.git","svn_url":"https://github.com/cockroachdb/cockroach","homepage":null,"size":51946,"stargazers_count":5051,"watchers_count":5051,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":399,"mirror_url":null,"open_issues_count":152,"forks":399,"open_issues":152,"watchers":5051,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2277"},"html":{"href":"https://github.com/cockroachdb/cockroach/pull/2277"},"issue":{"href":"https://api.github.com/repos/cockroachdb/cockroach/issues/2277"},"comments":{"href":"https://api.github.com/repos/cockroachdb/cockroach/issues/2277/comments"},"review_comments":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2277/comments"},"review_comment":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/2277/commits"},"statuses":{"href":"https://api.github.com/repos/cockroachdb/cockroach/statuses/89d2d31eb660b48e858fd740b9ea25f49ce8b423"}}}}