{"action":"created","comment":{"url":"https://api.github.com/repos/remind101/empire/pulls/comments/105336928","pull_request_review_id":26212565,"id":105336928,"diff_hunk":"@@ -931,6 +968,101 @@ func (m *Scheduler) Run(ctx context.Context, app *scheduler.App, process *schedu\n \t\treturn fmt.Errorf(\"error calling RunTask: %v\", err)\n \t}\n \n+\tfor _, f := range runResp.Failures {\n+\t\treturn fmt.Errorf(\"error running task %s: %s\", aws.StringValue(f.Arn), aws.StringValue(f.Reason))\n+\t}\n+\n+\ttask := runResp.Tasks[0]\n+\n+\tif attached {\n+\t\tif err := m.attach(ctx, task, in, out); err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t}\n+\n+\treturn nil\n+}\n+\n+// attach attaches to the given ECS task.\n+func (m *Scheduler) attach(ctx context.Context, task *ecs.Task, in io.Reader, out io.Writer) error {\n+\tdefer tryClose(out)\n+\n+\tif a, _ := arn.Parse(aws.StringValue(task.TaskArn)); a != nil {\n+\t\t// TODO: This should really go to a STDERR stream instead. Putting this\n+\t\t// on stdout breaks redirection, but not including it leads to\n+\t\t// confusion.\n+\t\tfmt.Fprintf(out, \"Attaching to %s...\\n\", a.Resource)\n+\t}\n+\n+\tdescContainerInstanceResp, err := m.ecs.DescribeContainerInstances(&ecs.DescribeContainerInstancesInput{\n+\t\tCluster:            task.ClusterArn,\n+\t\tContainerInstances: []*string{task.ContainerInstanceArn},\n+\t})\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"error describing container instance (%s): %v\", aws.StringValue(task.ContainerInstanceArn), err)\n+\t}\n+\n+\tcontainerInstance := descContainerInstanceResp.ContainerInstances[0]\n+\tdescInstanceResp, err := m.ec2.DescribeInstances(&ec2.DescribeInstancesInput{\n+\t\tInstanceIds: []*string{containerInstance.Ec2InstanceId},\n+\t})\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"error describing ec2 instance (%s): %v\", aws.StringValue(containerInstance.Ec2InstanceId), err)\n+\t}\n+\n+\tec2Instance := descInstanceResp.Reservations[0].Instances[0]\n+\n+\t// Wait for the task to start running. It will stay in the\n+\t// PENDING state while the container is being pulled.\n+\tif err := m.ecs.WaitUntilTasksNotPending(&ecs.DescribeTasksInput{\n+\t\tCluster: task.ClusterArn,\n+\t\tTasks:   []*string{task.TaskArn},\n+\t}); err != nil {\n+\t\treturn fmt.Errorf(\"error waiting for %s to transition from PENDING state: %s\", aws.StringValue(task.TaskArn), err)\n+\t}\n+\n+\t// Open a new connection to the Docker daemon on the EC2\n+\t// instance where the task is running.\n+\td, err := m.NewDockerClient(ec2Instance)\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"error establishing docker client connection to %s\", aws.StringValue(ec2Instance.InstanceId))","path":"scheduler/cloudformation/cloudformation.go","position":175,"original_position":175,"commit_id":"1048ed4cd59907a32b80c4d99df39dc3fd4575ff","original_commit_id":"1048ed4cd59907a32b80c4d99df39dc3fd4575ff","user":{"login":"ejholmes","id":95166,"avatar_url":"https://avatars3.githubusercontent.com/u/95166?v=3","gravatar_id":"","url":"https://api.github.com/users/ejholmes","html_url":"https://github.com/ejholmes","followers_url":"https://api.github.com/users/ejholmes/followers","following_url":"https://api.github.com/users/ejholmes/following{/other_user}","gists_url":"https://api.github.com/users/ejholmes/gists{/gist_id}","starred_url":"https://api.github.com/users/ejholmes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ejholmes/subscriptions","organizations_url":"https://api.github.com/users/ejholmes/orgs","repos_url":"https://api.github.com/users/ejholmes/repos","events_url":"https://api.github.com/users/ejholmes/events{/privacy}","received_events_url":"https://api.github.com/users/ejholmes/received_events","type":"User","site_admin":false},"body":"Not atm. I'll add that information to the error.","created_at":"2017-03-10T06:17:51Z","updated_at":"2017-03-10T06:17:51Z","html_url":"https://github.com/remind101/empire/pull/1043#discussion_r105336928","pull_request_url":"https://api.github.com/repos/remind101/empire/pulls/1043","_links":{"self":{"href":"https://api.github.com/repos/remind101/empire/pulls/comments/105336928"},"html":{"href":"https://github.com/remind101/empire/pull/1043#discussion_r105336928"},"pull_request":{"href":"https://api.github.com/repos/remind101/empire/pulls/1043"}}},"pull_request":{"url":"https://api.github.com/repos/remind101/empire/pulls/1043","id":108446927,"html_url":"https://github.com/remind101/empire/pull/1043","diff_url":"https://github.com/remind101/empire/pull/1043.diff","patch_url":"https://github.com/remind101/empire/pull/1043.patch","issue_url":"https://api.github.com/repos/remind101/empire/issues/1043","number":1043,"state":"open","locked":false,"title":"Use the ECS RunTask API to run attached processes","user":{"login":"ejholmes","id":95166,"avatar_url":"https://avatars3.githubusercontent.com/u/95166?v=3","gravatar_id":"","url":"https://api.github.com/users/ejholmes","html_url":"https://github.com/ejholmes","followers_url":"https://api.github.com/users/ejholmes/followers","following_url":"https://api.github.com/users/ejholmes/following{/other_user}","gists_url":"https://api.github.com/users/ejholmes/gists{/gist_id}","starred_url":"https://api.github.com/users/ejholmes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ejholmes/subscriptions","organizations_url":"https://api.github.com/users/ejholmes/orgs","repos_url":"https://api.github.com/users/ejholmes/repos","events_url":"https://api.github.com/users/ejholmes/events{/privacy}","received_events_url":"https://api.github.com/users/ejholmes/received_events","type":"User","site_admin":false},"body":"Not ready to merge.\r\n\r\nThis is a prototype for switching `emp run` to use the ECS RunTask API, instead of calling out to Docker directly. The primary motivation behind this is to allow containers started with `emp run` to use AWS Roles for ECS tasks. This is described in https://github.com/remind101/empire/wiki/RFC:-Use-RunTask-API-for-attached-runs.\r\n\r\nThere's some serious caveats with this implementation at the moment:\r\n\r\n1. Because we use `AttachToContainer`, the container needs to be started with the `Tty` and `OpenStdin` flags set to true. Unfortunately, the ECS API and the ECS agent don't currently provide a method to pass these down. We would currently need to fork the agent.\r\n2. I haven't yet addressed backwards compatibility. It may be a good idea to provide a flag to use the old method for running attached runs entirely through Docker.\r\n\r\nOn the plus side, this sets up some infrastructure for adding an `emp exec/attach` command for starting up a process in an existing container, or attaching to a running process.\r\n\r\n**TODO**\r\n\r\n* [x] Figure out how to pass down `Tty`/`OpenStdin` flags.\r\n* [x] Add the ability to limit attached runs to a group of hosts.\r\n* [x] Enable this feature with a flag.\r\n* [ ] <strike>Add ability to limit normal containers to a group of hosts.</strike>\r\n* [x] Docs\r\n  * Expiremental\r\n  * Document Docker TLS requirements\r\n  * Document need for ECS agent patch.","created_at":"2017-03-01T01:06:43Z","updated_at":"2017-03-10T06:17:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9c59449c24cc04fc0e06528e659b727e03e5b04a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/remind101/empire/pulls/1043/commits","review_comments_url":"https://api.github.com/repos/remind101/empire/pulls/1043/comments","review_comment_url":"https://api.github.com/repos/remind101/empire/pulls/comments{/number}","comments_url":"https://api.github.com/repos/remind101/empire/issues/1043/comments","statuses_url":"https://api.github.com/repos/remind101/empire/statuses/1048ed4cd59907a32b80c4d99df39dc3fd4575ff","head":{"label":"remind101:ecs-run","ref":"ecs-run","sha":"1048ed4cd59907a32b80c4d99df39dc3fd4575ff","user":{"login":"remind101","id":376343,"avatar_url":"https://avatars2.githubusercontent.com/u/376343?v=3","gravatar_id":"","url":"https://api.github.com/users/remind101","html_url":"https://github.com/remind101","followers_url":"https://api.github.com/users/remind101/followers","following_url":"https://api.github.com/users/remind101/following{/other_user}","gists_url":"https://api.github.com/users/remind101/gists{/gist_id}","starred_url":"https://api.github.com/users/remind101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remind101/subscriptions","organizations_url":"https://api.github.com/users/remind101/orgs","repos_url":"https://api.github.com/users/remind101/repos","events_url":"https://api.github.com/users/remind101/events{/privacy}","received_events_url":"https://api.github.com/users/remind101/received_events","type":"Organization","site_admin":false},"repo":{"id":30091667,"name":"empire","full_name":"remind101/empire","owner":{"login":"remind101","id":376343,"avatar_url":"https://avatars2.githubusercontent.com/u/376343?v=3","gravatar_id":"","url":"https://api.github.com/users/remind101","html_url":"https://github.com/remind101","followers_url":"https://api.github.com/users/remind101/followers","following_url":"https://api.github.com/users/remind101/following{/other_user}","gists_url":"https://api.github.com/users/remind101/gists{/gist_id}","starred_url":"https://api.github.com/users/remind101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remind101/subscriptions","organizations_url":"https://api.github.com/users/remind101/orgs","repos_url":"https://api.github.com/users/remind101/repos","events_url":"https://api.github.com/users/remind101/events{/privacy}","received_events_url":"https://api.github.com/users/remind101/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/remind101/empire","description":"A PaaS built on top of Amazon EC2 Container Service (ECS)","fork":false,"url":"https://api.github.com/repos/remind101/empire","forks_url":"https://api.github.com/repos/remind101/empire/forks","keys_url":"https://api.github.com/repos/remind101/empire/keys{/key_id}","collaborators_url":"https://api.github.com/repos/remind101/empire/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/remind101/empire/teams","hooks_url":"https://api.github.com/repos/remind101/empire/hooks","issue_events_url":"https://api.github.com/repos/remind101/empire/issues/events{/number}","events_url":"https://api.github.com/repos/remind101/empire/events","assignees_url":"https://api.github.com/repos/remind101/empire/assignees{/user}","branches_url":"https://api.github.com/repos/remind101/empire/branches{/branch}","tags_url":"https://api.github.com/repos/remind101/empire/tags","blobs_url":"https://api.github.com/repos/remind101/empire/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/remind101/empire/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/remind101/empire/git/refs{/sha}","trees_url":"https://api.github.com/repos/remind101/empire/git/trees{/sha}","statuses_url":"https://api.github.com/repos/remind101/empire/statuses/{sha}","languages_url":"https://api.github.com/repos/remind101/empire/languages","stargazers_url":"https://api.github.com/repos/remind101/empire/stargazers","contributors_url":"https://api.github.com/repos/remind101/empire/contributors","subscribers_url":"https://api.github.com/repos/remind101/empire/subscribers","subscription_url":"https://api.github.com/repos/remind101/empire/subscription","commits_url":"https://api.github.com/repos/remind101/empire/commits{/sha}","git_commits_url":"https://api.github.com/repos/remind101/empire/git/commits{/sha}","comments_url":"https://api.github.com/repos/remind101/empire/comments{/number}","issue_comment_url":"https://api.github.com/repos/remind101/empire/issues/comments{/number}","contents_url":"https://api.github.com/repos/remind101/empire/contents/{+path}","compare_url":"https://api.github.com/repos/remind101/empire/compare/{base}...{head}","merges_url":"https://api.github.com/repos/remind101/empire/merges","archive_url":"https://api.github.com/repos/remind101/empire/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/remind101/empire/downloads","issues_url":"https://api.github.com/repos/remind101/empire/issues{/number}","pulls_url":"https://api.github.com/repos/remind101/empire/pulls{/number}","milestones_url":"https://api.github.com/repos/remind101/empire/milestones{/number}","notifications_url":"https://api.github.com/repos/remind101/empire/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/remind101/empire/labels{/name}","releases_url":"https://api.github.com/repos/remind101/empire/releases{/id}","deployments_url":"https://api.github.com/repos/remind101/empire/deployments","created_at":"2015-01-30T21:32:09Z","updated_at":"2017-03-09T08:34:56Z","pushed_at":"2017-03-10T01:11:00Z","git_url":"git://github.com/remind101/empire.git","ssh_url":"git@github.com:remind101/empire.git","clone_url":"https://github.com/remind101/empire.git","svn_url":"https://github.com/remind101/empire","homepage":"","size":21948,"stargazers_count":2082,"watchers_count":2082,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":103,"mirror_url":null,"open_issues_count":67,"forks":103,"open_issues":67,"watchers":2082,"default_branch":"master"}},"base":{"label":"remind101:master","ref":"master","sha":"59f8001f569d0478c863b13924c2f41039d0fe17","user":{"login":"remind101","id":376343,"avatar_url":"https://avatars2.githubusercontent.com/u/376343?v=3","gravatar_id":"","url":"https://api.github.com/users/remind101","html_url":"https://github.com/remind101","followers_url":"https://api.github.com/users/remind101/followers","following_url":"https://api.github.com/users/remind101/following{/other_user}","gists_url":"https://api.github.com/users/remind101/gists{/gist_id}","starred_url":"https://api.github.com/users/remind101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remind101/subscriptions","organizations_url":"https://api.github.com/users/remind101/orgs","repos_url":"https://api.github.com/users/remind101/repos","events_url":"https://api.github.com/users/remind101/events{/privacy}","received_events_url":"https://api.github.com/users/remind101/received_events","type":"Organization","site_admin":false},"repo":{"id":30091667,"name":"empire","full_name":"remind101/empire","owner":{"login":"remind101","id":376343,"avatar_url":"https://avatars2.githubusercontent.com/u/376343?v=3","gravatar_id":"","url":"https://api.github.com/users/remind101","html_url":"https://github.com/remind101","followers_url":"https://api.github.com/users/remind101/followers","following_url":"https://api.github.com/users/remind101/following{/other_user}","gists_url":"https://api.github.com/users/remind101/gists{/gist_id}","starred_url":"https://api.github.com/users/remind101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remind101/subscriptions","organizations_url":"https://api.github.com/users/remind101/orgs","repos_url":"https://api.github.com/users/remind101/repos","events_url":"https://api.github.com/users/remind101/events{/privacy}","received_events_url":"https://api.github.com/users/remind101/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/remind101/empire","description":"A PaaS built on top of Amazon EC2 Container Service (ECS)","fork":false,"url":"https://api.github.com/repos/remind101/empire","forks_url":"https://api.github.com/repos/remind101/empire/forks","keys_url":"https://api.github.com/repos/remind101/empire/keys{/key_id}","collaborators_url":"https://api.github.com/repos/remind101/empire/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/remind101/empire/teams","hooks_url":"https://api.github.com/repos/remind101/empire/hooks","issue_events_url":"https://api.github.com/repos/remind101/empire/issues/events{/number}","events_url":"https://api.github.com/repos/remind101/empire/events","assignees_url":"https://api.github.com/repos/remind101/empire/assignees{/user}","branches_url":"https://api.github.com/repos/remind101/empire/branches{/branch}","tags_url":"https://api.github.com/repos/remind101/empire/tags","blobs_url":"https://api.github.com/repos/remind101/empire/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/remind101/empire/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/remind101/empire/git/refs{/sha}","trees_url":"https://api.github.com/repos/remind101/empire/git/trees{/sha}","statuses_url":"https://api.github.com/repos/remind101/empire/statuses/{sha}","languages_url":"https://api.github.com/repos/remind101/empire/languages","stargazers_url":"https://api.github.com/repos/remind101/empire/stargazers","contributors_url":"https://api.github.com/repos/remind101/empire/contributors","subscribers_url":"https://api.github.com/repos/remind101/empire/subscribers","subscription_url":"https://api.github.com/repos/remind101/empire/subscription","commits_url":"https://api.github.com/repos/remind101/empire/commits{/sha}","git_commits_url":"https://api.github.com/repos/remind101/empire/git/commits{/sha}","comments_url":"https://api.github.com/repos/remind101/empire/comments{/number}","issue_comment_url":"https://api.github.com/repos/remind101/empire/issues/comments{/number}","contents_url":"https://api.github.com/repos/remind101/empire/contents/{+path}","compare_url":"https://api.github.com/repos/remind101/empire/compare/{base}...{head}","merges_url":"https://api.github.com/repos/remind101/empire/merges","archive_url":"https://api.github.com/repos/remind101/empire/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/remind101/empire/downloads","issues_url":"https://api.github.com/repos/remind101/empire/issues{/number}","pulls_url":"https://api.github.com/repos/remind101/empire/pulls{/number}","milestones_url":"https://api.github.com/repos/remind101/empire/milestones{/number}","notifications_url":"https://api.github.com/repos/remind101/empire/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/remind101/empire/labels{/name}","releases_url":"https://api.github.com/repos/remind101/empire/releases{/id}","deployments_url":"https://api.github.com/repos/remind101/empire/deployments","created_at":"2015-01-30T21:32:09Z","updated_at":"2017-03-09T08:34:56Z","pushed_at":"2017-03-10T01:11:00Z","git_url":"git://github.com/remind101/empire.git","ssh_url":"git@github.com:remind101/empire.git","clone_url":"https://github.com/remind101/empire.git","svn_url":"https://github.com/remind101/empire","homepage":"","size":21948,"stargazers_count":2082,"watchers_count":2082,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":103,"mirror_url":null,"open_issues_count":67,"forks":103,"open_issues":67,"watchers":2082,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/remind101/empire/pulls/1043"},"html":{"href":"https://github.com/remind101/empire/pull/1043"},"issue":{"href":"https://api.github.com/repos/remind101/empire/issues/1043"},"comments":{"href":"https://api.github.com/repos/remind101/empire/issues/1043/comments"},"review_comments":{"href":"https://api.github.com/repos/remind101/empire/pulls/1043/comments"},"review_comment":{"href":"https://api.github.com/repos/remind101/empire/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/remind101/empire/pulls/1043/commits"},"statuses":{"href":"https://api.github.com/repos/remind101/empire/statuses/1048ed4cd59907a32b80c4d99df39dc3fd4575ff"}}}}
{"actor":{"display_login":"ejholmes"}}