{"action":"created","comment":{"url":"https://api.github.com/repos/vmware/vic/pulls/comments/82706636","pull_request_review_id":3595483,"id":82706636,"diff_hunk":"@@ -368,6 +376,119 @@ func (c *ContainerProxy) createNewAttachClientWithTimeouts(connectTimeout, respo\n \treturn plClient, transport\n }\n \n+func (c *ContainerProxy) Resize(vc *viccontainer.VicContainer, height, width int32) error {\n+\tdefer trace.End(trace.Begin(vc.ContainerID))\n+\n+\tif c.client == nil {\n+\t\treturn derr.NewErrorWithStatusCode(fmt.Errorf(\"ContainerProxy failed to create a portlayer client\"),\n+\t\t\thttp.StatusInternalServerError)\n+\t}\n+\n+\tplResizeParam := interaction.NewContainerResizeParamsWithContext(ctx).\n+\t\tWithID(vc.ContainerID).\n+\t\tWithHeight(height).\n+\t\tWithWidth(width)\n+\n+\t_, err := c.client.Interaction.ContainerResize(plResizeParam)\n+\tif err != nil {\n+\t\tif _, isa := err.(*interaction.ContainerResizeNotFound); isa {\n+\t\t\tcache.ContainerCache().DeleteContainer(vc.ContainerID)\n+\t\t\treturn NotFoundError(vc.ContainerID)\n+\t\t}\n+\n+\t\t// If we get here, most likely something went wrong with the port layer API server\n+\t\treturn InternalServerError(err.Error())\n+\t}\n+\n+\treturn nil\n+}\n+\n+// attacheStreams takes the the hijacked connections from the calling client and attaches\n+// them to the 3 streams from the portlayer's rest server.\n+// clStdin, clStdout, clStderr are the hijacked connection\n+func (c *ContainerProxy) AttachStreams(ctx context.Context, vc *viccontainer.VicContainer, clStdin io.ReadCloser, clStdout, clStderr io.Writer, ca *backend.ContainerAttachConfig) error {\n+\tdefer clStdin.Close()\n+\n+\t// Cancel will close the child connections.\n+\tctx, cancel := context.WithCancel(ctx)\n+\n+\tvar wg sync.WaitGroup\n+\terrors := make(chan error, 3)\n+\n+\t// For stdin, we only have a timeout for connection.  There can be a long duration before\n+\t// the first entry so there is no timeout for response.\n+\tplClient, transport := createNewAttachClientWithTimeouts(attachConnectTimeout, 0, attachAttemptTimeout)\n+\tdefer transport.Close()\n+\n+\tif ca.UseStdin {\n+\t\twg.Add(1)\n+\t\tgo func() {\n+\t\t\tdefer wg.Done()\n+\t\t\terr := copyStdIn(ctx, plClient, vc, clStdin, ca.DetachKeys)\n+\t\t\tif err != nil {\n+\t\t\t\tlog.Errorf(\"container attach: stdin (%s): %s\", vc.ContainerID, err.Error())\n+\t\t\t} else {\n+\t\t\t\tlog.Infof(\"container attach: stdin (%s) done: %s\", vc.ContainerID)\n+\t\t\t}\n+\n+\t\t\tcancel()\n+\t\t\terrors <- err\n+\t\t}()\n+\t}\n+\n+\tif ca.UseStdout {\n+\t\twg.Add(1)\n+\t\tgo func() {\n+\t\t\tdefer wg.Done()\n+\t\t\terr := copyStdOut(ctx, plClient, attachAttemptTimeout, vc, clStdout)\n+\t\t\tif err != nil {\n+\t\t\t\tlog.Errorf(\"container attach: stdout (%s): %s\", vc.ContainerID, err.Error())\n+\t\t\t} else {\n+\t\t\t\tlog.Infof(\"container attach: stdout (%s) done: %s\", vc.ContainerID)\n+\t\t\t}\n+\n+\t\t\tcancel()\n+\t\t\terrors <- err\n+\t\t}()\n+\t}\n+\n+\tif ca.UseStderr {\n+\t\twg.Add(1)\n+\t\tgo func() {\n+\t\t\tdefer wg.Done()\n+\t\t\terr := copyStdErr(ctx, plClient, vc, clStderr)\n+\t\t\tif err != nil {\n+\t\t\t\tlog.Errorf(\"container attach: stderr (%s): %s\", vc.ContainerID, err.Error())\n+\t\t\t} else {\n+\t\t\t\tlog.Infof(\"container attach: stderr (%s) done: %s\", vc.ContainerID)\n+\t\t\t}\n+\n+\t\t\tcancel()\n+\t\t\terrors <- err\n+\t\t}()\n+\t}\n+\n+\t// Wait for all stream copy to exit\n+\twg.Wait()\n+\n+\tlog.Infof(\"container attach:  cleaned up connections to %s.\", vc.ContainerID)\n+\tfor err := range errors {\n+\t\tif err != nil {\n+\t\t\t// If we get here, most likely something went wrong with the port layer API server\n+\t\t\t// These errors originate within the go-swagger client itself.\n+\t\t\t// Go-swagger returns untyped errors to us if the error is not one that we define\n+\t\t\t// in the swagger spec.  Even EOF.  Therefore, we must scan the error string (if there\n+\t\t\t// is an error string in the untyped error) for the term EOF.\n+\n+\t\t\tlog.Errorf(\"container attach error: %s\", err.Error())","path":"lib/apiservers/engine/backends/container_proxy.go","position":156,"original_position":156,"commit_id":"b0e29406bd888985bafeb8b254e02ac3047a439d","original_commit_id":"b0e29406bd888985bafeb8b254e02ac3047a439d","user":{"login":"sflxn","id":1330508,"avatar_url":"https://avatars.githubusercontent.com/u/1330508?v=3","gravatar_id":"","url":"https://api.github.com/users/sflxn","html_url":"https://github.com/sflxn","followers_url":"https://api.github.com/users/sflxn/followers","following_url":"https://api.github.com/users/sflxn/following{/other_user}","gists_url":"https://api.github.com/users/sflxn/gists{/gist_id}","starred_url":"https://api.github.com/users/sflxn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sflxn/subscriptions","organizations_url":"https://api.github.com/users/sflxn/orgs","repos_url":"https://api.github.com/users/sflxn/repos","events_url":"https://api.github.com/users/sflxn/events{/privacy}","received_events_url":"https://api.github.com/users/sflxn/received_events","type":"User","site_admin":false},"body":"Good point.","created_at":"2016-10-11T00:25:22Z","updated_at":"2016-10-11T00:25:22Z","html_url":"https://github.com/vmware/vic/pull/2406#discussion_r82706636","pull_request_url":"https://api.github.com/repos/vmware/vic/pulls/2406","_links":{"self":{"href":"https://api.github.com/repos/vmware/vic/pulls/comments/82706636"},"html":{"href":"https://github.com/vmware/vic/pull/2406#discussion_r82706636"},"pull_request":{"href":"https://api.github.com/repos/vmware/vic/pulls/2406"}}},"pull_request":{"url":"https://api.github.com/repos/vmware/vic/pulls/2406","id":86077562,"html_url":"https://github.com/vmware/vic/pull/2406","diff_url":"https://github.com/vmware/vic/pull/2406.diff","patch_url":"https://github.com/vmware/vic/pull/2406.patch","issue_url":"https://api.github.com/repos/vmware/vic/issues/2406","number":2406,"state":"open","locked":false,"title":"Establish stdin connection immediately after attach","user":{"login":"sflxn","id":1330508,"avatar_url":"https://avatars.githubusercontent.com/u/1330508?v=3","gravatar_id":"","url":"https://api.github.com/users/sflxn","html_url":"https://github.com/sflxn","followers_url":"https://api.github.com/users/sflxn/followers","following_url":"https://api.github.com/users/sflxn/following{/other_user}","gists_url":"https://api.github.com/users/sflxn/gists{/gist_id}","starred_url":"https://api.github.com/users/sflxn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sflxn/subscriptions","organizations_url":"https://api.github.com/users/sflxn/orgs","repos_url":"https://api.github.com/users/sflxn/repos","events_url":"https://api.github.com/users/sflxn/events{/privacy}","received_events_url":"https://api.github.com/users/sflxn/received_events","type":"User","site_admin":false},"body":"Formerly, the attach performed a lazy connection between the personality\r\nand the portlayer servers for the stdin stream.  The reason is the\r\nSwagger client will not make the initial connection unless there is data\r\npresent in the ReaderCloser given to the client.  We force the connection\r\nby sending over an init byte sequence, which causes an immediate connection\r\nto the portlayer.  The interaction portlayer was updated to ignore the initial byte\r\nsequence.\r\n\r\nAlso, since I touched the attach code again, I went ahead and moved\r\nall the attach and resize swagger related code to the _proxy.go file.\r\n\r\nResolves #2353\r\n\r\n**NOTE!!!: A lot of this code is the moving swagger code for resize and attach over to the _proxy.go file.  The relevant code is in container_proxy.go:copyStdIn() and in interaction_handler.go.**","created_at":"2016-09-21T00:04:38Z","updated_at":"2016-10-11T00:25:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9554b5f30005acf33b98b6f562d34d5b9db4d94d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/vmware/vic/pulls/2406/commits","review_comments_url":"https://api.github.com/repos/vmware/vic/pulls/2406/comments","review_comment_url":"https://api.github.com/repos/vmware/vic/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vmware/vic/issues/2406/comments","statuses_url":"https://api.github.com/repos/vmware/vic/statuses/b0e29406bd888985bafeb8b254e02ac3047a439d","head":{"label":"sflxn:attach-stdin-changes","ref":"attach-stdin-changes","sha":"b0e29406bd888985bafeb8b254e02ac3047a439d","user":{"login":"sflxn","id":1330508,"avatar_url":"https://avatars.githubusercontent.com/u/1330508?v=3","gravatar_id":"","url":"https://api.github.com/users/sflxn","html_url":"https://github.com/sflxn","followers_url":"https://api.github.com/users/sflxn/followers","following_url":"https://api.github.com/users/sflxn/following{/other_user}","gists_url":"https://api.github.com/users/sflxn/gists{/gist_id}","starred_url":"https://api.github.com/users/sflxn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sflxn/subscriptions","organizations_url":"https://api.github.com/users/sflxn/orgs","repos_url":"https://api.github.com/users/sflxn/repos","events_url":"https://api.github.com/users/sflxn/events{/privacy}","received_events_url":"https://api.github.com/users/sflxn/received_events","type":"User","site_admin":false},"repo":{"id":55453338,"name":"vic","full_name":"sflxn/vic","owner":{"login":"sflxn","id":1330508,"avatar_url":"https://avatars.githubusercontent.com/u/1330508?v=3","gravatar_id":"","url":"https://api.github.com/users/sflxn","html_url":"https://github.com/sflxn","followers_url":"https://api.github.com/users/sflxn/followers","following_url":"https://api.github.com/users/sflxn/following{/other_user}","gists_url":"https://api.github.com/users/sflxn/gists{/gist_id}","starred_url":"https://api.github.com/users/sflxn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sflxn/subscriptions","organizations_url":"https://api.github.com/users/sflxn/orgs","repos_url":"https://api.github.com/users/sflxn/repos","events_url":"https://api.github.com/users/sflxn/events{/privacy}","received_events_url":"https://api.github.com/users/sflxn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sflxn/vic","description":"Integrated containers on vSphere","fork":true,"url":"https://api.github.com/repos/sflxn/vic","forks_url":"https://api.github.com/repos/sflxn/vic/forks","keys_url":"https://api.github.com/repos/sflxn/vic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sflxn/vic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sflxn/vic/teams","hooks_url":"https://api.github.com/repos/sflxn/vic/hooks","issue_events_url":"https://api.github.com/repos/sflxn/vic/issues/events{/number}","events_url":"https://api.github.com/repos/sflxn/vic/events","assignees_url":"https://api.github.com/repos/sflxn/vic/assignees{/user}","branches_url":"https://api.github.com/repos/sflxn/vic/branches{/branch}","tags_url":"https://api.github.com/repos/sflxn/vic/tags","blobs_url":"https://api.github.com/repos/sflxn/vic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sflxn/vic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sflxn/vic/git/refs{/sha}","trees_url":"https://api.github.com/repos/sflxn/vic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sflxn/vic/statuses/{sha}","languages_url":"https://api.github.com/repos/sflxn/vic/languages","stargazers_url":"https://api.github.com/repos/sflxn/vic/stargazers","contributors_url":"https://api.github.com/repos/sflxn/vic/contributors","subscribers_url":"https://api.github.com/repos/sflxn/vic/subscribers","subscription_url":"https://api.github.com/repos/sflxn/vic/subscription","commits_url":"https://api.github.com/repos/sflxn/vic/commits{/sha}","git_commits_url":"https://api.github.com/repos/sflxn/vic/git/commits{/sha}","comments_url":"https://api.github.com/repos/sflxn/vic/comments{/number}","issue_comment_url":"https://api.github.com/repos/sflxn/vic/issues/comments{/number}","contents_url":"https://api.github.com/repos/sflxn/vic/contents/{+path}","compare_url":"https://api.github.com/repos/sflxn/vic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sflxn/vic/merges","archive_url":"https://api.github.com/repos/sflxn/vic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sflxn/vic/downloads","issues_url":"https://api.github.com/repos/sflxn/vic/issues{/number}","pulls_url":"https://api.github.com/repos/sflxn/vic/pulls{/number}","milestones_url":"https://api.github.com/repos/sflxn/vic/milestones{/number}","notifications_url":"https://api.github.com/repos/sflxn/vic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sflxn/vic/labels{/name}","releases_url":"https://api.github.com/repos/sflxn/vic/releases{/id}","deployments_url":"https://api.github.com/repos/sflxn/vic/deployments","created_at":"2016-04-04T23:42:42Z","updated_at":"2016-04-04T23:42:44Z","pushed_at":"2016-10-10T21:36:46Z","git_url":"git://github.com/sflxn/vic.git","ssh_url":"git@github.com:sflxn/vic.git","clone_url":"https://github.com/sflxn/vic.git","svn_url":"https://github.com/sflxn/vic","homepage":null,"size":29870,"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":"vmware:master","ref":"master","sha":"8c0104af8d6b1d2809907d98dd2c3ff3d9edfb20","user":{"login":"vmware","id":473334,"avatar_url":"https://avatars.githubusercontent.com/u/473334?v=3","gravatar_id":"","url":"https://api.github.com/users/vmware","html_url":"https://github.com/vmware","followers_url":"https://api.github.com/users/vmware/followers","following_url":"https://api.github.com/users/vmware/following{/other_user}","gists_url":"https://api.github.com/users/vmware/gists{/gist_id}","starred_url":"https://api.github.com/users/vmware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmware/subscriptions","organizations_url":"https://api.github.com/users/vmware/orgs","repos_url":"https://api.github.com/users/vmware/repos","events_url":"https://api.github.com/users/vmware/events{/privacy}","received_events_url":"https://api.github.com/users/vmware/received_events","type":"Organization","site_admin":false},"repo":{"id":49597898,"name":"vic","full_name":"vmware/vic","owner":{"login":"vmware","id":473334,"avatar_url":"https://avatars.githubusercontent.com/u/473334?v=3","gravatar_id":"","url":"https://api.github.com/users/vmware","html_url":"https://github.com/vmware","followers_url":"https://api.github.com/users/vmware/followers","following_url":"https://api.github.com/users/vmware/following{/other_user}","gists_url":"https://api.github.com/users/vmware/gists{/gist_id}","starred_url":"https://api.github.com/users/vmware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmware/subscriptions","organizations_url":"https://api.github.com/users/vmware/orgs","repos_url":"https://api.github.com/users/vmware/repos","events_url":"https://api.github.com/users/vmware/events{/privacy}","received_events_url":"https://api.github.com/users/vmware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vmware/vic","description":"Integrated containers engine on vSphere","fork":false,"url":"https://api.github.com/repos/vmware/vic","forks_url":"https://api.github.com/repos/vmware/vic/forks","keys_url":"https://api.github.com/repos/vmware/vic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vmware/vic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vmware/vic/teams","hooks_url":"https://api.github.com/repos/vmware/vic/hooks","issue_events_url":"https://api.github.com/repos/vmware/vic/issues/events{/number}","events_url":"https://api.github.com/repos/vmware/vic/events","assignees_url":"https://api.github.com/repos/vmware/vic/assignees{/user}","branches_url":"https://api.github.com/repos/vmware/vic/branches{/branch}","tags_url":"https://api.github.com/repos/vmware/vic/tags","blobs_url":"https://api.github.com/repos/vmware/vic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vmware/vic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vmware/vic/git/refs{/sha}","trees_url":"https://api.github.com/repos/vmware/vic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vmware/vic/statuses/{sha}","languages_url":"https://api.github.com/repos/vmware/vic/languages","stargazers_url":"https://api.github.com/repos/vmware/vic/stargazers","contributors_url":"https://api.github.com/repos/vmware/vic/contributors","subscribers_url":"https://api.github.com/repos/vmware/vic/subscribers","subscription_url":"https://api.github.com/repos/vmware/vic/subscription","commits_url":"https://api.github.com/repos/vmware/vic/commits{/sha}","git_commits_url":"https://api.github.com/repos/vmware/vic/git/commits{/sha}","comments_url":"https://api.github.com/repos/vmware/vic/comments{/number}","issue_comment_url":"https://api.github.com/repos/vmware/vic/issues/comments{/number}","contents_url":"https://api.github.com/repos/vmware/vic/contents/{+path}","compare_url":"https://api.github.com/repos/vmware/vic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vmware/vic/merges","archive_url":"https://api.github.com/repos/vmware/vic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vmware/vic/downloads","issues_url":"https://api.github.com/repos/vmware/vic/issues{/number}","pulls_url":"https://api.github.com/repos/vmware/vic/pulls{/number}","milestones_url":"https://api.github.com/repos/vmware/vic/milestones{/number}","notifications_url":"https://api.github.com/repos/vmware/vic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vmware/vic/labels{/name}","releases_url":"https://api.github.com/repos/vmware/vic/releases{/id}","deployments_url":"https://api.github.com/repos/vmware/vic/deployments","created_at":"2016-01-13T19:53:57Z","updated_at":"2016-10-10T03:44:55Z","pushed_at":"2016-10-11T00:11:54Z","git_url":"git://github.com/vmware/vic.git","ssh_url":"git@github.com:vmware/vic.git","clone_url":"https://github.com/vmware/vic.git","svn_url":"https://github.com/vmware/vic","homepage":"","size":81426,"stargazers_count":139,"watchers_count":139,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":53,"mirror_url":null,"open_issues_count":466,"forks":53,"open_issues":466,"watchers":139,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vmware/vic/pulls/2406"},"html":{"href":"https://github.com/vmware/vic/pull/2406"},"issue":{"href":"https://api.github.com/repos/vmware/vic/issues/2406"},"comments":{"href":"https://api.github.com/repos/vmware/vic/issues/2406/comments"},"review_comments":{"href":"https://api.github.com/repos/vmware/vic/pulls/2406/comments"},"review_comment":{"href":"https://api.github.com/repos/vmware/vic/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vmware/vic/pulls/2406/commits"},"statuses":{"href":"https://api.github.com/repos/vmware/vic/statuses/b0e29406bd888985bafeb8b254e02ac3047a439d"}}}}
{"actor":{"display_login":"sflxn"}}