From ec5af88844d5c775df703e34f3947b45639eb134 Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Tue, 11 Dec 2012 18:00:25 +0100
Subject: [PATCH] Read watcher pause using RPC, not directly

The master daemon should not directly read files written by the node
daemon. This patch adds a new RPC to read the watcher pause file and
changes the master code to use it.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 lib/cmdlib.py       | 8 +++++++-
 lib/rpc_defs.py     | 2 ++
 lib/server/noded.py | 7 +++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index d29631aea..a0dced12a 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -6530,7 +6530,13 @@ class _ClusterQuery(_QueryBase):
       drain_flag = NotImplemented
 
     if query.CQ_WATCHER_PAUSE in self.requested_data:
-      watcher_pause = utils.ReadWatcherPauseFile(pathutils.WATCHER_PAUSEFILE)
+      master_name = lu.cfg.GetMasterNode()
+
+      result = lu.rpc.call_get_watcher_pause(master_name)
+      result.Raise("Can't retrieve watcher pause from master node '%s'" %
+                   master_name)
+
+      watcher_pause = result.payload
     else:
       watcher_pause = NotImplemented
 
diff --git a/lib/rpc_defs.py b/lib/rpc_defs.py
index 449b50ad8..20c349a7c 100644
--- a/lib/rpc_defs.py
+++ b/lib/rpc_defs.py
@@ -505,6 +505,8 @@ _MISC_CALLS = [
     ("hvname", None, "Hypervisor name"),
     ("hvfull", None, "Parameters to be validated"),
     ], None, None, "Validate hypervisor params"),
+  ("get_watcher_pause", SINGLE, None, constants.RPC_TMO_URGENT, [],
+    None, None, "Get watcher pause end"),
   ("set_watcher_pause", MULTI, None, constants.RPC_TMO_URGENT, [
     ("until", None, None),
     ], None, None, "Set watcher pause end"),
diff --git a/lib/server/noded.py b/lib/server/noded.py
index 0a1d0d6d5..c6d653c3b 100644
--- a/lib/server/noded.py
+++ b/lib/server/noded.py
@@ -827,6 +827,13 @@ class NodeRequestHandler(http.server.HttpServerHandler):
     (values,) = params
     return ssconf.WriteSsconfFiles(values)
 
+  @staticmethod
+  def perspective_get_watcher_pause(params):
+    """Get watcher pause end.
+
+    """
+    return utils.ReadWatcherPauseFile(pathutils.WATCHER_PAUSEFILE)
+
   @staticmethod
   def perspective_set_watcher_pause(params):
     """Set watcher pause.
-- 
GitLab