Skip to content

Add a retry block when hosts are added to replset#436

Merged
bastelfreak merged 3 commits intovoxpupuli:masterfrom
pkilambi:master
Jan 5, 2018
Merged

Add a retry block when hosts are added to replset#436
bastelfreak merged 3 commits intovoxpupuli:masterfrom
pkilambi:master

Conversation

@pkilambi
Copy link
Copy Markdown

@pkilambi pkilambi commented Jan 5, 2018

There is a race condition here where, if the master has changed since
the replset host add will fail. This can happen when scaling out of nodes
or when master is being migrated.

Adding a retry block here will give the hosts a chance to join the
cluster while the master is coming up.

Pradeep Kilambi added 2 commits January 5, 2018 10:14
There is a race condition here where, if the master has changed since
the replset host add will fail. This happens during scale out of nodes
or when master is being migrated.

Adding a retry block here will give the hosts a chance to join the
cluster while the master is coming up.
output = {}
output = rs_arbiter == host ? rs_add_arbiter(host, master) : rs_add(host, master)
retry_limit.times do |n|
begin
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can drop lines 246, 257 (new begin-end scope block is implied by the times do |n| loop)

Puppet.debug "Retry adding host to replicaset. Retry: #{n}"
sleep retry_sleep
master = master_host(alive_hosts)
next
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can drop the next too, as it doesn't skip anything and the loop will progress to the next iteration by itself.

@bastelfreak bastelfreak added the bug Something isn't working label Jan 5, 2018
@bastelfreak
Copy link
Copy Markdown
Member

Thanks for the PR @pkilambi and thanks for review @jistr !

@bastelfreak bastelfreak merged commit 951b8a2 into voxpupuli:master Jan 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants