{"action":"opened","number":17305,"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/17305","id":63960256,"html_url":"https://github.com/elastic/elasticsearch/pull/17305","diff_url":"https://github.com/elastic/elasticsearch/pull/17305.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/17305.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/17305","number":17305,"state":"open","locked":false,"title":"Add API to explain why a shard is or isn't assigned","user":{"login":"dakrone","id":19060,"avatar_url":"https://avatars.githubusercontent.com/u/19060?v=3","gravatar_id":"","url":"https://api.github.com/users/dakrone","html_url":"https://github.com/dakrone","followers_url":"https://api.github.com/users/dakrone/followers","following_url":"https://api.github.com/users/dakrone/following{/other_user}","gists_url":"https://api.github.com/users/dakrone/gists{/gist_id}","starred_url":"https://api.github.com/users/dakrone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dakrone/subscriptions","organizations_url":"https://api.github.com/users/dakrone/orgs","repos_url":"https://api.github.com/users/dakrone/repos","events_url":"https://api.github.com/users/dakrone/events{/privacy}","received_events_url":"https://api.github.com/users/dakrone/received_events","type":"User","site_admin":false},"body":"This adds a new `/_cluster/allocation/explain` API that explains why a\r\nshard can or cannot be allocated to nodes in the cluster. Additionally,\r\nit will show where the master *desires* to put the shard, according to\r\nthe `ShardsAllocator`.\r\n\r\nIt looks like this:\r\n\r\n```json\r\nGET /_cluster/allocation/explain?pretty\r\n{\r\n  \"index\": \"only-foo\",\r\n  \"shard\": 0,\r\n  \"primary\": false\r\n}\r\n```\r\n\r\nThough, you can optionally send an empty body, which means \"explain the\r\nallocation for the first unassigned shard you find\".\r\n\r\nThe output when a shard is unassigned looks like this:\r\n\r\n```json\r\n{\r\n  \"shard\" : {\r\n    \"index\" : \"only-foo\",\r\n    \"index_uuid\" : \"KnW0-zELRs6PK84l0r38ZA\",\r\n    \"id\" : 0,\r\n    \"primary\" : false\r\n  },\r\n  \"assigned\" : false,\r\n  \"unassigned_info\" : {\r\n    \"reason\" : \"INDEX_CREATED\",\r\n    \"at\" : \"2016-03-22T20:04:23.620Z\"\r\n  },\r\n  \"nodes\" : {\r\n    \"V-Spi0AyRZ6ZvKbaI3691w\" : {\r\n      \"node_name\" : \"Susan Storm\",\r\n      \"node_attributes\" : {\r\n        \"bar\" : \"baz\"\r\n      },\r\n      \"final_decision\" : \"NO\",\r\n      \"weight\" : 0.06666675,\r\n      \"decisions\" : [ {\r\n        \"decider\" : \"filter\",\r\n        \"decision\" : \"NO\",\r\n        \"explanation\" : \"node does not match index include filters [foo:\\\"bar\\\"]\"\r\n      } ]\r\n    },\r\n    \"Qc6VL8c5RWaw1qXZ0Rg57g\" : {\r\n      \"node_name\" : \"Slipstream\",\r\n      \"node_attributes\" : {\r\n        \"bar\" : \"baz\",\r\n        \"foo\" : \"bar\"\r\n      },\r\n      \"final_decision\" : \"NO\",\r\n      \"weight\" : -1.3833332,\r\n      \"decisions\" : [ {\r\n        \"decider\" : \"same_shard\",\r\n        \"decision\" : \"NO\",\r\n        \"explanation\" : \"the shard cannot be allocated on the same node id [Qc6VL8c5RWaw1qXZ0Rg57g] on which it already exists\"\r\n      } ]\r\n    },\r\n    \"PzdyMZGXQdGhqTJHF_hGgA\" : {\r\n      \"node_name\" : \"The Symbiote\",\r\n      \"node_attributes\" : { },\r\n      \"final_decision\" : \"NO\",\r\n      \"weight\" : 2.3166666,\r\n      \"decisions\" : [ {\r\n        \"decider\" : \"filter\",\r\n        \"decision\" : \"NO\",\r\n        \"explanation\" : \"node does not match index include filters [foo:\\\"bar\\\"]\"\r\n      } ]\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nAnd when the shard *is* assigned, the output looks like:\r\n\r\n```json\r\n{\r\n  \"shard\" : {\r\n    \"index\" : \"only-foo\",\r\n    \"index_uuid\" : \"KnW0-zELRs6PK84l0r38ZA\",\r\n    \"id\" : 0,\r\n    \"primary\" : true\r\n  },\r\n  \"assigned\" : true,\r\n  \"assigned_node_id\" : \"Qc6VL8c5RWaw1qXZ0Rg57g\",\r\n  \"nodes\" : {\r\n    \"V-Spi0AyRZ6ZvKbaI3691w\" : {\r\n      \"node_name\" : \"Susan Storm\",\r\n      \"node_attributes\" : {\r\n        \"bar\" : \"baz\"\r\n      },\r\n      \"final_decision\" : \"NO\",\r\n      \"weight\" : 1.4499999,\r\n      \"decisions\" : [ {\r\n        \"decider\" : \"filter\",\r\n        \"decision\" : \"NO\",\r\n        \"explanation\" : \"node does not match index include filters [foo:\\\"bar\\\"]\"\r\n      } ]\r\n    },\r\n    \"Qc6VL8c5RWaw1qXZ0Rg57g\" : {\r\n      \"node_name\" : \"Slipstream\",\r\n      \"node_attributes\" : {\r\n        \"bar\" : \"baz\",\r\n        \"foo\" : \"bar\"\r\n      },\r\n      \"final_decision\" : \"CURRENTLY_ASSIGNED\",\r\n      \"weight\" : 0.0,\r\n      \"decisions\" : [ {\r\n        \"decider\" : \"same_shard\",\r\n        \"decision\" : \"NO\",\r\n        \"explanation\" : \"the shard cannot be allocated on the same node id [Qc6VL8c5RWaw1qXZ0Rg57g] on which it already exists\"\r\n      } ]\r\n    },\r\n    \"PzdyMZGXQdGhqTJHF_hGgA\" : {\r\n      \"node_name\" : \"The Symbiote\",\r\n      \"node_attributes\" : { },\r\n      \"final_decision\" : \"NO\",\r\n      \"weight\" : 3.6999998,\r\n      \"decisions\" : [ {\r\n        \"decider\" : \"filter\",\r\n        \"decision\" : \"NO\",\r\n        \"explanation\" : \"node does not match index include filters [foo:\\\"bar\\\"]\"\r\n      } ]\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nOnly \"NO\" decisions are returned by default, but all decisions can be\r\nshown by specifying the `?include_yes_decisions=true` parameter in the\r\nrequest.\r\n\r\nResolves #14593","created_at":"2016-03-23T22:01:22Z","updated_at":"2016-03-23T22:01:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/17305/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/17305/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/17305/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/a5ac64ad0be0e841ba2d14689a9aad43c4e66e6b","head":{"label":"dakrone:allocation-explain","ref":"allocation-explain","sha":"a5ac64ad0be0e841ba2d14689a9aad43c4e66e6b","user":{"login":"dakrone","id":19060,"avatar_url":"https://avatars.githubusercontent.com/u/19060?v=3","gravatar_id":"","url":"https://api.github.com/users/dakrone","html_url":"https://github.com/dakrone","followers_url":"https://api.github.com/users/dakrone/followers","following_url":"https://api.github.com/users/dakrone/following{/other_user}","gists_url":"https://api.github.com/users/dakrone/gists{/gist_id}","starred_url":"https://api.github.com/users/dakrone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dakrone/subscriptions","organizations_url":"https://api.github.com/users/dakrone/orgs","repos_url":"https://api.github.com/users/dakrone/repos","events_url":"https://api.github.com/users/dakrone/events{/privacy}","received_events_url":"https://api.github.com/users/dakrone/received_events","type":"User","site_admin":false},"repo":{"id":3037278,"name":"elasticsearch","full_name":"dakrone/elasticsearch","owner":{"login":"dakrone","id":19060,"avatar_url":"https://avatars.githubusercontent.com/u/19060?v=3","gravatar_id":"","url":"https://api.github.com/users/dakrone","html_url":"https://github.com/dakrone","followers_url":"https://api.github.com/users/dakrone/followers","following_url":"https://api.github.com/users/dakrone/following{/other_user}","gists_url":"https://api.github.com/users/dakrone/gists{/gist_id}","starred_url":"https://api.github.com/users/dakrone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dakrone/subscriptions","organizations_url":"https://api.github.com/users/dakrone/orgs","repos_url":"https://api.github.com/users/dakrone/repos","events_url":"https://api.github.com/users/dakrone/events{/privacy}","received_events_url":"https://api.github.com/users/dakrone/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dakrone/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/dakrone/elasticsearch","forks_url":"https://api.github.com/repos/dakrone/elasticsearch/forks","keys_url":"https://api.github.com/repos/dakrone/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dakrone/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dakrone/elasticsearch/teams","hooks_url":"https://api.github.com/repos/dakrone/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/dakrone/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/dakrone/elasticsearch/events","assignees_url":"https://api.github.com/repos/dakrone/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/dakrone/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/dakrone/elasticsearch/tags","blobs_url":"https://api.github.com/repos/dakrone/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dakrone/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dakrone/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/dakrone/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dakrone/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/dakrone/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/dakrone/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/dakrone/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/dakrone/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/dakrone/elasticsearch/subscription","commits_url":"https://api.github.com/repos/dakrone/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/dakrone/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/dakrone/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/dakrone/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/dakrone/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/dakrone/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dakrone/elasticsearch/merges","archive_url":"https://api.github.com/repos/dakrone/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dakrone/elasticsearch/downloads","issues_url":"https://api.github.com/repos/dakrone/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/dakrone/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/dakrone/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/dakrone/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dakrone/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/dakrone/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/dakrone/elasticsearch/deployments","created_at":"2011-12-22T23:14:00Z","updated_at":"2014-12-16T08:28:10Z","pushed_at":"2016-03-23T21:58:43Z","git_url":"git://github.com/dakrone/elasticsearch.git","ssh_url":"git@github.com:dakrone/elasticsearch.git","clone_url":"https://github.com/dakrone/elasticsearch.git","svn_url":"https://github.com/dakrone/elasticsearch","homepage":"http://elasticsearch.org","size":185059,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"04e6e6c3e052b5c8284bb406dee3cba319b9b27e","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":507775,"name":"elasticsearch","full_name":"elastic/elasticsearch","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":false,"url":"https://api.github.com/repos/elastic/elasticsearch","forks_url":"https://api.github.com/repos/elastic/elasticsearch/forks","keys_url":"https://api.github.com/repos/elastic/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/elasticsearch/teams","hooks_url":"https://api.github.com/repos/elastic/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/elasticsearch/events","assignees_url":"https://api.github.com/repos/elastic/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/elasticsearch/tags","blobs_url":"https://api.github.com/repos/elastic/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/elastic/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/elastic/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/elastic/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/elastic/elasticsearch/subscription","commits_url":"https://api.github.com/repos/elastic/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/elasticsearch/merges","archive_url":"https://api.github.com/repos/elastic/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/elasticsearch/downloads","issues_url":"https://api.github.com/repos/elastic/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/elastic/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/elastic/elasticsearch/deployments","created_at":"2010-02-08T13:20:56Z","updated_at":"2016-03-23T20:52:05Z","pushed_at":"2016-03-23T21:57:54Z","git_url":"git://github.com/elastic/elasticsearch.git","ssh_url":"git@github.com:elastic/elasticsearch.git","clone_url":"https://github.com/elastic/elasticsearch.git","svn_url":"https://github.com/elastic/elasticsearch","homepage":"https://www.elastic.co/products/elasticsearch","size":298130,"stargazers_count":15666,"watchers_count":15666,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5229,"mirror_url":null,"open_issues_count":1075,"forks":5229,"open_issues":1075,"watchers":15666,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/17305"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/17305"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/17305"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/17305/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/17305/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/17305/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/a5ac64ad0be0e841ba2d14689a9aad43c4e66e6b"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":1618,"deletions":109,"changed_files":38}}