Skip to content

Commit

Permalink
Look at all active hosts to detect if replset init is successfully ended
Browse files Browse the repository at this point in the history
  • Loading branch information
h-haaks committed Apr 21, 2024
1 parent f9957b3 commit 24bb055
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/puppet/provider/mongodb_replset/mongo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,15 @@ def create_replica_set(alive_hosts)
retry_sleep = 3

retry_limit.times do |n|
if db_ismaster(alive_hosts[0]['host'])['ismaster']
Puppet.debug 'Replica set initialization has successfully ended'
return true
else
Puppet.debug "Waiting for replica initialization. Retry: #{n}"
sleep retry_sleep
next
alive_hosts.each do |alive_host|
if db_ismaster(alive_host['host'])['ismaster']
Puppet.debug 'Replica set initialization has successfully ended'
return true
else
Puppet.debug "Waiting for replica initialization. Retry: #{n}"
sleep retry_sleep
next
end
end
end
raise Puppet::Error, "rs.initiate() failed for replicaset #{name}"
Expand Down

0 comments on commit 24bb055

Please sign in to comment.