-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cluster: make sure we don't miss the first pushPull #1456
Conversation
cee9d3e
to
58abd4c
Compare
LGTM |
During the join, memberlist initiates a pushPull to get initial data. Unfortunately, at this point the nflog and silence listener have not been registered yet, so the first data arrives only after one pushPull cycle (1min by default !). Signed-off-by: Corentin Chary <c.chary@criteo.com>
cmd/alertmanager/main.go
Outdated
@@ -206,7 +204,7 @@ func main() { | |||
cancel() | |||
peer.Leave(10 * time.Second) | |||
}() | |||
go peer.Settle(ctx, *gossipInterval*10) | |||
go peer.Settle(ctx, *pushPullInterval) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand the Settle()
function correctly, it initially waits for interval
before starting to check whether the cluster is settled. By increasing this interval (gossipInterval
-> pushPullInterval
) marking a cluster as settled is delayed for every setup, even though it might already be settled.
Why not going back to a low interval
and moving the peer.Settle
below the peer.Join
logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would work too, I just though pushPullInterval made more sense here (but you are right, it might be a bit too long).
I'll be happy to change to whatever you think makes more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also expect peer.Settle()
to be called after peer.Join()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved, re-changed the interval value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments but looks great overall.
cmd/alertmanager/main.go
Outdated
*peerReconnectTimeout, | ||
) | ||
if err != nil { | ||
level.Error(logger).Log("msg", "Unable to initialize gossip mesh", "err", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/initialize/join/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
cmd/alertmanager/main.go
Outdated
@@ -263,6 +261,18 @@ func main() { | |||
wg.Wait() | |||
}() | |||
|
|||
// Peer state listener have been registered, now we can join and get the initial state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/listener/listeners/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
cluster/delegate.go
Outdated
@@ -135,6 +135,7 @@ func (d *delegate) NotifyMsg(b []byte) { | |||
level.Warn(d.logger).Log("msg", "decode broadcast", "err", err) | |||
return | |||
} | |||
level.Debug(d.logger).Log("received", "NotifyMsg", "len", len(b), "key", p.Key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure the extra logging is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
cluster/delegate.go
Outdated
for _, p := range fs.Parts { | ||
s, ok := d.states[p.Key] | ||
if !ok { | ||
level.Debug(d.logger).Log("received", "unknown state key", "len", len(buf), "key", p.Key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto or it should be Warn()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
cmd/alertmanager/main.go
Outdated
@@ -206,7 +204,7 @@ func main() { | |||
cancel() | |||
peer.Leave(10 * time.Second) | |||
}() | |||
go peer.Settle(ctx, *gossipInterval*10) | |||
go peer.Settle(ctx, *pushPullInterval) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also expect peer.Settle()
to be called after peer.Join()
.
Signed-off-by: Corentin Chary <c.chary@criteo.com>
Closes #1457 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Thanks for the quick adjustments.
Leaving last call to @stuartnelson3 and @simonpasquier.
@iksaif Thanks for your help! |
* cluster: make sure we don't miss the first pushPull During the join, memberlist initiates a pushPull to get initial data. Unfortunately, at this point the nflog and silence listener have not been registered yet, so the first data arrives only after one pushPull cycle (1min by default !). Signed-off-by: Corentin Chary <c.chary@criteo.com>
Alertmanager is exiting with a non-zero exit code if the initial cluster join fails. This behavior could be not wanted because: - As Alertmanager is a critical component with an at-least-once guarantee, failing on joining the cluster is unnecessary as Alertmanager still functions by itself. - In an environment like Kubernetes discovering peers via DNS, peers might roll out one-by-one, leaving the DNS entries unpopulated for the first peer of a set. Failing on initial join prevents a roll-out. Instead of failing on the initial join this patch only logs the failure. The cluster can be later joined via the `handleReconnect`. This is a regression introduced in PR prometheus#1456 [1]. [1] prometheus#1456
Alertmanager is exiting with a non-zero exit code if the initial cluster join fails. This behavior could be not wanted because: - As Alertmanager is a critical component with an at-least-once guarantee, failing on joining the cluster is unnecessary as Alertmanager still functions by itself. - In an environment like Kubernetes discovering peers via DNS, peers might roll out one-by-one, leaving the DNS entries unpopulated for the first peer of a set. Failing on initial join prevents a roll-out. Instead of failing on the initial join this patch only logs the failure. The cluster can be later joined via the `handleReconnect`. This is a regression introduced in PR prometheus#1456 [1]. [1] prometheus#1456 Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
Alertmanager is exiting with a non-zero exit code if the initial cluster join fails. This behavior could be not wanted because: - As Alertmanager is a critical component with an at-least-once guarantee, failing on joining the cluster is unnecessary as Alertmanager still functions by itself. - In an environment like Kubernetes discovering peers via DNS, peers might roll out one-by-one, leaving the DNS entries unpopulated for the first peer of a set. Failing on initial join prevents a roll-out. Instead of failing on the initial join this patch only logs the failure. The cluster can be later joined via the `handleReconnect`. This is a regression introduced in PR #1456 [1]. [1] #1456 Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
Alertmanager is exiting with a non-zero exit code if the initial cluster join fails. This behavior could be not wanted because: - As Alertmanager is a critical component with an at-least-once guarantee, failing on joining the cluster is unnecessary as Alertmanager still functions by itself. - In an environment like Kubernetes discovering peers via DNS, peers might roll out one-by-one, leaving the DNS entries unpopulated for the first peer of a set. Failing on initial join prevents a roll-out. Instead of failing on the initial join this patch only logs the failure. The cluster can be later joined via the `handleReconnect`. This is a regression introduced in PR prometheus#1456 [1]. [1] prometheus#1456 Signed-off-by: Max Leonard Inden <IndenML@gmail.com>
During the join, memberlist initiates a pushPull to get initial data.
Unfortunately, at this point the nflog and silence listener have not
been registered yet, so the first data arrives only after one pushPull
cycle (1min by default !).