Ian Main
2009-Mar-05 20:43 UTC
[Ovirt-devel] [PATCH server] Keep trying to get DNS SRV records in taskomatic and dbomatic.
The last patch made it so we only try 4 times to get the DNS SRV records before giving up in *omatic. This patch makes them retry indefinitely. Signed-off-by: Ian Main <imain at redhat.com> --- src/db-omatic/db_omatic.rb | 10 +++++----- src/task-omatic/taskomatic.rb | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/db-omatic/db_omatic.rb b/src/db-omatic/db_omatic.rb index 678b1cb..8e62f54 100755 --- a/src/db-omatic/db_omatic.rb +++ b/src/db-omatic/db_omatic.rb @@ -78,15 +78,15 @@ class DbOmatic < Qpid::Qmf::Console database_connect server, port = nil - (1..4).each do + sleepy = 5 + while true do server, port = get_srv('qpidd', 'tcp') break if server - @logger.error "Unable to determine qpid server from DNS SRV record" if not server - sleep(10) + @logger.error "Unable to determine qpid server from DNS SRV record, retrying.." if not server + sleep(sleepy) + sleepy *= 2 if sleepy < 120 end - raise "Unable to determine server and port from DNS SRV records" if not server - @logger.info "Connecting to amqp://#{server}:#{port}" @session = Qpid::Qmf::Session.new(:console => self, :manage_connections => true) @broker = @session.add_broker("amqp://#{server}:#{port}", :mechanism => 'GSSAPI') diff --git a/src/task-omatic/taskomatic.rb b/src/task-omatic/taskomatic.rb index eb8e2ae..67c1369 100755 --- a/src/task-omatic/taskomatic.rb +++ b/src/task-omatic/taskomatic.rb @@ -98,11 +98,13 @@ class TaskOmatic ensure_credentials server, port = nil - (1..4).each do + sleepy = 5 + while true do server, port = get_srv('qpidd', 'tcp') break if server - @logger.error "Unable to determine qpid server from DNS SRV record" if not server - sleep(10) + @logger.error "Unable to determine qpid server from DNS SRV record, retrying.." if not server + sleep(sleepy) + sleepy *= 2 if sleepy < 120 end @session = Qpid::Qmf::Session.new(:manage_connections => true) -- 1.6.0.6