Skip to content
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

Merged
merged 2 commits into from
Jul 9, 2018

Conversation

iksaif
Copy link
Contributor

@iksaif iksaif commented Jul 4, 2018

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 !).

@iksaif iksaif force-pushed the master branch 3 times, most recently from cee9d3e to 58abd4c Compare July 4, 2018 14:26
@clems4ever
Copy link

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>
@@ -206,7 +204,7 @@ func main() {
cancel()
peer.Leave(10 * time.Second)
}()
go peer.Settle(ctx, *gossipInterval*10)
go peer.Settle(ctx, *pushPullInterval)
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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().

Copy link
Contributor Author

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

Copy link
Member

@simonpasquier simonpasquier left a 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.

*peerReconnectTimeout,
)
if err != nil {
level.Error(logger).Log("msg", "Unable to initialize gossip mesh", "err", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/initialize/join/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -263,6 +261,18 @@ func main() {
wg.Wait()
}()

// Peer state listener have been registered, now we can join and get the initial state.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/listener/listeners/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -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)
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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)
Copy link
Member

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().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -206,7 +204,7 @@ func main() {
cancel()
peer.Leave(10 * time.Second)
}()
go peer.Settle(ctx, *gossipInterval*10)
go peer.Settle(ctx, *pushPullInterval)
Copy link
Member

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>
@mxinden
Copy link
Member

mxinden commented Jul 5, 2018

Closes #1457

Copy link
Member

@mxinden mxinden left a 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.

@mxinden mxinden merged commit 42ea9a5 into prometheus:master Jul 9, 2018
@mxinden
Copy link
Member

mxinden commented Jul 9, 2018

@iksaif Thanks for your help!

mxinden pushed a commit to mxinden/alertmanager that referenced this pull request Jul 10, 2018
* 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>
@mxinden mxinden mentioned this pull request Jul 10, 2018
mxinden added a commit to mxinden/alertmanager that referenced this pull request Jul 11, 2018
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
mxinden added a commit to mxinden/alertmanager that referenced this pull request Jul 11, 2018
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>
mxinden added a commit that referenced this pull request Jul 11, 2018
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>
mxinden added a commit to mxinden/alertmanager that referenced this pull request Jul 11, 2018
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants