Package: ganeti-2.15 / 2.15.2-15

0014-fix-ssh-key-renewal-on-single-node-clusters.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From: Apollon Oikonomopoulos <apoikos@debian.org>
Date: Wed, 24 May 2017 16:15:54 +0300
Subject: backend: make SSH key renewal work on single-node clusters

Currently gnt-cluster renew-crypt will unconditionally call
AddNodeSshKeyBulk() to replace non-master node keys, regardless of
whether there are non-master nodes or not. OTOH, AddNodeSshKeyBulk()
expects that at least one operation should be perfomed and dies with an
assertion error otherwise. Thus, on single node clusters, where there is
only a single master node, gnt-cluster renew-crypto --new-ssh-keys will
always fail.

Fix this by calling AddNodeSshKeyBulk only if node_keys_to_add is not
empty.
---
 lib/backend.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/backend.py b/lib/backend.py
index 9b363d2..89e93e0 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -2100,13 +2100,14 @@ def RenewSshKeys(node_uuids, node_names, master_candidate_uuids,
                                get_public_keys=True)
     node_keys_to_add.append(node_info)
 
-  node_errors = AddNodeSshKeyBulk(
-      node_keys_to_add, potential_master_candidates,
-      pub_key_file=ganeti_pub_keys_file, ssconf_store=ssconf_store,
-      noded_cert_file=noded_cert_file,
-      run_cmd_fn=run_cmd_fn)
-  if node_errors:
-    all_node_errors = all_node_errors + node_errors
+  if node_keys_to_add:
+    node_errors = AddNodeSshKeyBulk(
+        node_keys_to_add, potential_master_candidates,
+        pub_key_file=ganeti_pub_keys_file, ssconf_store=ssconf_store,
+        noded_cert_file=noded_cert_file,
+        run_cmd_fn=run_cmd_fn)
+    if node_errors:
+      all_node_errors = all_node_errors + node_errors
 
   # Renewing the master node's key