{"action":"created","comment":{"url":"https://api.github.com/repos/prometheus/alertmanager/pulls/comments/166301853","pull_request_review_id":94345507,"id":166301853,"diff_hunk":"@@ -388,6 +396,45 @@ func (s peerDescSlice) Len() int           { return len(s) }\n func (s peerDescSlice) Less(i, j int) bool { return s[i].UID < s[j].UID }\n func (s peerDescSlice) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }\n \n+// meshSettle set isReady to 1 once the mesh is considered settle (or after a\n+// configurable timeout). The idea is that we don't want to start \"working\" before\n+// we get a chance to know most of the alerts and/or silences.\n+func meshSettle(r *mesh.Router, isReady *int32, timeout time.Duration, logger log.Logger) {\n+\t// Inspired from https://github.com/apache/cassandra/blob/7a40abb6a5108688fb1b10c375bb751cbb782ea4/src/java/org/apache/cassandra/gms/Gossiper.java\n+\t// This is clearly not perfect or strictly correct but should prevent the alertmanager\n+\t// to be used before it is obviously not read.\n+\tconst PollInterval = 1 * time.Second\n+\tconst NumOkayRequired = 3\n+\tconst ForceAfter = 60 // Limit this to 10 * PollInterval, this needs to be higher than the mesh connection timeout.\n+\tlevel.Info(logger).Log(\"msg\", \"Waiting for gossip to settle...\")\n+\ttime.Sleep(PollInterval)\n+\t\n+\tnPeers := 0\n+\tnOkay := 0\n+\ttotalPolls := 0\n+\tfor {\n+\t\ttime.Sleep(PollInterval)\n+\t\tif nOkay >= NumOkayRequired {\n+\t\t\tlevel.Info(logger).Log(\"msg\", \"No gossip backlog; proceeding\")","path":"cmd/alertmanager/main.go","position":null,"original_position":47,"commit_id":"bbbedad46269b51aa7fa0e7bcbff7c306d4d0b72","original_commit_id":"4564a6330bd9ae98e8648afaf97dbbbbdd1bea54","user":{"login":"iksaif","id":1032963,"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-02-06T13:41:37Z","updated_at":"2018-02-06T13:41:37Z","html_url":"https://github.com/prometheus/alertmanager/pull/1209#discussion_r166301853","pull_request_url":"https://api.github.com/repos/prometheus/alertmanager/pulls/1209","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/prometheus/alertmanager/pulls/comments/166301853"},"html":{"href":"https://github.com/prometheus/alertmanager/pull/1209#discussion_r166301853"},"pull_request":{"href":"https://api.github.com/repos/prometheus/alertmanager/pulls/1209"}},"in_reply_to_id":166231749},"pull_request":{"url":"https://api.github.com/repos/prometheus/alertmanager/pulls/1209","id":165134330,"html_url":"https://github.com/prometheus/alertmanager/pull/1209","diff_url":"https://github.com/prometheus/alertmanager/pull/1209.diff","patch_url":"https://github.com/prometheus/alertmanager/pull/1209.patch","issue_url":"https://api.github.com/repos/prometheus/alertmanager/issues/1209","number":1209,"state":"open","locked":false,"title":"Add /-/ready based on mesh status","user":{"login":"iksaif","id":1032963,"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":"This is not a final proposal, merely an attempt to get an idea of what should be done.\r\n\r\nAs an heuristic for mesh readyness, try to see if\r\nthe mesh looks stable (the number of peers isn't changing too much).\r\nThis implementation always mark the altermanager as ready after a maximum of 60s.\r\n\r\nIt was briefly discussed in 991, would be affected by #1200.\r\n\r\nIt's important not to start processing requests ASAP when you have thousands of alerts and silences to gossip and alertmanager instances in other continents.","created_at":"2018-01-25T14:35:54Z","updated_at":"2018-02-06T13:41:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ade5cb327bfec5a2ab3727922bbfd8d222633b42","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/prometheus/alertmanager/pulls/1209/commits","review_comments_url":"https://api.github.com/repos/prometheus/alertmanager/pulls/1209/comments","review_comment_url":"https://api.github.com/repos/prometheus/alertmanager/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prometheus/alertmanager/issues/1209/comments","statuses_url":"https://api.github.com/repos/prometheus/alertmanager/statuses/bbbedad46269b51aa7fa0e7bcbff7c306d4d0b72","head":{"label":"iksaif:pr-ready","ref":"pr-ready","sha":"bbbedad46269b51aa7fa0e7bcbff7c306d4d0b72","user":{"login":"iksaif","id":1032963,"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},"repo":{"id":94531435,"name":"alertmanager","full_name":"iksaif/alertmanager","owner":{"login":"iksaif","id":1032963,"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},"private":false,"html_url":"https://github.com/iksaif/alertmanager","description":"Prometheus Alertmanager","fork":true,"url":"https://api.github.com/repos/iksaif/alertmanager","forks_url":"https://api.github.com/repos/iksaif/alertmanager/forks","keys_url":"https://api.github.com/repos/iksaif/alertmanager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iksaif/alertmanager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iksaif/alertmanager/teams","hooks_url":"https://api.github.com/repos/iksaif/alertmanager/hooks","issue_events_url":"https://api.github.com/repos/iksaif/alertmanager/issues/events{/number}","events_url":"https://api.github.com/repos/iksaif/alertmanager/events","assignees_url":"https://api.github.com/repos/iksaif/alertmanager/assignees{/user}","branches_url":"https://api.github.com/repos/iksaif/alertmanager/branches{/branch}","tags_url":"https://api.github.com/repos/iksaif/alertmanager/tags","blobs_url":"https://api.github.com/repos/iksaif/alertmanager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iksaif/alertmanager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iksaif/alertmanager/git/refs{/sha}","trees_url":"https://api.github.com/repos/iksaif/alertmanager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iksaif/alertmanager/statuses/{sha}","languages_url":"https://api.github.com/repos/iksaif/alertmanager/languages","stargazers_url":"https://api.github.com/repos/iksaif/alertmanager/stargazers","contributors_url":"https://api.github.com/repos/iksaif/alertmanager/contributors","subscribers_url":"https://api.github.com/repos/iksaif/alertmanager/subscribers","subscription_url":"https://api.github.com/repos/iksaif/alertmanager/subscription","commits_url":"https://api.github.com/repos/iksaif/alertmanager/commits{/sha}","git_commits_url":"https://api.github.com/repos/iksaif/alertmanager/git/commits{/sha}","comments_url":"https://api.github.com/repos/iksaif/alertmanager/comments{/number}","issue_comment_url":"https://api.github.com/repos/iksaif/alertmanager/issues/comments{/number}","contents_url":"https://api.github.com/repos/iksaif/alertmanager/contents/{+path}","compare_url":"https://api.github.com/repos/iksaif/alertmanager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iksaif/alertmanager/merges","archive_url":"https://api.github.com/repos/iksaif/alertmanager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iksaif/alertmanager/downloads","issues_url":"https://api.github.com/repos/iksaif/alertmanager/issues{/number}","pulls_url":"https://api.github.com/repos/iksaif/alertmanager/pulls{/number}","milestones_url":"https://api.github.com/repos/iksaif/alertmanager/milestones{/number}","notifications_url":"https://api.github.com/repos/iksaif/alertmanager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iksaif/alertmanager/labels{/name}","releases_url":"https://api.github.com/repos/iksaif/alertmanager/releases{/id}","deployments_url":"https://api.github.com/repos/iksaif/alertmanager/deployments","created_at":"2017-06-16T10:01:36Z","updated_at":"2017-06-16T10:01:38Z","pushed_at":"2018-02-06T13:40:34Z","git_url":"git://github.com/iksaif/alertmanager.git","ssh_url":"git@github.com:iksaif/alertmanager.git","clone_url":"https://github.com/iksaif/alertmanager.git","svn_url":"https://github.com/iksaif/alertmanager","homepage":"","size":19902,"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":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"prometheus:master","ref":"master","sha":"a43a513b77ffa10a655019dcca9d24233a74b9a6","user":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars3.githubusercontent.com/u/3380462?v=4","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"repo":{"id":11452538,"name":"alertmanager","full_name":"prometheus/alertmanager","owner":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars3.githubusercontent.com/u/3380462?v=4","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prometheus/alertmanager","description":"Prometheus Alertmanager","fork":false,"url":"https://api.github.com/repos/prometheus/alertmanager","forks_url":"https://api.github.com/repos/prometheus/alertmanager/forks","keys_url":"https://api.github.com/repos/prometheus/alertmanager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prometheus/alertmanager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prometheus/alertmanager/teams","hooks_url":"https://api.github.com/repos/prometheus/alertmanager/hooks","issue_events_url":"https://api.github.com/repos/prometheus/alertmanager/issues/events{/number}","events_url":"https://api.github.com/repos/prometheus/alertmanager/events","assignees_url":"https://api.github.com/repos/prometheus/alertmanager/assignees{/user}","branches_url":"https://api.github.com/repos/prometheus/alertmanager/branches{/branch}","tags_url":"https://api.github.com/repos/prometheus/alertmanager/tags","blobs_url":"https://api.github.com/repos/prometheus/alertmanager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prometheus/alertmanager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prometheus/alertmanager/git/refs{/sha}","trees_url":"https://api.github.com/repos/prometheus/alertmanager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prometheus/alertmanager/statuses/{sha}","languages_url":"https://api.github.com/repos/prometheus/alertmanager/languages","stargazers_url":"https://api.github.com/repos/prometheus/alertmanager/stargazers","contributors_url":"https://api.github.com/repos/prometheus/alertmanager/contributors","subscribers_url":"https://api.github.com/repos/prometheus/alertmanager/subscribers","subscription_url":"https://api.github.com/repos/prometheus/alertmanager/subscription","commits_url":"https://api.github.com/repos/prometheus/alertmanager/commits{/sha}","git_commits_url":"https://api.github.com/repos/prometheus/alertmanager/git/commits{/sha}","comments_url":"https://api.github.com/repos/prometheus/alertmanager/comments{/number}","issue_comment_url":"https://api.github.com/repos/prometheus/alertmanager/issues/comments{/number}","contents_url":"https://api.github.com/repos/prometheus/alertmanager/contents/{+path}","compare_url":"https://api.github.com/repos/prometheus/alertmanager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prometheus/alertmanager/merges","archive_url":"https://api.github.com/repos/prometheus/alertmanager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prometheus/alertmanager/downloads","issues_url":"https://api.github.com/repos/prometheus/alertmanager/issues{/number}","pulls_url":"https://api.github.com/repos/prometheus/alertmanager/pulls{/number}","milestones_url":"https://api.github.com/repos/prometheus/alertmanager/milestones{/number}","notifications_url":"https://api.github.com/repos/prometheus/alertmanager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prometheus/alertmanager/labels{/name}","releases_url":"https://api.github.com/repos/prometheus/alertmanager/releases{/id}","deployments_url":"https://api.github.com/repos/prometheus/alertmanager/deployments","created_at":"2013-07-16T15:06:31Z","updated_at":"2018-02-06T10:13:49Z","pushed_at":"2018-02-06T13:40:37Z","git_url":"git://github.com/prometheus/alertmanager.git","ssh_url":"git@github.com:prometheus/alertmanager.git","clone_url":"https://github.com/prometheus/alertmanager.git","svn_url":"https://github.com/prometheus/alertmanager","homepage":"","size":20217,"stargazers_count":957,"watchers_count":957,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":405,"mirror_url":null,"archived":false,"open_issues_count":136,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":405,"open_issues":136,"watchers":957,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prometheus/alertmanager/pulls/1209"},"html":{"href":"https://github.com/prometheus/alertmanager/pull/1209"},"issue":{"href":"https://api.github.com/repos/prometheus/alertmanager/issues/1209"},"comments":{"href":"https://api.github.com/repos/prometheus/alertmanager/issues/1209/comments"},"review_comments":{"href":"https://api.github.com/repos/prometheus/alertmanager/pulls/1209/comments"},"review_comment":{"href":"https://api.github.com/repos/prometheus/alertmanager/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prometheus/alertmanager/pulls/1209/commits"},"statuses":{"href":"https://api.github.com/repos/prometheus/alertmanager/statuses/bbbedad46269b51aa7fa0e7bcbff7c306d4d0b72"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"iksaif"}}