EnsureKvmdOnNodes is called to make sure ganeti-kvmd is running/stopped
according to the desired configuration. This patch silences the KVM
related warnings in situations:
- node addition (irrespectively of whether kvm is enabled or not),
- parameter changes where kvm is disabled both before and after the change.

Signed-off-by: Viktor Bachraty <[email protected]>
---
 lib/cmdlib/cluster/__init__.py |  6 +++++-
 lib/cmdlib/common.py           | 12 ++++++++----
 lib/cmdlib/node.py             | 10 ++++++++--
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/lib/cmdlib/cluster/__init__.py b/lib/cmdlib/cluster/__init__.py
index 5c47cc3..8763e2b 100644
--- a/lib/cmdlib/cluster/__init__.py
+++ b/lib/cmdlib/cluster/__init__.py
@@ -1664,6 +1664,10 @@ class LUClusterSetParams(LogicalUnit):
     self.cluster = self.cfg.GetClusterInfo()
 
     ensure_kvmd = False
+    stop_kvmd_silently = not (
+        constants.HT_KVM in self.cluster.enabled_hypervisors or
+        (self.op.enabled_hypervisors is not None and
+         constants.HT_KVM in self.op.enabled_hypervisors))
 
     active = constants.DATA_COLLECTOR_STATE_ACTIVE
     if self.op.enabled_data_collectors is not None:
@@ -1832,7 +1836,7 @@ class LUClusterSetParams(LogicalUnit):
     # this will update the cluster object and sync 'Ssconf', and kvmd
     # uses 'Ssconf'.
     if ensure_kvmd:
-      EnsureKvmdOnNodes(self, feedback_fn)
+      EnsureKvmdOnNodes(self, feedback_fn, silent_stop=stop_kvmd_silently)
 
     if self.op.compression_tools is not None:
       self.cfg.SetCompressionTools(self.op.compression_tools)
diff --git a/lib/cmdlib/common.py b/lib/cmdlib/common.py
index 2c44ac7..96b3e04 100644
--- a/lib/cmdlib/common.py
+++ b/lib/cmdlib/common.py
@@ -1535,7 +1535,7 @@ def DetermineImageSize(lu, image, node_uuid):
   return math.ceil(byte_size / 1024. / 1024.)
 
 
-def EnsureKvmdOnNodes(lu, feedback_fn, nodes=None):
+def EnsureKvmdOnNodes(lu, feedback_fn, nodes=None, silent_stop=False):
   """Ensure KVM daemon is running on nodes with KVM instances.
 
   If user shutdown is enabled in the cluster:
@@ -1558,6 +1558,9 @@ def EnsureKvmdOnNodes(lu, feedback_fn, nodes=None):
   @param nodes: if supplied, it overrides the node uuids to start/stop;
                 this is used mainly for optimization
 
+  @type silent_stop: bool
+  @param silent_stop: if we should issue a warning in case KVM daemon is 
already
+                      stopped
   """
   cluster = lu.cfg.GetClusterInfo()
 
@@ -1592,9 +1595,10 @@ def EnsureKvmdOnNodes(lu, feedback_fn, nodes=None):
   # Stop KVM where necessary
   if stop_nodes:
     results = lu.rpc.call_node_ensure_daemon(stop_nodes, constants.KVMD, False)
-    for node_uuid in stop_nodes:
-      results[node_uuid].Warn("Failed to stop KVM daemon in node '%s'" %
-                              node_uuid, feedback_fn)
+    if not silent_stop:
+      for node_uuid in stop_nodes:
+        results[node_uuid].Warn("Failed to stop KVM daemon in node '%s'" %
+                                node_uuid, feedback_fn)
 
 
 def WarnAboutFailedSshUpdates(result, master_uuid, feedback_fn):
diff --git a/lib/cmdlib/node.py b/lib/cmdlib/node.py
index ddae675..8f3e239 100644
--- a/lib/cmdlib/node.py
+++ b/lib/cmdlib/node.py
@@ -469,7 +469,9 @@ class LUNodeAdd(LogicalUnit):
     else:
       self.cfg.RemoveNodeFromCandidateCerts(self.new_node.uuid, warn_fn=None)
 
-    EnsureKvmdOnNodes(self, feedback_fn, nodes=[self.new_node.uuid])
+    # Ensure, that kvmd is in the expected state on the added node.
+    EnsureKvmdOnNodes(self, feedback_fn, nodes=[self.new_node.uuid],
+                      silent_stop=True)
 
     # Update SSH setup of all nodes
     if self.op.node_setup:
@@ -857,7 +859,11 @@ class LUNodeSetParams(LogicalUnit):
       if self.old_role == self._ROLE_CANDIDATE:
         RemoveNodeCertFromCandidateCerts(self.cfg, node.uuid)
 
-    EnsureKvmdOnNodes(self, feedback_fn, nodes=[node.uuid])
+    # KVM configuration never changes here, so disable warnings if KVM 
disabled.
+    silent_stop = constants.HT_KVM not in \
+        self.cfg.GetClusterInfo().enabled_hypervisors
+    EnsureKvmdOnNodes(self, feedback_fn, nodes=[node.uuid],
+                      silent_stop=silent_stop)
 
     # this will trigger job queue propagation or cleanup if the mc
     # flag changed
-- 
2.7.0.rc3.207.g0ac5344

Reply via email to