From 186c03b356a3d351520645293c981a3a5ecb2241 Mon Sep 17 00:00:00 2001
From: Andrea Spadaccini <spadaccio@google.com>
Date: Fri, 4 Nov 2011 13:33:59 +0000
Subject: [PATCH] Fix cluster start failure due to missing netmask
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If the cluster version is upgraded from a version before commit
5a8648eb609f7e3a8d7ad7f82e93cfdd467a8fb5 to a version after that commit,
the master startup will fail because the ssconf file with the master
netmask will not be present, and it is read during the master voting
process.

This patch fixes this bug, making ssconf.GetMasterNetmask return a
default netmask value, and also corrects the docstring of this method.

Signed-off-by: Andrea Spadaccini <spadaccio@google.com>
Reviewed-by: RenΓ© Nussbaumer <rn@google.com>
---
 lib/ssconf.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/ssconf.py b/lib/ssconf.py
index 67d903c17..babd148e6 100644
--- a/lib/ssconf.py
+++ b/lib/ssconf.py
@@ -413,10 +413,15 @@ class SimpleStore(object):
     return self._ReadFile(constants.SS_MASTER_NETDEV)
 
   def GetMasterNetmask(self):
-    """Get the netdev to which we'll add the master ip.
+    """Get the master netmask.
 
     """
-    return self._ReadFile(constants.SS_MASTER_NETMASK)
+    try:
+      return self._ReadFile(constants.SS_MASTER_NETMASK)
+    except errors.ConfigurationError:
+      family = self.GetPrimaryIPFamily()
+      ipcls = netutils.IPAddress.GetClassFromIpFamily(family)
+      return ipcls.iplen
 
   def GetMasterNode(self):
     """Get the hostname of the master node for this cluster.
-- 
GitLab