While running "gnt-node list", if a query to ConfD fails (especially because of permission problems) it used to just fail silently, with gnt-node showing question marks instead of data.
With this patch, ConfD records the error in its log file, together with a message giving an indication of the reason. Fixes Issue 517. Signed-off-by: Michele Tartara <mtart...@google.com> --- src/Ganeti/Query/Node.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Ganeti/Query/Node.hs b/src/Ganeti/Query/Node.hs index 293ceb7..8e7c91d 100644 --- a/src/Ganeti/Query/Node.hs +++ b/src/Ganeti/Query/Node.hs @@ -36,6 +36,7 @@ import qualified Data.Map as Map import qualified Text.JSON as J import Ganeti.Config +import Ganeti.Logging import Ganeti.Objects import Ganeti.JSON import Ganeti.Rpc @@ -214,6 +215,19 @@ fieldsMap :: FieldMap Node Runtime fieldsMap = Map.fromList $ map (\v@(f, _, _) -> (fdefName f, v)) nodeFields +-- | Scan the list of results produced by executeRpcCall and log all the RPC +-- errors. +logRpcErrors :: [(Node, Runtime)] -> IO () +logRpcErrors [] = return () +logRpcErrors (x:xs) = do + let logOneRpcErr (_, Right _) = return () + logOneRpcErr (_, Left err) = do + logError $ "Error in the RPC HTTP reply: " ++ show err + return () + logOneRpcErr x + logRpcErrors xs + + -- | Collect live data from RPC query if enabled. -- -- FIXME: Check which fields we actually need and possibly send empty @@ -233,6 +247,7 @@ collectLiveData True cfg nodes = do Nothing -> (n : bn, gn, em) (bnodes, gnodes, emap) = foldr step ([], [], []) nodes rpcres <- executeRpcCall gnodes (RpcCallNodeInfo vgs hvs (Map.fromList emap)) + logRpcErrors rpcres -- FIXME: The order of nodes in the result could be different from the input return $ zip bnodes (repeat $ Left (RpcResultError "Broken configuration")) ++ rpcres -- 1.7.10.4