LGTM, thanks On Tue, 24 Mar 2015 at 14:35 'Klaus Aehlig' via ganeti-devel < [email protected]> wrote:
> If we cannot connect to a socket, first verify that we are > actually running on master before retrying. In this way, we > can report to the user quickly without adding additional > overhead to the intended use case. > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > lib/rpc/transport.py | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/lib/rpc/transport.py b/lib/rpc/transport.py > index e0cb1a0..6112627 100644 > --- a/lib/rpc/transport.py > +++ b/lib/rpc/transport.py > @@ -42,6 +42,8 @@ import socket > import time > > from ganeti import constants > +import ganeti.errors > +from ganeti import ssconf > from ganeti import utils > from ganeti.rpc import errors > > @@ -117,6 +119,15 @@ class Transport: > except socket.error, err: > error_code = err.args[0] > if error_code in (errno.ENOENT, errno.ECONNREFUSED): > + # Verify if we're acutally on the master node before trying > + # again. > + ss = ssconf.SimpleStore() > + try: > + master, myself = ssconf.GetMasterAndMyself(ss=ss) > + except ganeti.errors.ConfigurationError: > + raise errors.NoMasterError(address) > + if master != myself: > + raise errors.NoMasterError(address) > raise utils.RetryAgain() > elif error_code in (errno.EPERM, errno.EACCES): > raise errors.PermissionError(address) > -- > 2.2.0.rc0.207.ga3a616c > >
