Commit 87eccd0a authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Retry connections to WConfD



With jobs as processes, it is by design that WConfD might
be restarted while jobs are running. Therefore, retry any
attempt to connect to WConfD several times.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent b9471a8f
......@@ -23,9 +23,14 @@
"""
import logging
import random
import time
import ganeti.rpc.client as cl
import ganeti.rpc.stub.wconfd as stub
from ganeti.rpc.transport import Transport
from ganeti.rpc import errors
class Client(cl.AbstractStubClient, stub.ClientRpcStub):
......@@ -43,4 +48,15 @@ class Client(cl.AbstractStubClient, stub.ClientRpcStub):
"""
cl.AbstractStubClient.__init__(self, timeouts, transport)
stub.ClientRpcStub.__init__(self)
self._InitTransport()
retries = 10
for try_no in range(0, retries):
try:
self._InitTransport()
return
except errors.TimeoutError:
logging.debug("Timout trying to connect to WConfD")
if try_no == retries -1:
raise
logging.debug("Will retry")
time.sleep(10 * random.random())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment