{"action":"created","comment":{"url":"https://api.github.com/repos/containerd/containerd/pulls/comments/221741360","pull_request_review_id":160465960,"id":221741360,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMTc0MTM2MA==","diff_hunk":"@@ -119,21 +124,100 @@ func handleSignals(logger *logrus.Entry, signals chan os.Signal) error {\n \t}\n }\n \n+// deferredShimWriteLogger exists to solve the upstream loggin issue presented\n+// by using Windows Named Pipes for logging. When containerd restarts it tries\n+// to reconnect to any shims. This means that the connection to the logger will\n+// be severed but when containerd starts up it should reconnect and start\n+// logging again. We abstract all of this logic behind what looks like a simple\n+// `io.Writer` that can reconnect in the liftime and buffers logs while\n+// disconnected.\n type deferredShimWriteLogger struct {\n+\tmu sync.Mutex\n+\n \tctx context.Context\n \n-\twg sync.WaitGroup\n+\tconnected bool\n+\taborted   bool\n+\n+\tbuffer bytes.Buffer\n \n+\tl      net.Listener\n \tc      net.Conn\n \tconerr error\n }\n \n+// beginAccept issues an accept to wait for a connection. Once a conneciton\n+// occurs drains any outstanding buffer. While draining the buffer any writes\n+// are blocked. If the buffer fails to fully drain due to a connection drop a\n+// call to `beginAccept` is re-issued waiting for another connection from\n+// containerd.\n+func (dswl *deferredShimWriteLogger) beginAccept() {\n+\tdswl.mu.Lock()\n+\tif dswl.connected {\n+\t\treturn\n+\t}\n+\tdswl.mu.Unlock()\n+\n+\tc, err := dswl.l.Accept()\n+\tif err == errorConnectionAborted {\n+\t\tdswl.mu.Lock()\n+\t\tdswl.aborted = true\n+\t\tdswl.l.Close()\n+\t\tdswl.conerr = errors.New(\"connection closed\")\n+\t\tdswl.mu.Unlock()\n+\t\treturn\n+\t}\n+\tdswl.mu.Lock()\n+\tdswl.connected = true\n+\tdswl.c = c\n+\n+\t// Drain the buffer\n+\tif dswl.buffer.Len() > 0 {\n+\t\t_, err := dswl.buffer.WriteTo(dswl.c)\n+\t\tif err != nil {\n+\t\t\t// We lost our connection draining the buffer.\n+\t\t\tdswl.connected = false\n+\t\t\tdswl.c.Close()\n+\t\t\tgo dswl.beginAccept()\n+\t\t}\n+\t}\n+\tdswl.mu.Unlock()\n+}\n+\n func (dswl *deferredShimWriteLogger) Write(p []byte) (int, error) {\n-\tdswl.wg.Wait()\n-\tif dswl.c == nil {\n+\tdswl.mu.Lock()\n+\tdefer dswl.mu.Unlock()\n+\n+\tif dswl.aborted {\n \t\treturn 0, dswl.conerr\n \t}\n-\treturn dswl.c.Write(p)\n+\n+\tif dswl.connected {\n+\t\t// We have a connection. beginAccept would of drained the buffer so we just write our data to\n+\t\t// the connection directly.\n+\t\twritten, err := dswl.c.Write(p)\n+\t\tif err != nil {\n+\t\t\t// We lost the connection.\n+\t\t\tdswl.connected = false\n+\t\t\tdswl.c.Close()\n+\t\t\tgo dswl.beginAccept()\n+\n+\t\t\t// We weren't able to write the full `p` bytes. Buffer the rest\n+\t\t\tif written != len(p) {\n+\t\t\t\tw, err := dswl.buffer.Write(p[written:])\n+\t\t\t\tif err != nil {\n+\t\t\t\t\t// We failed to buffer. Return this error\n+\t\t\t\t\treturn written + w, err\n+\t\t\t\t}\n+\t\t\t\twritten += w\n+\t\t\t}\n+\t\t}\n+\n+\t\treturn written, nil\n+\t}\n+\n+\t// We are disconnected. Buffer the contents.\n+\treturn dswl.buffer.Write(p)","path":"runtime/v2/shim/shim_windows.go","position":166,"original_position":120,"commit_id":"cc2bbb17b26049ffe1078a3f5b3c9a3d0e026d03","original_commit_id":"61dbc5a984e11cb5b1080f02e84e8535dd9ced02","user":{"login":"mlaventure","id":16065150,"node_id":"MDQ6VXNlcjE2MDY1MTUw","avatar_url":"https://avatars1.githubusercontent.com/u/16065150?v=4","gravatar_id":"","url":"https://api.github.com/users/mlaventure","html_url":"https://github.com/mlaventure","followers_url":"https://api.github.com/users/mlaventure/followers","following_url":"https://api.github.com/users/mlaventure/following{/other_user}","gists_url":"https://api.github.com/users/mlaventure/gists{/gist_id}","starred_url":"https://api.github.com/users/mlaventure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlaventure/subscriptions","organizations_url":"https://api.github.com/users/mlaventure/orgs","repos_url":"https://api.github.com/users/mlaventure/repos","events_url":"https://api.github.com/users/mlaventure/events{/privacy}","received_events_url":"https://api.github.com/users/mlaventure/received_events","type":"User","site_admin":false},"body":"It seems to cause a data race atm.","created_at":"2018-10-01T20:13:41Z","updated_at":"2018-10-01T20:13:42Z","html_url":"https://github.com/containerd/containerd/pull/2692#discussion_r221741360","pull_request_url":"https://api.github.com/repos/containerd/containerd/pulls/2692","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/containerd/containerd/pulls/comments/221741360"},"html":{"href":"https://github.com/containerd/containerd/pull/2692#discussion_r221741360"},"pull_request":{"href":"https://api.github.com/repos/containerd/containerd/pulls/2692"}},"in_reply_to_id":221639867},"pull_request":{"url":"https://api.github.com/repos/containerd/containerd/pulls/2692","id":219096620,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE5MDk2NjIw","html_url":"https://github.com/containerd/containerd/pull/2692","diff_url":"https://github.com/containerd/containerd/pull/2692.diff","patch_url":"https://github.com/containerd/containerd/pull/2692.patch","issue_url":"https://api.github.com/repos/containerd/containerd/issues/2692","number":2692,"state":"open","locked":false,"title":"Various runhcs shim fixes","user":{"login":"jterry75","id":5858142,"node_id":"MDQ6VXNlcjU4NTgxNDI=","avatar_url":"https://avatars1.githubusercontent.com/u/5858142?v=4","gravatar_id":"","url":"https://api.github.com/users/jterry75","html_url":"https://github.com/jterry75","followers_url":"https://api.github.com/users/jterry75/followers","following_url":"https://api.github.com/users/jterry75/following{/other_user}","gists_url":"https://api.github.com/users/jterry75/gists{/gist_id}","starred_url":"https://api.github.com/users/jterry75/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jterry75/subscriptions","organizations_url":"https://api.github.com/users/jterry75/orgs","repos_url":"https://api.github.com/users/jterry75/repos","events_url":"https://api.github.com/users/jterry75/events{/privacy}","received_events_url":"https://api.github.com/users/jterry75/received_events","type":"User","site_admin":false},"body":"- Adds Windows shim reconnect logs support\r\n- Decrease shim timeout on pipe not found\r\nOn Windows because of the way the log pipe is forwarded to the shim there is a\r\ncondition where the pipe listener may not yet be active when a client tries to\r\nconnect. To handle this case we allow polling on the file and retry on pipe not\r\nfound. This limits the pipe not found retry to 5 seconds but leaves the connect\r\ntimeout alone as if there is a listener we want to connect to it normally.\r\n- Handle shim delete workdir on Windows","created_at":"2018-09-28T22:03:40Z","updated_at":"2018-10-01T20:13:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a0c4479d7872fdffa87f1feddf22e2a1fc2d2cb4","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/containerd/containerd/pulls/2692/commits","review_comments_url":"https://api.github.com/repos/containerd/containerd/pulls/2692/comments","review_comment_url":"https://api.github.com/repos/containerd/containerd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/containerd/containerd/issues/2692/comments","statuses_url":"https://api.github.com/repos/containerd/containerd/statuses/cc2bbb17b26049ffe1078a3f5b3c9a3d0e026d03","head":{"label":"jterry75:shim_reconnect","ref":"shim_reconnect","sha":"cc2bbb17b26049ffe1078a3f5b3c9a3d0e026d03","user":{"login":"jterry75","id":5858142,"node_id":"MDQ6VXNlcjU4NTgxNDI=","avatar_url":"https://avatars1.githubusercontent.com/u/5858142?v=4","gravatar_id":"","url":"https://api.github.com/users/jterry75","html_url":"https://github.com/jterry75","followers_url":"https://api.github.com/users/jterry75/followers","following_url":"https://api.github.com/users/jterry75/following{/other_user}","gists_url":"https://api.github.com/users/jterry75/gists{/gist_id}","starred_url":"https://api.github.com/users/jterry75/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jterry75/subscriptions","organizations_url":"https://api.github.com/users/jterry75/orgs","repos_url":"https://api.github.com/users/jterry75/repos","events_url":"https://api.github.com/users/jterry75/events{/privacy}","received_events_url":"https://api.github.com/users/jterry75/received_events","type":"User","site_admin":false},"repo":{"id":137511785,"node_id":"MDEwOlJlcG9zaXRvcnkxMzc1MTE3ODU=","name":"containerd","full_name":"jterry75/containerd","private":false,"owner":{"login":"jterry75","id":5858142,"node_id":"MDQ6VXNlcjU4NTgxNDI=","avatar_url":"https://avatars1.githubusercontent.com/u/5858142?v=4","gravatar_id":"","url":"https://api.github.com/users/jterry75","html_url":"https://github.com/jterry75","followers_url":"https://api.github.com/users/jterry75/followers","following_url":"https://api.github.com/users/jterry75/following{/other_user}","gists_url":"https://api.github.com/users/jterry75/gists{/gist_id}","starred_url":"https://api.github.com/users/jterry75/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jterry75/subscriptions","organizations_url":"https://api.github.com/users/jterry75/orgs","repos_url":"https://api.github.com/users/jterry75/repos","events_url":"https://api.github.com/users/jterry75/events{/privacy}","received_events_url":"https://api.github.com/users/jterry75/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jterry75/containerd","description":"An open and reliable container runtime","fork":true,"url":"https://api.github.com/repos/jterry75/containerd","forks_url":"https://api.github.com/repos/jterry75/containerd/forks","keys_url":"https://api.github.com/repos/jterry75/containerd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jterry75/containerd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jterry75/containerd/teams","hooks_url":"https://api.github.com/repos/jterry75/containerd/hooks","issue_events_url":"https://api.github.com/repos/jterry75/containerd/issues/events{/number}","events_url":"https://api.github.com/repos/jterry75/containerd/events","assignees_url":"https://api.github.com/repos/jterry75/containerd/assignees{/user}","branches_url":"https://api.github.com/repos/jterry75/containerd/branches{/branch}","tags_url":"https://api.github.com/repos/jterry75/containerd/tags","blobs_url":"https://api.github.com/repos/jterry75/containerd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jterry75/containerd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jterry75/containerd/git/refs{/sha}","trees_url":"https://api.github.com/repos/jterry75/containerd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jterry75/containerd/statuses/{sha}","languages_url":"https://api.github.com/repos/jterry75/containerd/languages","stargazers_url":"https://api.github.com/repos/jterry75/containerd/stargazers","contributors_url":"https://api.github.com/repos/jterry75/containerd/contributors","subscribers_url":"https://api.github.com/repos/jterry75/containerd/subscribers","subscription_url":"https://api.github.com/repos/jterry75/containerd/subscription","commits_url":"https://api.github.com/repos/jterry75/containerd/commits{/sha}","git_commits_url":"https://api.github.com/repos/jterry75/containerd/git/commits{/sha}","comments_url":"https://api.github.com/repos/jterry75/containerd/comments{/number}","issue_comment_url":"https://api.github.com/repos/jterry75/containerd/issues/comments{/number}","contents_url":"https://api.github.com/repos/jterry75/containerd/contents/{+path}","compare_url":"https://api.github.com/repos/jterry75/containerd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jterry75/containerd/merges","archive_url":"https://api.github.com/repos/jterry75/containerd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jterry75/containerd/downloads","issues_url":"https://api.github.com/repos/jterry75/containerd/issues{/number}","pulls_url":"https://api.github.com/repos/jterry75/containerd/pulls{/number}","milestones_url":"https://api.github.com/repos/jterry75/containerd/milestones{/number}","notifications_url":"https://api.github.com/repos/jterry75/containerd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jterry75/containerd/labels{/name}","releases_url":"https://api.github.com/repos/jterry75/containerd/releases{/id}","deployments_url":"https://api.github.com/repos/jterry75/containerd/deployments","created_at":"2018-06-15T16:49:38Z","updated_at":"2018-09-28T23:02:44Z","pushed_at":"2018-10-01T19:38:50Z","git_url":"git://github.com/jterry75/containerd.git","ssh_url":"git@github.com:jterry75/containerd.git","clone_url":"https://github.com/jterry75/containerd.git","svn_url":"https://github.com/jterry75/containerd","homepage":"https://containerd.io","size":44339,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"containerd:master","ref":"master","sha":"ac01f20a8e6a1ff67a74e16783463c187a40b7c4","user":{"login":"containerd","id":14037953,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MDM3OTUz","avatar_url":"https://avatars1.githubusercontent.com/u/14037953?v=4","gravatar_id":"","url":"https://api.github.com/users/containerd","html_url":"https://github.com/containerd","followers_url":"https://api.github.com/users/containerd/followers","following_url":"https://api.github.com/users/containerd/following{/other_user}","gists_url":"https://api.github.com/users/containerd/gists{/gist_id}","starred_url":"https://api.github.com/users/containerd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/containerd/subscriptions","organizations_url":"https://api.github.com/users/containerd/orgs","repos_url":"https://api.github.com/users/containerd/repos","events_url":"https://api.github.com/users/containerd/events{/privacy}","received_events_url":"https://api.github.com/users/containerd/received_events","type":"Organization","site_admin":false},"repo":{"id":46089560,"node_id":"MDEwOlJlcG9zaXRvcnk0NjA4OTU2MA==","name":"containerd","full_name":"containerd/containerd","private":false,"owner":{"login":"containerd","id":14037953,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MDM3OTUz","avatar_url":"https://avatars1.githubusercontent.com/u/14037953?v=4","gravatar_id":"","url":"https://api.github.com/users/containerd","html_url":"https://github.com/containerd","followers_url":"https://api.github.com/users/containerd/followers","following_url":"https://api.github.com/users/containerd/following{/other_user}","gists_url":"https://api.github.com/users/containerd/gists{/gist_id}","starred_url":"https://api.github.com/users/containerd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/containerd/subscriptions","organizations_url":"https://api.github.com/users/containerd/orgs","repos_url":"https://api.github.com/users/containerd/repos","events_url":"https://api.github.com/users/containerd/events{/privacy}","received_events_url":"https://api.github.com/users/containerd/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/containerd/containerd","description":"An open and reliable container runtime","fork":false,"url":"https://api.github.com/repos/containerd/containerd","forks_url":"https://api.github.com/repos/containerd/containerd/forks","keys_url":"https://api.github.com/repos/containerd/containerd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/containerd/containerd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/containerd/containerd/teams","hooks_url":"https://api.github.com/repos/containerd/containerd/hooks","issue_events_url":"https://api.github.com/repos/containerd/containerd/issues/events{/number}","events_url":"https://api.github.com/repos/containerd/containerd/events","assignees_url":"https://api.github.com/repos/containerd/containerd/assignees{/user}","branches_url":"https://api.github.com/repos/containerd/containerd/branches{/branch}","tags_url":"https://api.github.com/repos/containerd/containerd/tags","blobs_url":"https://api.github.com/repos/containerd/containerd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/containerd/containerd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/containerd/containerd/git/refs{/sha}","trees_url":"https://api.github.com/repos/containerd/containerd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/containerd/containerd/statuses/{sha}","languages_url":"https://api.github.com/repos/containerd/containerd/languages","stargazers_url":"https://api.github.com/repos/containerd/containerd/stargazers","contributors_url":"https://api.github.com/repos/containerd/containerd/contributors","subscribers_url":"https://api.github.com/repos/containerd/containerd/subscribers","subscription_url":"https://api.github.com/repos/containerd/containerd/subscription","commits_url":"https://api.github.com/repos/containerd/containerd/commits{/sha}","git_commits_url":"https://api.github.com/repos/containerd/containerd/git/commits{/sha}","comments_url":"https://api.github.com/repos/containerd/containerd/comments{/number}","issue_comment_url":"https://api.github.com/repos/containerd/containerd/issues/comments{/number}","contents_url":"https://api.github.com/repos/containerd/containerd/contents/{+path}","compare_url":"https://api.github.com/repos/containerd/containerd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/containerd/containerd/merges","archive_url":"https://api.github.com/repos/containerd/containerd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/containerd/containerd/downloads","issues_url":"https://api.github.com/repos/containerd/containerd/issues{/number}","pulls_url":"https://api.github.com/repos/containerd/containerd/pulls{/number}","milestones_url":"https://api.github.com/repos/containerd/containerd/milestones{/number}","notifications_url":"https://api.github.com/repos/containerd/containerd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/containerd/containerd/labels{/name}","releases_url":"https://api.github.com/repos/containerd/containerd/releases{/id}","deployments_url":"https://api.github.com/repos/containerd/containerd/deployments","created_at":"2015-11-13T00:27:43Z","updated_at":"2018-10-01T03:53:58Z","pushed_at":"2018-10-01T19:38:51Z","git_url":"git://github.com/containerd/containerd.git","ssh_url":"git@github.com:containerd/containerd.git","clone_url":"https://github.com/containerd/containerd.git","svn_url":"https://github.com/containerd/containerd","homepage":"https://containerd.io","size":44709,"stargazers_count":2965,"watchers_count":2965,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":604,"mirror_url":null,"archived":false,"open_issues_count":119,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":604,"open_issues":119,"watchers":2965,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/containerd/containerd/pulls/2692"},"html":{"href":"https://github.com/containerd/containerd/pull/2692"},"issue":{"href":"https://api.github.com/repos/containerd/containerd/issues/2692"},"comments":{"href":"https://api.github.com/repos/containerd/containerd/issues/2692/comments"},"review_comments":{"href":"https://api.github.com/repos/containerd/containerd/pulls/2692/comments"},"review_comment":{"href":"https://api.github.com/repos/containerd/containerd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/containerd/containerd/pulls/2692/commits"},"statuses":{"href":"https://api.github.com/repos/containerd/containerd/statuses/cc2bbb17b26049ffe1078a3f5b3c9a3d0e026d03"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"mlaventure"}}