Fix renew-crypto on one-node-cluster
authorHelga Velroyen <helgav@google.com>
Wed, 16 Dec 2015 10:03:23 +0000 (11:03 +0100)
committerHelga Velroyen <helgav@google.com>
Thu, 7 Jan 2016 13:33:33 +0000 (14:33 +0100)
There was a bug which made 'gnt-cluster renew-crypto'
crash if it is a one-node cluster. This patch fixes
it by checking if there are any non-master nodes
to update at all.

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

lib/backend.py
test/py/ganeti.backend_unittest.py

index 251b07a..4d3a2dd 100644 (file)
@@ -1502,12 +1502,6 @@ def AddNodeSshKeyBulk(node_list,
                             node_list])
   to_public_keys = any([node_info.to_public_keys for node_info in
                         node_list])
-  get_public_keys = any([node_info.get_public_keys for node_info in
-                         node_list])
-
-  # assure that at least one of those flags is true, as the function would
-  # not do anything otherwise
-  assert (to_authorized_keys or to_public_keys or get_public_keys)
 
   if not ssconf_store:
     ssconf_store = ssconf.SimpleStore()
index 3de4293..17e7dc7 100755 (executable)
@@ -1239,8 +1239,7 @@ class TestAddRemoveGenerateNodeSshKey(testutils.GanetiTestCase):
         is_potential_master_candidate, is_master_candidate,
         is_master)
 
-    self.assertRaises(
-        AssertionError, backend.AddNodeSshKey, new_node_uuid, new_node_name,
+    backend.AddNodeSshKey(new_node_uuid, new_node_name,
         self._potential_master_candidates,
         to_authorized_keys=is_master_candidate,
         to_public_keys=is_potential_master_candidate,
@@ -1258,8 +1257,7 @@ class TestAddRemoveGenerateNodeSshKey(testutils.GanetiTestCase):
     (node_list, key_map) = self._SetupNodeBulk(
         num_nodes, self._GetNewNumberedNormalNode)
 
-    self.assertRaises(
-        AssertionError, backend.AddNodeSshKeyBulk, node_list,
+    backend.AddNodeSshKeyBulk(node_list,
         self._potential_master_candidates,
         pub_key_file=self._pub_key_file,
         ssconf_store=self._ssconf_mock,