This removes the use of ConfigSync in AllocatePort

Signed-off-by: BSRK Aditya <[email protected]>
---
 lib/config/__init__.py | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/lib/config/__init__.py b/lib/config/__init__.py
index 2f471d9..4c2d166 100644
--- a/lib/config/__init__.py
+++ b/lib/config/__init__.py
@@ -1153,26 +1153,17 @@ class ConfigWriter(object):
     """
     return self._ConfigData().cluster.tcpudp_port_pool.copy()
 
-  @ConfigSync()
   def AllocatePort(self):
-    """Allocate a port.
-
-    The port will be taken from the available port pool or from the
-    default port range (and in this case we increase
-    highest_used_port).
+    """Allocate a port."""
+    def withException():
+      port = self._wconfd.AllocatePort()
+      self.OutDate()
 
-    """
-    # If there are TCP/IP ports configured, we use them first.
-    if self._ConfigData().cluster.tcpudp_port_pool:
-      port = self._ConfigData().cluster.tcpudp_port_pool.pop()
-    else:
-      port = self._ConfigData().cluster.highest_used_port + 1
-      if port >= constants.LAST_DRBD_PORT:
-        raise errors.ConfigurationError("The highest used port is greater"
-                                        " than %s. Aborting." %
-                                        constants.LAST_DRBD_PORT)
-      self._ConfigData().cluster.highest_used_port = port
-    return port
+      if port is None:
+        raise utils.RetryAgain()
+      else:
+        return port
+    return utils.Retry(withException, 0.1, 30)
 
   @ConfigSync(shared=1)
   def ComputeDRBDMap(self):
-- 
2.2.0.rc0.207.ga3a616c

Reply via email to