Set up the configuration client properly on non-masters
authorPetr Pudlak <pudlak@google.com>
Thu, 2 Jul 2015 09:29:28 +0000 (11:29 +0200)
committerPetr Pudlak <pudlak@google.com>
Fri, 3 Jul 2015 07:56:08 +0000 (09:56 +0200)
If the configuration client is opened in the 'accept_foreign' mode,
meaning it is running on a non-master node temporarily, the option
needs to be propagated to the RPC client as well.

This fixes issue #1115.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

lib/config.py

index fc5a11a..fbd953f 100644 (file)
@@ -102,7 +102,12 @@ def GetConfig(ec_id, livelock, **kwargs):
 
   """
   kwargs['wconfdcontext'] = GetWConfdContext(ec_id, livelock)
-  kwargs['wconfd'] = wc.Client()
+
+  # if the config is to be opened in the accept_foreign mode, we should
+  # also tell the RPC client not to check for the master node
+  accept_foreign = kwargs.get('accept_foreign', False)
+  kwargs['wconfd'] = wc.Client(allow_non_master=accept_foreign)
+
   return ConfigWriter(**kwargs)