{"action":"created","comment":{"url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/comments/199586104","pull_request_review_id":133734792,"id":199586104,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5OTU4NjEwNA==","diff_hunk":"@@ -147,55 +149,63 @@ func (le *LeaderEngine) init() error {\n func (le *LeaderEngine) EnsureLeaderElectionRuns() error {\n \tle.m.Lock()\n \tdefer le.m.Unlock()\n+\n \tif le.running {\n-\t\tlog.Debugf(\"Currently leader: %t. Leader identity: %q\", le.IsLeader(), le.CurrentLeaderName())\n+\t\tlog.Debugf(\"Currently Leader: %t. Leader identity: %q\", le.IsLeader(), le.GetLeader())\n \t\treturn nil\n \t}\n \n \tle.once.Do(\n \t\tfunc() {\n-\t\t\tlog.Infof(\"Starting Leader Election process for %q ...\", le.HolderIdentity)\n-\t\t\tgo le.leaderElector.Run()\n+\t\t\tgo le.startLeaderElection()\n \t\t},\n \t)\n \n \ttimeoutDuration := clientTimeout * 2\n \ttimeout := time.After(timeoutDuration)\n \ttick := time.NewTicker(time.Millisecond * 500)\n \tdefer tick.Stop()\n-\tvar leaderIdentity string\n \tfor {\n+\t\tlog.Tracef(\"Waiting for new leader identity...\")\n \t\tselect {\n \t\tcase <-tick.C:\n-\t\t\tleaderIdentity = le.CurrentLeaderName()\n+\t\t\tleaderIdentity := le.GetLeader()\n \t\t\tif leaderIdentity != \"\" {\n-\t\t\t\tlog.Infof(\"Leader Election run, current leader is %q\", leaderIdentity)\n+\t\t\t\tlog.Infof(\"Leader election running, current leader is %q\", leaderIdentity)\n \t\t\t\tle.running = true\n \t\t\t\treturn nil\n \t\t\t}\n-\t\t\tlog.Tracef(\"Leader identity is unset\")\n \n \t\tcase <-timeout:\n-\t\t\treturn fmt.Errorf(\"leader election still not running, timeout after %s\", timeoutDuration.String())\n+\t\t\treturn fmt.Errorf(\"leader election still not running, timeout after %s\", timeoutDuration)\n \t\t}\n \t}\n }\n \n-// CurrentLeaderName is the main interface that can be called to fetch the name of the current leader.\n-func (le *LeaderEngine) CurrentLeaderName() string {\n+func (le *LeaderEngine) startLeaderElection() {\n+\tfor {\n+\t\tlog.Infof(\"Starting leader election process for %q...\", le.HolderIdentity)\n+\t\tle.leaderElector.Run()\n+\t\tlog.Info(\"Leading election lost\")\n+\t}\n+}\n+","path":"pkg/util/kubernetes/apiserver/leaderelection/leaderelection.go","position":82,"original_position":82,"commit_id":"e746b67f17b9f2a5c2a5175d69ba4e5aff8fd90c","original_commit_id":"e746b67f17b9f2a5c2a5175d69ba4e5aff8fd90c","user":{"login":"devonboyer","id":5367914,"node_id":"MDQ6VXNlcjUzNjc5MTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/5367914?v=4","gravatar_id":"","url":"https://api.github.com/users/devonboyer","html_url":"https://github.com/devonboyer","followers_url":"https://api.github.com/users/devonboyer/followers","following_url":"https://api.github.com/users/devonboyer/following{/other_user}","gists_url":"https://api.github.com/users/devonboyer/gists{/gist_id}","starred_url":"https://api.github.com/users/devonboyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devonboyer/subscriptions","organizations_url":"https://api.github.com/users/devonboyer/orgs","repos_url":"https://api.github.com/users/devonboyer/repos","events_url":"https://api.github.com/users/devonboyer/events{/privacy}","received_events_url":"https://api.github.com/users/devonboyer/received_events","type":"User","site_admin":false},"body":"This loop is the real change in this PR.","created_at":"2018-07-02T18:38:14Z","updated_at":"2018-07-02T18:38:14Z","html_url":"https://github.com/DataDog/datadog-agent/pull/1777#discussion_r199586104","pull_request_url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/1777","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/DataDog/datadog-agent/pulls/comments/199586104"},"html":{"href":"https://github.com/DataDog/datadog-agent/pull/1777#discussion_r199586104"},"pull_request":{"href":"https://api.github.com/repos/DataDog/datadog-agent/pulls/1777"}}},"pull_request":{"url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/1777","id":192133066,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkyMTMzMDY2","html_url":"https://github.com/DataDog/datadog-agent/pull/1777","diff_url":"https://github.com/DataDog/datadog-agent/pull/1777.diff","patch_url":"https://github.com/DataDog/datadog-agent/pull/1777.patch","issue_url":"https://api.github.com/repos/DataDog/datadog-agent/issues/1777","number":1777,"state":"open","locked":false,"title":"Allow agent to become leader again after another agent became leader.","user":{"login":"devonboyer","id":5367914,"node_id":"MDQ6VXNlcjUzNjc5MTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/5367914?v=4","gravatar_id":"","url":"https://api.github.com/users/devonboyer","html_url":"https://github.com/devonboyer","followers_url":"https://api.github.com/users/devonboyer/followers","following_url":"https://api.github.com/users/devonboyer/following{/other_user}","gists_url":"https://api.github.com/users/devonboyer/gists{/gist_id}","starred_url":"https://api.github.com/users/devonboyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devonboyer/subscriptions","organizations_url":"https://api.github.com/users/devonboyer/orgs","repos_url":"https://api.github.com/users/devonboyer/repos","events_url":"https://api.github.com/users/devonboyer/events{/privacy}","received_events_url":"https://api.github.com/users/devonboyer/received_events","type":"User","site_admin":false},"body":"### What does this PR do?\r\n\r\nIf for whatever reason the leader loses connection to the API server and another agent becomes the leader. Allow the previous leader to try to become the leader again.\r\n\r\n### Motivation\r\n\r\nPreviously, if an agent stopped leading then it would never try to become the leader again.","created_at":"2018-06-01T20:20:43Z","updated_at":"2018-07-02T18:38:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"716ef3a1ebad26454d2910262b6fab5c142fe585","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[{"name":"agent-core","id":1224133,"node_id":"MDQ6VGVhbTEyMjQxMzM=","slug":"agent-core","description":"(formerly Croissant) Core Infra Agent and Agent packaging","privacy":"closed","url":"https://api.github.com/teams/1224133","members_url":"https://api.github.com/teams/1224133/members{/member}","repositories_url":"https://api.github.com/teams/1224133/repos","permission":"pull"},{"name":"Burrito","id":2159346,"node_id":"MDQ6VGVhbTIxNTkzNDY=","slug":"burrito","description":"","privacy":"closed","url":"https://api.github.com/teams/2159346","members_url":"https://api.github.com/teams/2159346/members{/member}","repositories_url":"https://api.github.com/teams/2159346/repos","permission":"pull"}],"labels":[{"id":695417157,"node_id":"MDU6TGFiZWw2OTU0MTcxNTc=","url":"https://api.github.com/repos/DataDog/datadog-agent/labels/team/containers","name":"team/containers","color":"d4c5f9","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/1777/commits","review_comments_url":"https://api.github.com/repos/DataDog/datadog-agent/pulls/1777/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/1777/comments","statuses_url":"https://api.github.com/repos/DataDog/datadog-agent/statuses/e746b67f17b9f2a5c2a5175d69ba4e5aff8fd90c","head":{"label":"DataDog:devon/leader-election-retry","ref":"devon/leader-election-retry","sha":"e746b67f17b9f2a5c2a5175d69ba4e5aff8fd90c","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","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},"private":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-07-02T16:24:55Z","pushed_at":"2018-07-02T18:37:41Z","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":19633,"stargazers_count":200,"watchers_count":200,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":76,"mirror_url":null,"archived":false,"open_issues_count":96,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":76,"open_issues":96,"watchers":200,"default_branch":"master"}},"base":{"label":"DataDog:master","ref":"master","sha":"063ba5c2b0f98c2905fa5f23cc6f0c42d7363bdd","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","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},"private":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-07-02T16:24:55Z","pushed_at":"2018-07-02T18:37:41Z","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":19633,"stargazers_count":200,"watchers_count":200,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":76,"mirror_url":null,"archived":false,"open_issues_count":96,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":76,"open_issues":96,"watchers":200,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DataDog/datadog-agent/pulls/1777"},"html":{"href":"https://github.com/DataDog/datadog-agent/pull/1777"},"issue":{"href":"https://api.github.com/repos/DataDog/datadog-agent/issues/1777"},"comments":{"href":"https://api.github.com/repos/DataDog/datadog-agent/issues/1777/comments"},"review_comments":{"href":"https://api.github.com/repos/DataDog/datadog-agent/pulls/1777/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/1777/commits"},"statuses":{"href":"https://api.github.com/repos/DataDog/datadog-agent/statuses/e746b67f17b9f2a5c2a5175d69ba4e5aff8fd90c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"devonboyer"}}