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 25, 2024
1 parent 97d2fd1 commit d203c12
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/puppet/provider/mongodb_replset/mongo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,14 @@ 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
end
end
Puppet.debug "Waiting for replica initialization. Retry: #{n}"
sleep retry_sleep
end
raise Puppet::Error, "rs.initiate() failed for replicaset #{name}"
end
Expand Down

0 comments on commit d203c12

Please sign in to comment.