{"action":"created","comment":{"url":"https://api.github.com/repos/HubSpot/Singularity/pulls/comments/63204485","id":63204485,"diff_hunk":"@@ -603,7 +603,7 @@ private SingularityDeployResult markStepFinished(SingularityPendingDeploy pendin\n     int numTasksToShutDown = Math.max(otherActiveTasks.size() - (request.getInstancesSafe() - deployProgress.getTargetActiveInstances()), 0);\n     List<SingularityTaskId> sortedOtherTasks = new ArrayList<>(otherActiveTasks);\n     Collections.sort(sortedOtherTasks, SingularityTaskId.INSTANCE_NO_COMPARATOR);\n-    return sortedOtherTasks.subList(0, numTasksToShutDown);\n+    return sortedOtherTasks.subList(0, Math.min(numTasksToShutDown, sortedOtherTasks.size() - 1));","path":"SingularityService/src/main/java/com/hubspot/singularity/scheduler/SingularityDeployChecker.java","position":5,"original_position":5,"commit_id":"b9b9f494d16a3aa1a5ae5cab9cdd7f0e1fd966c7","original_commit_id":"b9b9f494d16a3aa1a5ae5cab9cdd7f0e1fd966c7","user":{"login":"tpetr","id":47152,"avatar_url":"https://avatars.githubusercontent.com/u/47152?v=3","gravatar_id":"","url":"https://api.github.com/users/tpetr","html_url":"https://github.com/tpetr","followers_url":"https://api.github.com/users/tpetr/followers","following_url":"https://api.github.com/users/tpetr/following{/other_user}","gists_url":"https://api.github.com/users/tpetr/gists{/gist_id}","starred_url":"https://api.github.com/users/tpetr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tpetr/subscriptions","organizations_url":"https://api.github.com/users/tpetr/orgs","repos_url":"https://api.github.com/users/tpetr/repos","events_url":"https://api.github.com/users/tpetr/events{/privacy}","received_events_url":"https://api.github.com/users/tpetr/received_events","type":"User","site_admin":false},"body":"But if you look at that javadoc, `toIndex` is exclusive:\r\n\r\n```\r\n     * @param fromIndex low endpoint (inclusive) of the subList\r\n     * @param toIndex high endpoint (exclusive) of the subList\r\n     * @return a view of the specified range within this list\r\n     * @throws IndexOutOfBoundsException for an illegal endpoint index value\r\n     *         (<tt>fromIndex &lt; 0 || toIndex &gt; size ||\r\n     *         fromIndex &gt; toIndex</tt>)\r\n     */\r\n```","created_at":"2016-05-13T15:40:43Z","updated_at":"2016-05-13T15:40:43Z","html_url":"https://github.com/HubSpot/Singularity/pull/1037#discussion_r63204485","pull_request_url":"https://api.github.com/repos/HubSpot/Singularity/pulls/1037","_links":{"self":{"href":"https://api.github.com/repos/HubSpot/Singularity/pulls/comments/63204485"},"html":{"href":"https://github.com/HubSpot/Singularity/pull/1037#discussion_r63204485"},"pull_request":{"href":"https://api.github.com/repos/HubSpot/Singularity/pulls/1037"}}},"pull_request":{"url":"https://api.github.com/repos/HubSpot/Singularity/pulls/1037","id":70005040,"html_url":"https://github.com/HubSpot/Singularity/pull/1037","diff_url":"https://github.com/HubSpot/Singularity/pull/1037.diff","patch_url":"https://github.com/HubSpot/Singularity/pull/1037.patch","issue_url":"https://api.github.com/repos/HubSpot/Singularity/issues/1037","number":1037,"state":"open","locked":false,"title":"avoid index out of bounds when finding tasks to shut down","user":{"login":"ssalinas","id":6034439,"avatar_url":"https://avatars.githubusercontent.com/u/6034439?v=3","gravatar_id":"","url":"https://api.github.com/users/ssalinas","html_url":"https://github.com/ssalinas","followers_url":"https://api.github.com/users/ssalinas/followers","following_url":"https://api.github.com/users/ssalinas/following{/other_user}","gists_url":"https://api.github.com/users/ssalinas/gists{/gist_id}","starred_url":"https://api.github.com/users/ssalinas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssalinas/subscriptions","organizations_url":"https://api.github.com/users/ssalinas/orgs","repos_url":"https://api.github.com/users/ssalinas/repos","events_url":"https://api.github.com/users/ssalinas/events{/privacy}","received_events_url":"https://api.github.com/users/ssalinas/received_events","type":"User","site_admin":false},"body":"@stevenschlansker should fix that edge case you ran into the other day when scaling + deploying at the same time","created_at":"2016-05-13T14:31:42Z","updated_at":"2016-05-13T15:40:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7cf75ab1f600fbb1455acdd1733b36fd155b9d6b","assignee":null,"milestone":{"url":"https://api.github.com/repos/HubSpot/Singularity/milestones/14","html_url":"https://github.com/HubSpot/Singularity/milestones/0.6.0","labels_url":"https://api.github.com/repos/HubSpot/Singularity/milestones/14/labels","id":1684895,"number":14,"title":"0.6.0","description":"","creator":{"login":"ssalinas","id":6034439,"avatar_url":"https://avatars.githubusercontent.com/u/6034439?v=3","gravatar_id":"","url":"https://api.github.com/users/ssalinas","html_url":"https://github.com/ssalinas","followers_url":"https://api.github.com/users/ssalinas/followers","following_url":"https://api.github.com/users/ssalinas/following{/other_user}","gists_url":"https://api.github.com/users/ssalinas/gists{/gist_id}","starred_url":"https://api.github.com/users/ssalinas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ssalinas/subscriptions","organizations_url":"https://api.github.com/users/ssalinas/orgs","repos_url":"https://api.github.com/users/ssalinas/repos","events_url":"https://api.github.com/users/ssalinas/events{/privacy}","received_events_url":"https://api.github.com/users/ssalinas/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":35,"state":"open","created_at":"2016-04-05T15:31:47Z","updated_at":"2016-05-13T15:19:00Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/HubSpot/Singularity/pulls/1037/commits","review_comments_url":"https://api.github.com/repos/HubSpot/Singularity/pulls/1037/comments","review_comment_url":"https://api.github.com/repos/HubSpot/Singularity/pulls/comments{/number}","comments_url":"https://api.github.com/repos/HubSpot/Singularity/issues/1037/comments","statuses_url":"https://api.github.com/repos/HubSpot/Singularity/statuses/b9b9f494d16a3aa1a5ae5cab9cdd7f0e1fd966c7","head":{"label":"HubSpot:avoid_oob","ref":"avoid_oob","sha":"b9b9f494d16a3aa1a5ae5cab9cdd7f0e1fd966c7","user":{"login":"HubSpot","id":326419,"avatar_url":"https://avatars.githubusercontent.com/u/326419?v=3","gravatar_id":"","url":"https://api.github.com/users/HubSpot","html_url":"https://github.com/HubSpot","followers_url":"https://api.github.com/users/HubSpot/followers","following_url":"https://api.github.com/users/HubSpot/following{/other_user}","gists_url":"https://api.github.com/users/HubSpot/gists{/gist_id}","starred_url":"https://api.github.com/users/HubSpot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HubSpot/subscriptions","organizations_url":"https://api.github.com/users/HubSpot/orgs","repos_url":"https://api.github.com/users/HubSpot/repos","events_url":"https://api.github.com/users/HubSpot/events{/privacy}","received_events_url":"https://api.github.com/users/HubSpot/received_events","type":"Organization","site_admin":false},"repo":{"id":13631804,"name":"Singularity","full_name":"HubSpot/Singularity","owner":{"login":"HubSpot","id":326419,"avatar_url":"https://avatars.githubusercontent.com/u/326419?v=3","gravatar_id":"","url":"https://api.github.com/users/HubSpot","html_url":"https://github.com/HubSpot","followers_url":"https://api.github.com/users/HubSpot/followers","following_url":"https://api.github.com/users/HubSpot/following{/other_user}","gists_url":"https://api.github.com/users/HubSpot/gists{/gist_id}","starred_url":"https://api.github.com/users/HubSpot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HubSpot/subscriptions","organizations_url":"https://api.github.com/users/HubSpot/orgs","repos_url":"https://api.github.com/users/HubSpot/repos","events_url":"https://api.github.com/users/HubSpot/events{/privacy}","received_events_url":"https://api.github.com/users/HubSpot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/HubSpot/Singularity","description":"Scheduler (HTTP API and webapp) for running Mesos tasks—long running processes, one-off tasks, and scheduled jobs. #hubspot-open-source","fork":false,"url":"https://api.github.com/repos/HubSpot/Singularity","forks_url":"https://api.github.com/repos/HubSpot/Singularity/forks","keys_url":"https://api.github.com/repos/HubSpot/Singularity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HubSpot/Singularity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HubSpot/Singularity/teams","hooks_url":"https://api.github.com/repos/HubSpot/Singularity/hooks","issue_events_url":"https://api.github.com/repos/HubSpot/Singularity/issues/events{/number}","events_url":"https://api.github.com/repos/HubSpot/Singularity/events","assignees_url":"https://api.github.com/repos/HubSpot/Singularity/assignees{/user}","branches_url":"https://api.github.com/repos/HubSpot/Singularity/branches{/branch}","tags_url":"https://api.github.com/repos/HubSpot/Singularity/tags","blobs_url":"https://api.github.com/repos/HubSpot/Singularity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HubSpot/Singularity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HubSpot/Singularity/git/refs{/sha}","trees_url":"https://api.github.com/repos/HubSpot/Singularity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HubSpot/Singularity/statuses/{sha}","languages_url":"https://api.github.com/repos/HubSpot/Singularity/languages","stargazers_url":"https://api.github.com/repos/HubSpot/Singularity/stargazers","contributors_url":"https://api.github.com/repos/HubSpot/Singularity/contributors","subscribers_url":"https://api.github.com/repos/HubSpot/Singularity/subscribers","subscription_url":"https://api.github.com/repos/HubSpot/Singularity/subscription","commits_url":"https://api.github.com/repos/HubSpot/Singularity/commits{/sha}","git_commits_url":"https://api.github.com/repos/HubSpot/Singularity/git/commits{/sha}","comments_url":"https://api.github.com/repos/HubSpot/Singularity/comments{/number}","issue_comment_url":"https://api.github.com/repos/HubSpot/Singularity/issues/comments{/number}","contents_url":"https://api.github.com/repos/HubSpot/Singularity/contents/{+path}","compare_url":"https://api.github.com/repos/HubSpot/Singularity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HubSpot/Singularity/merges","archive_url":"https://api.github.com/repos/HubSpot/Singularity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HubSpot/Singularity/downloads","issues_url":"https://api.github.com/repos/HubSpot/Singularity/issues{/number}","pulls_url":"https://api.github.com/repos/HubSpot/Singularity/pulls{/number}","milestones_url":"https://api.github.com/repos/HubSpot/Singularity/milestones{/number}","notifications_url":"https://api.github.com/repos/HubSpot/Singularity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HubSpot/Singularity/labels{/name}","releases_url":"https://api.github.com/repos/HubSpot/Singularity/releases{/id}","deployments_url":"https://api.github.com/repos/HubSpot/Singularity/deployments","created_at":"2013-10-16T21:28:49Z","updated_at":"2016-05-08T09:43:56Z","pushed_at":"2016-05-13T15:19:00Z","git_url":"git://github.com/HubSpot/Singularity.git","ssh_url":"git@github.com:HubSpot/Singularity.git","clone_url":"https://github.com/HubSpot/Singularity.git","svn_url":"https://github.com/HubSpot/Singularity","homepage":"https://github.com/HubSpot/Singularity","size":64461,"stargazers_count":533,"watchers_count":533,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":84,"mirror_url":null,"open_issues_count":41,"forks":84,"open_issues":41,"watchers":533,"default_branch":"master"}},"base":{"label":"HubSpot:master","ref":"master","sha":"c35bc1baf1d930d6cf10075bd84b22808bed60a1","user":{"login":"HubSpot","id":326419,"avatar_url":"https://avatars.githubusercontent.com/u/326419?v=3","gravatar_id":"","url":"https://api.github.com/users/HubSpot","html_url":"https://github.com/HubSpot","followers_url":"https://api.github.com/users/HubSpot/followers","following_url":"https://api.github.com/users/HubSpot/following{/other_user}","gists_url":"https://api.github.com/users/HubSpot/gists{/gist_id}","starred_url":"https://api.github.com/users/HubSpot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HubSpot/subscriptions","organizations_url":"https://api.github.com/users/HubSpot/orgs","repos_url":"https://api.github.com/users/HubSpot/repos","events_url":"https://api.github.com/users/HubSpot/events{/privacy}","received_events_url":"https://api.github.com/users/HubSpot/received_events","type":"Organization","site_admin":false},"repo":{"id":13631804,"name":"Singularity","full_name":"HubSpot/Singularity","owner":{"login":"HubSpot","id":326419,"avatar_url":"https://avatars.githubusercontent.com/u/326419?v=3","gravatar_id":"","url":"https://api.github.com/users/HubSpot","html_url":"https://github.com/HubSpot","followers_url":"https://api.github.com/users/HubSpot/followers","following_url":"https://api.github.com/users/HubSpot/following{/other_user}","gists_url":"https://api.github.com/users/HubSpot/gists{/gist_id}","starred_url":"https://api.github.com/users/HubSpot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HubSpot/subscriptions","organizations_url":"https://api.github.com/users/HubSpot/orgs","repos_url":"https://api.github.com/users/HubSpot/repos","events_url":"https://api.github.com/users/HubSpot/events{/privacy}","received_events_url":"https://api.github.com/users/HubSpot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/HubSpot/Singularity","description":"Scheduler (HTTP API and webapp) for running Mesos tasks—long running processes, one-off tasks, and scheduled jobs. #hubspot-open-source","fork":false,"url":"https://api.github.com/repos/HubSpot/Singularity","forks_url":"https://api.github.com/repos/HubSpot/Singularity/forks","keys_url":"https://api.github.com/repos/HubSpot/Singularity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HubSpot/Singularity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HubSpot/Singularity/teams","hooks_url":"https://api.github.com/repos/HubSpot/Singularity/hooks","issue_events_url":"https://api.github.com/repos/HubSpot/Singularity/issues/events{/number}","events_url":"https://api.github.com/repos/HubSpot/Singularity/events","assignees_url":"https://api.github.com/repos/HubSpot/Singularity/assignees{/user}","branches_url":"https://api.github.com/repos/HubSpot/Singularity/branches{/branch}","tags_url":"https://api.github.com/repos/HubSpot/Singularity/tags","blobs_url":"https://api.github.com/repos/HubSpot/Singularity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HubSpot/Singularity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HubSpot/Singularity/git/refs{/sha}","trees_url":"https://api.github.com/repos/HubSpot/Singularity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HubSpot/Singularity/statuses/{sha}","languages_url":"https://api.github.com/repos/HubSpot/Singularity/languages","stargazers_url":"https://api.github.com/repos/HubSpot/Singularity/stargazers","contributors_url":"https://api.github.com/repos/HubSpot/Singularity/contributors","subscribers_url":"https://api.github.com/repos/HubSpot/Singularity/subscribers","subscription_url":"https://api.github.com/repos/HubSpot/Singularity/subscription","commits_url":"https://api.github.com/repos/HubSpot/Singularity/commits{/sha}","git_commits_url":"https://api.github.com/repos/HubSpot/Singularity/git/commits{/sha}","comments_url":"https://api.github.com/repos/HubSpot/Singularity/comments{/number}","issue_comment_url":"https://api.github.com/repos/HubSpot/Singularity/issues/comments{/number}","contents_url":"https://api.github.com/repos/HubSpot/Singularity/contents/{+path}","compare_url":"https://api.github.com/repos/HubSpot/Singularity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HubSpot/Singularity/merges","archive_url":"https://api.github.com/repos/HubSpot/Singularity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HubSpot/Singularity/downloads","issues_url":"https://api.github.com/repos/HubSpot/Singularity/issues{/number}","pulls_url":"https://api.github.com/repos/HubSpot/Singularity/pulls{/number}","milestones_url":"https://api.github.com/repos/HubSpot/Singularity/milestones{/number}","notifications_url":"https://api.github.com/repos/HubSpot/Singularity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HubSpot/Singularity/labels{/name}","releases_url":"https://api.github.com/repos/HubSpot/Singularity/releases{/id}","deployments_url":"https://api.github.com/repos/HubSpot/Singularity/deployments","created_at":"2013-10-16T21:28:49Z","updated_at":"2016-05-08T09:43:56Z","pushed_at":"2016-05-13T15:19:00Z","git_url":"git://github.com/HubSpot/Singularity.git","ssh_url":"git@github.com:HubSpot/Singularity.git","clone_url":"https://github.com/HubSpot/Singularity.git","svn_url":"https://github.com/HubSpot/Singularity","homepage":"https://github.com/HubSpot/Singularity","size":64461,"stargazers_count":533,"watchers_count":533,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":84,"mirror_url":null,"open_issues_count":41,"forks":84,"open_issues":41,"watchers":533,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/HubSpot/Singularity/pulls/1037"},"html":{"href":"https://github.com/HubSpot/Singularity/pull/1037"},"issue":{"href":"https://api.github.com/repos/HubSpot/Singularity/issues/1037"},"comments":{"href":"https://api.github.com/repos/HubSpot/Singularity/issues/1037/comments"},"review_comments":{"href":"https://api.github.com/repos/HubSpot/Singularity/pulls/1037/comments"},"review_comment":{"href":"https://api.github.com/repos/HubSpot/Singularity/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/HubSpot/Singularity/pulls/1037/commits"},"statuses":{"href":"https://api.github.com/repos/HubSpot/Singularity/statuses/b9b9f494d16a3aa1a5ae5cab9cdd7f0e1fd966c7"}}}}