{"action":"created","comment":{"url":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/comments/176269047","pull_request_review_id":105941611,"id":176269047,"diff_hunk":"@@ -230,15 +223,51 @@ func (cs *ClientServerImpl) IsReady() bool {\n \n // SetConnection passes a websocket connection object into the client. This is used only in\n // testing and should be avoided in non-test code.\n-func (cs *ClientServerImpl) SetConnection(conn WebsocketConn) {\n+func (cs *ClientServerImpl) SetConnection(conn wsconn.WebsocketConn) {\n \tcs.conn = conn\n }\n \n // SetReadDeadline sets the read deadline for the websocket connection\n // A read timeout results in an io error if there are any outstanding reads\n // that exceed the deadline\n func (cs *ClientServerImpl) SetReadDeadline(t time.Time) error {\n-\treturn cs.conn.SetReadDeadline(t)\n+\terr := cs.conn.SetReadDeadline(t)\n+\tif err == nil {\n+\t\treturn nil\n+\t}\n+\tseelog.Warnf(\"Unable to set read deadline for websocket connection: %v for %s\", err, cs.URL)\n+\t// If we get connection closed error from SetReadDeadline, break out of the for loop and\n+\t// return an error\n+\tif opErr, ok := err.(*net.OpError); ok && strings.Contains(opErr.Err.Error(), errClosed) {\n+\t\tseelog.Errorf(\"Stopping redundant reads on closed network connection: %s\", cs.URL)\n+\t\treturn opErr\n+\t}\n+\t// An unhandled error has occurred while trying to extend read deadline.\n+\t// Try asynchronously closing the connection. We don't want to be blocked on stale connections\n+\t// taking too long to close. The flip side is that we might start accumulating stale connections.","path":"agent/wsclient/client.go","position":105,"original_position":105,"commit_id":"8d11bdbe64440e7fb435f20eb9001dd4d5d02afd","original_commit_id":"58b68d26ed4770f5754340c204a821331788dd58","user":{"login":"tehshwann","id":32145118,"avatar_url":"https://avatars3.githubusercontent.com/u/32145118?v=4","gravatar_id":"","url":"https://api.github.com/users/tehshwann","html_url":"https://github.com/tehshwann","followers_url":"https://api.github.com/users/tehshwann/followers","following_url":"https://api.github.com/users/tehshwann/following{/other_user}","gists_url":"https://api.github.com/users/tehshwann/gists{/gist_id}","starred_url":"https://api.github.com/users/tehshwann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tehshwann/subscriptions","organizations_url":"https://api.github.com/users/tehshwann/orgs","repos_url":"https://api.github.com/users/tehshwann/repos","events_url":"https://api.github.com/users/tehshwann/events{/privacy}","received_events_url":"https://api.github.com/users/tehshwann/received_events","type":"User","site_admin":false},"body":"How do we know that? Do we have a test that ensures that the expected behavior happens when we hit the limit?","created_at":"2018-03-21T23:17:17Z","updated_at":"2018-03-21T23:31:32Z","html_url":"https://github.com/aws/amazon-ecs-agent/pull/1310#discussion_r176269047","pull_request_url":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/1310","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/comments/176269047"},"html":{"href":"https://github.com/aws/amazon-ecs-agent/pull/1310#discussion_r176269047"},"pull_request":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/1310"}},"in_reply_to_id":176151528},"pull_request":{"url":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/1310","id":176510814,"html_url":"https://github.com/aws/amazon-ecs-agent/pull/1310","diff_url":"https://github.com/aws/amazon-ecs-agent/pull/1310.diff","patch_url":"https://github.com/aws/amazon-ecs-agent/pull/1310.patch","issue_url":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/1310","number":1310,"state":"closed","locked":false,"title":"Handle SetReadDeadline error for websocket connections (#1292)","user":{"login":"aaithal","id":1183359,"avatar_url":"https://avatars1.githubusercontent.com/u/1183359?v=4","gravatar_id":"","url":"https://api.github.com/users/aaithal","html_url":"https://github.com/aaithal","followers_url":"https://api.github.com/users/aaithal/followers","following_url":"https://api.github.com/users/aaithal/following{/other_user}","gists_url":"https://api.github.com/users/aaithal/gists{/gist_id}","starred_url":"https://api.github.com/users/aaithal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaithal/subscriptions","organizations_url":"https://api.github.com/users/aaithal/orgs","repos_url":"https://api.github.com/users/aaithal/repos","events_url":"https://api.github.com/users/aaithal/events{/privacy}","received_events_url":"https://api.github.com/users/aaithal/received_events","type":"User","site_admin":false},"body":"<!--\r\nPlease make sure you've read and understood our contributing guidelines;\r\nhttps://github.com/aws/amazon-ecs-agent/blob/master/CONTRIBUTING.md\r\n\r\nPlease provide the following information:\r\n-->\r\n\r\n### Summary\r\nAdded error handling for `SetReadDeadline()`. This should take care or scenarios where stale websocket connections linger (#1292)\r\n\r\n### Implementation details\r\n<!-- How are the changes implemented? -->\r\n1. Forcefully terminate connection if there's any error with the\r\n    SetReadDeadline() call. Not doing this leads to unpredictable behavior\r\n    with stale websocket connections.\r\n\r\n    Since SetWriteDeadline always returns `nil`, errors from that are not\r\n    handled.\r\n\r\n2. Move WebsocketConn to its own package. This allows us to mock it\r\n    out in the \"wsclient\" package and write unit tests on it.\r\n\r\n### Testing\r\n<!-- How was this tested? -->\r\n<!--\r\nNote for external contributors:\r\n`make test` and `make run-integ-tests` can run in a Linux development\r\nenvironment like your laptop.  `go test -timeout=25s ./agent/...` and\r\n`.\\scripts\\run-integ.tests.ps1` can run in a Windows development environment\r\nlike your laptop.  Please ensure unit and integration tests pass (on at least\r\none platform) before opening the pull request.  `make run-functional-tests` and\r\n`.\\scripts\\run-functional-tests.ps1` must be run on an EC2 instance with an\r\ninstance profile allowing it access to AWS resources.  Running\r\n`make run-functional-tests` and `.\\scripts\\run-functional-tests.ps1` may incur\r\ncharges to your AWS account; if you're unable or unwilling to run these tests\r\nin your own account, we can run the tests and provide test results.\r\n-->\r\n- [x] Builds on Linux (`make release`)\r\n- [x] Builds on Windows (`go build -out amazon-ecs-agent.exe ./agent`)\r\n- [x] Unit tests on Linux (`make test`) pass\r\n- [x] Unit tests on Windows (`go test -timeout=25s ./agent/...`) pass\r\n- [x] Integration tests on Linux (`make run-integ-tests`) pass\r\n- [x] Integration tests on Windows (`.\\scripts\\run-integ-tests.ps1`) pass\r\n- [x] Functional tests on Linux (`make run-functional-tests`) pass\r\n- [x] Functional tests on Windows (`.\\scripts\\run-functional-tests.ps1`) pass\r\n\r\nNew tests cover the changes: Yes\r\n\r\n### Description for the changelog\r\n<!--\r\nWrite a short (one line) summary that describes the changes in this\r\npull request for inclusion in the changelog.\r\nYou can see our changelog entry style here:\r\nhttps://github.com/aws/amazon-ecs-agent/commit/c9aefebc2b3007f09468f651f6308136bd7b384f\r\n-->\r\n\r\n### Licensing\r\n\r\nBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.\r\n","created_at":"2018-03-21T15:19:40Z","updated_at":"2018-03-21T23:31:32Z","closed_at":"2018-03-21T23:30:11Z","merged_at":"2018-03-21T23:30:11Z","merge_commit_sha":"3f2fecc0bbe74b4064677b2ec72e182915d38d8f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":{"url":"https://api.github.com/repos/aws/amazon-ecs-agent/milestones/23","html_url":"https://github.com/aws/amazon-ecs-agent/milestone/23","labels_url":"https://api.github.com/repos/aws/amazon-ecs-agent/milestones/23/labels","id":3154982,"number":23,"title":"1.17.3","description":null,"creator":{"login":"sharanyad","id":14119911,"avatar_url":"https://avatars1.githubusercontent.com/u/14119911?v=4","gravatar_id":"","url":"https://api.github.com/users/sharanyad","html_url":"https://github.com/sharanyad","followers_url":"https://api.github.com/users/sharanyad/followers","following_url":"https://api.github.com/users/sharanyad/following{/other_user}","gists_url":"https://api.github.com/users/sharanyad/gists{/gist_id}","starred_url":"https://api.github.com/users/sharanyad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharanyad/subscriptions","organizations_url":"https://api.github.com/users/sharanyad/orgs","repos_url":"https://api.github.com/users/sharanyad/repos","events_url":"https://api.github.com/users/sharanyad/events{/privacy}","received_events_url":"https://api.github.com/users/sharanyad/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":4,"state":"open","created_at":"2018-03-01T23:53:30Z","updated_at":"2018-03-21T23:30:11Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/1310/commits","review_comments_url":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/1310/comments","review_comment_url":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/1310/comments","statuses_url":"https://api.github.com/repos/aws/amazon-ecs-agent/statuses/8d11bdbe64440e7fb435f20eb9001dd4d5d02afd","head":{"label":"aaithal:websocketDeadlineErrors","ref":"websocketDeadlineErrors","sha":"8d11bdbe64440e7fb435f20eb9001dd4d5d02afd","user":{"login":"aaithal","id":1183359,"avatar_url":"https://avatars1.githubusercontent.com/u/1183359?v=4","gravatar_id":"","url":"https://api.github.com/users/aaithal","html_url":"https://github.com/aaithal","followers_url":"https://api.github.com/users/aaithal/followers","following_url":"https://api.github.com/users/aaithal/following{/other_user}","gists_url":"https://api.github.com/users/aaithal/gists{/gist_id}","starred_url":"https://api.github.com/users/aaithal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaithal/subscriptions","organizations_url":"https://api.github.com/users/aaithal/orgs","repos_url":"https://api.github.com/users/aaithal/repos","events_url":"https://api.github.com/users/aaithal/events{/privacy}","received_events_url":"https://api.github.com/users/aaithal/received_events","type":"User","site_admin":false},"repo":{"id":30386191,"name":"amazon-ecs-agent","full_name":"aaithal/amazon-ecs-agent","owner":{"login":"aaithal","id":1183359,"avatar_url":"https://avatars1.githubusercontent.com/u/1183359?v=4","gravatar_id":"","url":"https://api.github.com/users/aaithal","html_url":"https://github.com/aaithal","followers_url":"https://api.github.com/users/aaithal/followers","following_url":"https://api.github.com/users/aaithal/following{/other_user}","gists_url":"https://api.github.com/users/aaithal/gists{/gist_id}","starred_url":"https://api.github.com/users/aaithal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaithal/subscriptions","organizations_url":"https://api.github.com/users/aaithal/orgs","repos_url":"https://api.github.com/users/aaithal/repos","events_url":"https://api.github.com/users/aaithal/events{/privacy}","received_events_url":"https://api.github.com/users/aaithal/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aaithal/amazon-ecs-agent","description":"Amazon EC2 Container Service Agent","fork":true,"url":"https://api.github.com/repos/aaithal/amazon-ecs-agent","forks_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/forks","keys_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/teams","hooks_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/hooks","issue_events_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/issues/events{/number}","events_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/events","assignees_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/assignees{/user}","branches_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/branches{/branch}","tags_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/tags","blobs_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/languages","stargazers_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/stargazers","contributors_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/contributors","subscribers_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/subscribers","subscription_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/subscription","commits_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/contents/{+path}","compare_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/merges","archive_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/downloads","issues_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/issues{/number}","pulls_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/labels{/name}","releases_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/releases{/id}","deployments_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/deployments","created_at":"2015-02-06T00:24:31Z","updated_at":"2017-11-25T18:19:27Z","pushed_at":"2018-03-21T23:00:23Z","git_url":"git://github.com/aaithal/amazon-ecs-agent.git","ssh_url":"git@github.com:aaithal/amazon-ecs-agent.git","clone_url":"https://github.com/aaithal/amazon-ecs-agent.git","svn_url":"https://github.com/aaithal/amazon-ecs-agent","homepage":"http://aws.amazon.com/ecs/","size":29950,"stargazers_count":9,"watchers_count":9,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":1,"open_issues":0,"watchers":9,"default_branch":"master"}},"base":{"label":"aws:dev","ref":"dev","sha":"e258e16e2b25de45bf51c85895c9a721d5a5cb3a","user":{"login":"aws","id":2232217,"avatar_url":"https://avatars3.githubusercontent.com/u/2232217?v=4","gravatar_id":"","url":"https://api.github.com/users/aws","html_url":"https://github.com/aws","followers_url":"https://api.github.com/users/aws/followers","following_url":"https://api.github.com/users/aws/following{/other_user}","gists_url":"https://api.github.com/users/aws/gists{/gist_id}","starred_url":"https://api.github.com/users/aws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aws/subscriptions","organizations_url":"https://api.github.com/users/aws/orgs","repos_url":"https://api.github.com/users/aws/repos","events_url":"https://api.github.com/users/aws/events{/privacy}","received_events_url":"https://api.github.com/users/aws/received_events","type":"Organization","site_admin":false},"repo":{"id":27551774,"name":"amazon-ecs-agent","full_name":"aws/amazon-ecs-agent","owner":{"login":"aws","id":2232217,"avatar_url":"https://avatars3.githubusercontent.com/u/2232217?v=4","gravatar_id":"","url":"https://api.github.com/users/aws","html_url":"https://github.com/aws","followers_url":"https://api.github.com/users/aws/followers","following_url":"https://api.github.com/users/aws/following{/other_user}","gists_url":"https://api.github.com/users/aws/gists{/gist_id}","starred_url":"https://api.github.com/users/aws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aws/subscriptions","organizations_url":"https://api.github.com/users/aws/orgs","repos_url":"https://api.github.com/users/aws/repos","events_url":"https://api.github.com/users/aws/events{/privacy}","received_events_url":"https://api.github.com/users/aws/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aws/amazon-ecs-agent","description":"Amazon Elastic Container Service Agent","fork":false,"url":"https://api.github.com/repos/aws/amazon-ecs-agent","forks_url":"https://api.github.com/repos/aws/amazon-ecs-agent/forks","keys_url":"https://api.github.com/repos/aws/amazon-ecs-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aws/amazon-ecs-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aws/amazon-ecs-agent/teams","hooks_url":"https://api.github.com/repos/aws/amazon-ecs-agent/hooks","issue_events_url":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/events{/number}","events_url":"https://api.github.com/repos/aws/amazon-ecs-agent/events","assignees_url":"https://api.github.com/repos/aws/amazon-ecs-agent/assignees{/user}","branches_url":"https://api.github.com/repos/aws/amazon-ecs-agent/branches{/branch}","tags_url":"https://api.github.com/repos/aws/amazon-ecs-agent/tags","blobs_url":"https://api.github.com/repos/aws/amazon-ecs-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aws/amazon-ecs-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aws/amazon-ecs-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/aws/amazon-ecs-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aws/amazon-ecs-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/aws/amazon-ecs-agent/languages","stargazers_url":"https://api.github.com/repos/aws/amazon-ecs-agent/stargazers","contributors_url":"https://api.github.com/repos/aws/amazon-ecs-agent/contributors","subscribers_url":"https://api.github.com/repos/aws/amazon-ecs-agent/subscribers","subscription_url":"https://api.github.com/repos/aws/amazon-ecs-agent/subscription","commits_url":"https://api.github.com/repos/aws/amazon-ecs-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/aws/amazon-ecs-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/aws/amazon-ecs-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/aws/amazon-ecs-agent/contents/{+path}","compare_url":"https://api.github.com/repos/aws/amazon-ecs-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aws/amazon-ecs-agent/merges","archive_url":"https://api.github.com/repos/aws/amazon-ecs-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aws/amazon-ecs-agent/downloads","issues_url":"https://api.github.com/repos/aws/amazon-ecs-agent/issues{/number}","pulls_url":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/aws/amazon-ecs-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/aws/amazon-ecs-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aws/amazon-ecs-agent/labels{/name}","releases_url":"https://api.github.com/repos/aws/amazon-ecs-agent/releases{/id}","deployments_url":"https://api.github.com/repos/aws/amazon-ecs-agent/deployments","created_at":"2014-12-04T17:31:49Z","updated_at":"2018-03-21T18:21:37Z","pushed_at":"2018-03-21T23:30:20Z","git_url":"git://github.com/aws/amazon-ecs-agent.git","ssh_url":"git@github.com:aws/amazon-ecs-agent.git","clone_url":"https://github.com/aws/amazon-ecs-agent.git","svn_url":"https://github.com/aws/amazon-ecs-agent","homepage":"http://aws.amazon.com/ecs/","size":29766,"stargazers_count":1187,"watchers_count":1187,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":315,"mirror_url":null,"archived":false,"open_issues_count":108,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":315,"open_issues":108,"watchers":1187,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/1310"},"html":{"href":"https://github.com/aws/amazon-ecs-agent/pull/1310"},"issue":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/1310"},"comments":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/1310/comments"},"review_comments":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/1310/comments"},"review_comment":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/1310/commits"},"statuses":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/statuses/8d11bdbe64440e7fb435f20eb9001dd4d5d02afd"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"tehshwann"}}