{"action":"created","comment":{"url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/comments/220841219","pull_request_review_id":159342011,"id":220841219,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMDg0MTIxOQ==","diff_hunk":"@@ -59,20 +84,46 @@ func (s *Sender) run() {\n // wireMessage lets the Sender send a message to datadog's intake\n func (s *Sender) wireMessage(payload message.Message) {\n \tfor {\n+\t\tvar err error\n+\n+\t\t// Check if we should stop early. This must be before NewConnection so that\n+\t\t// when we are stopping we are still reading the messages from inputChan (so\n+\t\t// that the rest of the pipeline finishes up cleanly) but we are not trying to\n+\t\t// connect anymore.\n+\t\tselect {\n+\t\tcase <-s.ctx.Done():\n+\t\t\tbreak\n+\t\tdefault:\n+\t\t}\n+\n+\t\tif s.conn == nil {\n+\t\t\t// blocks until a new conn is ready\n+\t\t\ts.conn, err = s.connManager.NewConnection(s.ctx)\n+\t\t}\n+\n+\t\t// If we've been cancelled we don't want to forward messages anymore.\n+\t\tif err == context.Canceled {","path":"pkg/logs/sender/sender.go","position":null,"original_position":87,"commit_id":"222704a14a68044d5f4cb07c372f181d13da3746","original_commit_id":"93d703ce60ecce9b330951a703b59451ddde07e8","user":{"login":"iksaif","id":1032963,"node_id":"MDQ6VXNlcjEwMzI5NjM=","avatar_url":"https://avatars1.githubusercontent.com/u/1032963?v=4","gravatar_id":"","url":"https://api.github.com/users/iksaif","html_url":"https://github.com/iksaif","followers_url":"https://api.github.com/users/iksaif/followers","following_url":"https://api.github.com/users/iksaif/following{/other_user}","gists_url":"https://api.github.com/users/iksaif/gists{/gist_id}","starred_url":"https://api.github.com/users/iksaif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iksaif/subscriptions","organizations_url":"https://api.github.com/users/iksaif/orgs","repos_url":"https://api.github.com/users/iksaif/repos","events_url":"https://api.github.com/users/iksaif/events{/privacy}","received_events_url":"https://api.github.com/users/iksaif/received_events","type":"User","site_admin":false},"body":"done","created_at":"2018-09-27T08:48:19Z","updated_at":"2018-09-27T08:48:19Z","html_url":"https://github.com/DataDog/datadog-agent/pull/2373#discussion_r220841219","pull_request_url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/2373","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/DataDog/datadog-agent/pulls/comments/220841219"},"html":{"href":"https://github.com/DataDog/datadog-agent/pull/2373#discussion_r220841219"},"pull_request":{"href":"https://api.github.com/repos/DataDog/datadog-agent/pulls/2373"}},"in_reply_to_id":220832473},"pull_request":{"url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/2373","id":218372820,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE4MzcyODIw","html_url":"https://github.com/DataDog/datadog-agent/pull/2373","diff_url":"https://github.com/DataDog/datadog-agent/pull/2373.diff","patch_url":"https://github.com/DataDog/datadog-agent/pull/2373.patch","issue_url":"https://api.github.com/repos/DataDog/datadog-agent/issues/2373","number":2373,"state":"open","locked":false,"title":"[wip] Dont block the agent if we can't send logs","user":{"login":"iksaif","id":1032963,"node_id":"MDQ6VXNlcjEwMzI5NjM=","avatar_url":"https://avatars1.githubusercontent.com/u/1032963?v=4","gravatar_id":"","url":"https://api.github.com/users/iksaif","html_url":"https://github.com/iksaif","followers_url":"https://api.github.com/users/iksaif/followers","following_url":"https://api.github.com/users/iksaif/following{/other_user}","gists_url":"https://api.github.com/users/iksaif/gists{/gist_id}","starred_url":"https://api.github.com/users/iksaif/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iksaif/subscriptions","organizations_url":"https://api.github.com/users/iksaif/orgs","repos_url":"https://api.github.com/users/iksaif/repos","events_url":"https://api.github.com/users/iksaif/events{/privacy}","received_events_url":"https://api.github.com/users/iksaif/received_events","type":"User","site_admin":false},"body":"### What does this PR do?\r\n\r\n***This is WIP, to make sure that the general idea looks good before going further, do not look at style too much yet***\r\n\r\nCurrently if the Senders are not able to consume the messages of the\r\npipelines (for example, because they can't establish a connection) it\r\nis impossible to stop the logging agent. Even worse, it is impossible\r\nto stop the inputs too because the channels in-between components have\r\na fixed size.\r\n\r\n\r\n### Additional Notes\r\n\r\nThis is based heavilly on context.Context to allow us to have proper\r\ncomposite timeouts / cancellations. This is the recommended way to do\r\nthat in go which is also already used in other parts of the agent.\r\n\r\nThis commit also changes the following things:\r\n- ConnectionManager becomes restartable in order to stop connections\r\n  attempts when the normal stopping process fails.\r\n- Sender starts using context.Context in order to have proper cancelation\r\n  timeouts.\r\n- Move is running to agent.go to make it easier for the caller to start/stop agents.\r\n\r\n[TODO]\r\n- unit tests: Start() / Stop() sequence for agent / sender / connection manager\r\n- cleanup imports\r\n- remove FIXMEs (including the early stop)\r\n\r\n[TODO Maybe]\r\n- Make the auditor re-usable by changing the way the channel is created,\r\n  this will allow use to restart all the logging agent, which might be\r\n  useful for unit tests (or to someday support enabling it/disabling it\r\n  without restarting the agent).","created_at":"2018-09-26T16:03:52Z","updated_at":"2018-09-27T08:48:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c51cd708dcdf3e505478de11a093a82118056b39","assignee":null,"assignees":[],"requested_reviewers":[{"login":"ajacquemot","id":5777308,"node_id":"MDQ6VXNlcjU3NzczMDg=","avatar_url":"https://avatars0.githubusercontent.com/u/5777308?v=4","gravatar_id":"","url":"https://api.github.com/users/ajacquemot","html_url":"https://github.com/ajacquemot","followers_url":"https://api.github.com/users/ajacquemot/followers","following_url":"https://api.github.com/users/ajacquemot/following{/other_user}","gists_url":"https://api.github.com/users/ajacquemot/gists{/gist_id}","starred_url":"https://api.github.com/users/ajacquemot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajacquemot/subscriptions","organizations_url":"https://api.github.com/users/ajacquemot/orgs","repos_url":"https://api.github.com/users/ajacquemot/repos","events_url":"https://api.github.com/users/ajacquemot/events{/privacy}","received_events_url":"https://api.github.com/users/ajacquemot/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":776720186,"node_id":"MDU6TGFiZWw3NzY3MjAxODY=","url":"https://api.github.com/repos/DataDog/datadog-agent/labels/component/logs","name":"component/logs","color":"0052cc","default":false},{"id":571127627,"node_id":"MDU6TGFiZWw1NzExMjc2Mjc=","url":"https://api.github.com/repos/DataDog/datadog-agent/labels/do-not-merge/WIP","name":"do-not-merge/WIP","color":"000000","default":false},{"id":313604150,"node_id":"MDU6TGFiZWwzMTM2MDQxNTA=","url":"https://api.github.com/repos/DataDog/datadog-agent/labels/kind/bug","name":"kind/bug","color":"fc2929","default":false},{"id":695416522,"node_id":"MDU6TGFiZWw2OTU0MTY1MjI=","url":"https://api.github.com/repos/DataDog/datadog-agent/labels/team/ramen","name":"team/ramen","color":"d4c5f9","default":false}],"milestone":{"url":"https://api.github.com/repos/DataDog/datadog-agent/milestones/36","html_url":"https://github.com/DataDog/datadog-agent/milestone/36","labels_url":"https://api.github.com/repos/DataDog/datadog-agent/milestones/36/labels","id":3611712,"node_id":"MDk6TWlsZXN0b25lMzYxMTcxMg==","number":36,"title":"6.6.0","description":null,"creator":{"login":"truthbk","id":448216,"node_id":"MDQ6VXNlcjQ0ODIxNg==","avatar_url":"https://avatars0.githubusercontent.com/u/448216?v=4","gravatar_id":"","url":"https://api.github.com/users/truthbk","html_url":"https://github.com/truthbk","followers_url":"https://api.github.com/users/truthbk/followers","following_url":"https://api.github.com/users/truthbk/following{/other_user}","gists_url":"https://api.github.com/users/truthbk/gists{/gist_id}","starred_url":"https://api.github.com/users/truthbk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/truthbk/subscriptions","organizations_url":"https://api.github.com/users/truthbk/orgs","repos_url":"https://api.github.com/users/truthbk/repos","events_url":"https://api.github.com/users/truthbk/events{/privacy}","received_events_url":"https://api.github.com/users/truthbk/received_events","type":"User","site_admin":false},"open_issues":32,"closed_issues":19,"state":"open","created_at":"2018-08-30T23:18:53Z","updated_at":"2018-09-26T21:24:53Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/2373/commits","review_comments_url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/2373/comments","review_comment_url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DataDog/datadog-agent/issues/2373/comments","statuses_url":"https://api.github.com/repos/DataDog/datadog-agent/statuses/222704a14a68044d5f4cb07c372f181d13da3746","head":{"label":"DataDog:corentin.chary/intake-sender-unblock-2","ref":"corentin.chary/intake-sender-unblock-2","sha":"222704a14a68044d5f4cb07c372f181d13da3746","user":{"login":"DataDog","id":365230,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2NTIzMA==","avatar_url":"https://avatars1.githubusercontent.com/u/365230?v=4","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"repo":{"id":49970739,"node_id":"MDEwOlJlcG9zaXRvcnk0OTk3MDczOQ==","name":"datadog-agent","full_name":"DataDog/datadog-agent","private":false,"owner":{"login":"DataDog","id":365230,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2NTIzMA==","avatar_url":"https://avatars1.githubusercontent.com/u/365230?v=4","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/DataDog/datadog-agent","description":"Datadog Agent ","fork":false,"url":"https://api.github.com/repos/DataDog/datadog-agent","forks_url":"https://api.github.com/repos/DataDog/datadog-agent/forks","keys_url":"https://api.github.com/repos/DataDog/datadog-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DataDog/datadog-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DataDog/datadog-agent/teams","hooks_url":"https://api.github.com/repos/DataDog/datadog-agent/hooks","issue_events_url":"https://api.github.com/repos/DataDog/datadog-agent/issues/events{/number}","events_url":"https://api.github.com/repos/DataDog/datadog-agent/events","assignees_url":"https://api.github.com/repos/DataDog/datadog-agent/assignees{/user}","branches_url":"https://api.github.com/repos/DataDog/datadog-agent/branches{/branch}","tags_url":"https://api.github.com/repos/DataDog/datadog-agent/tags","blobs_url":"https://api.github.com/repos/DataDog/datadog-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DataDog/datadog-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DataDog/datadog-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/DataDog/datadog-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DataDog/datadog-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/DataDog/datadog-agent/languages","stargazers_url":"https://api.github.com/repos/DataDog/datadog-agent/stargazers","contributors_url":"https://api.github.com/repos/DataDog/datadog-agent/contributors","subscribers_url":"https://api.github.com/repos/DataDog/datadog-agent/subscribers","subscription_url":"https://api.github.com/repos/DataDog/datadog-agent/subscription","commits_url":"https://api.github.com/repos/DataDog/datadog-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/DataDog/datadog-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/DataDog/datadog-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/DataDog/datadog-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/DataDog/datadog-agent/contents/{+path}","compare_url":"https://api.github.com/repos/DataDog/datadog-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DataDog/datadog-agent/merges","archive_url":"https://api.github.com/repos/DataDog/datadog-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DataDog/datadog-agent/downloads","issues_url":"https://api.github.com/repos/DataDog/datadog-agent/issues{/number}","pulls_url":"https://api.github.com/repos/DataDog/datadog-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/DataDog/datadog-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/DataDog/datadog-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DataDog/datadog-agent/labels{/name}","releases_url":"https://api.github.com/repos/DataDog/datadog-agent/releases{/id}","deployments_url":"https://api.github.com/repos/DataDog/datadog-agent/deployments","created_at":"2016-01-19T17:40:41Z","updated_at":"2018-09-27T01:58:29Z","pushed_at":"2018-09-27T08:47:51Z","git_url":"git://github.com/DataDog/datadog-agent.git","ssh_url":"git@github.com:DataDog/datadog-agent.git","clone_url":"https://github.com/DataDog/datadog-agent.git","svn_url":"https://github.com/DataDog/datadog-agent","homepage":"https://docs.datadoghq.com/","size":29991,"stargazers_count":280,"watchers_count":280,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":118,"mirror_url":null,"archived":false,"open_issues_count":156,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":118,"open_issues":156,"watchers":280,"default_branch":"master"}},"base":{"label":"DataDog:master","ref":"master","sha":"51de13c18358ac380154d01d4dbd47e067189bc8","user":{"login":"DataDog","id":365230,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2NTIzMA==","avatar_url":"https://avatars1.githubusercontent.com/u/365230?v=4","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"repo":{"id":49970739,"node_id":"MDEwOlJlcG9zaXRvcnk0OTk3MDczOQ==","name":"datadog-agent","full_name":"DataDog/datadog-agent","private":false,"owner":{"login":"DataDog","id":365230,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2NTIzMA==","avatar_url":"https://avatars1.githubusercontent.com/u/365230?v=4","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/DataDog/datadog-agent","description":"Datadog Agent ","fork":false,"url":"https://api.github.com/repos/DataDog/datadog-agent","forks_url":"https://api.github.com/repos/DataDog/datadog-agent/forks","keys_url":"https://api.github.com/repos/DataDog/datadog-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DataDog/datadog-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DataDog/datadog-agent/teams","hooks_url":"https://api.github.com/repos/DataDog/datadog-agent/hooks","issue_events_url":"https://api.github.com/repos/DataDog/datadog-agent/issues/events{/number}","events_url":"https://api.github.com/repos/DataDog/datadog-agent/events","assignees_url":"https://api.github.com/repos/DataDog/datadog-agent/assignees{/user}","branches_url":"https://api.github.com/repos/DataDog/datadog-agent/branches{/branch}","tags_url":"https://api.github.com/repos/DataDog/datadog-agent/tags","blobs_url":"https://api.github.com/repos/DataDog/datadog-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DataDog/datadog-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DataDog/datadog-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/DataDog/datadog-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DataDog/datadog-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/DataDog/datadog-agent/languages","stargazers_url":"https://api.github.com/repos/DataDog/datadog-agent/stargazers","contributors_url":"https://api.github.com/repos/DataDog/datadog-agent/contributors","subscribers_url":"https://api.github.com/repos/DataDog/datadog-agent/subscribers","subscription_url":"https://api.github.com/repos/DataDog/datadog-agent/subscription","commits_url":"https://api.github.com/repos/DataDog/datadog-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/DataDog/datadog-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/DataDog/datadog-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/DataDog/datadog-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/DataDog/datadog-agent/contents/{+path}","compare_url":"https://api.github.com/repos/DataDog/datadog-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DataDog/datadog-agent/merges","archive_url":"https://api.github.com/repos/DataDog/datadog-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DataDog/datadog-agent/downloads","issues_url":"https://api.github.com/repos/DataDog/datadog-agent/issues{/number}","pulls_url":"https://api.github.com/repos/DataDog/datadog-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/DataDog/datadog-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/DataDog/datadog-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DataDog/datadog-agent/labels{/name}","releases_url":"https://api.github.com/repos/DataDog/datadog-agent/releases{/id}","deployments_url":"https://api.github.com/repos/DataDog/datadog-agent/deployments","created_at":"2016-01-19T17:40:41Z","updated_at":"2018-09-27T01:58:29Z","pushed_at":"2018-09-27T08:47:51Z","git_url":"git://github.com/DataDog/datadog-agent.git","ssh_url":"git@github.com:DataDog/datadog-agent.git","clone_url":"https://github.com/DataDog/datadog-agent.git","svn_url":"https://github.com/DataDog/datadog-agent","homepage":"https://docs.datadoghq.com/","size":29991,"stargazers_count":280,"watchers_count":280,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":118,"mirror_url":null,"archived":false,"open_issues_count":156,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":118,"open_issues":156,"watchers":280,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DataDog/datadog-agent/pulls/2373"},"html":{"href":"https://github.com/DataDog/datadog-agent/pull/2373"},"issue":{"href":"https://api.github.com/repos/DataDog/datadog-agent/issues/2373"},"comments":{"href":"https://api.github.com/repos/DataDog/datadog-agent/issues/2373/comments"},"review_comments":{"href":"https://api.github.com/repos/DataDog/datadog-agent/pulls/2373/comments"},"review_comment":{"href":"https://api.github.com/repos/DataDog/datadog-agent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DataDog/datadog-agent/pulls/2373/commits"},"statuses":{"href":"https://api.github.com/repos/DataDog/datadog-agent/statuses/222704a14a68044d5f4cb07c372f181d13da3746"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"iksaif"}}