Fix Haskell log file naming after virtual cluster changes
authorIustin Pop <iustin@google.com>
Mon, 4 Feb 2013 13:34:33 +0000 (14:34 +0100)
committerIustin Pop <iustin@google.com>
Tue, 5 Feb 2013 08:36:30 +0000 (09:36 +0100)
Commit 3329f4de changed the Haskell log file from constants to
functions, but introduced a bug: it uses now the daemon name instead
of the correct log file, which means "ganeti-confd.log" instead of
"conf-daemon.log".

In order to fix this, we need to abstract the log file base (in
constants.py) into a separate set of constants, so that we can reuse
it in the Haskell code.

This fixes issue 343.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

lib/constants.py
src/Ganeti/Runtime.hs

index 4e04dff..b99b12c 100644 (file)
@@ -166,13 +166,17 @@ DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
 FIRST_DRBD_PORT = 11000
 LAST_DRBD_PORT = 14999
 
-DAEMONS_LOGFILES = {
-  NODED: pathutils.GetLogFilename("node-daemon"),
-  CONFD: pathutils.GetLogFilename("conf-daemon"),
-  RAPI: pathutils.GetLogFilename("rapi-daemon"),
-  MASTERD: pathutils.GetLogFilename("master-daemon"),
+DAEMONS_LOGBASE = {
+  NODED: "node-daemon",
+  CONFD: "conf-daemon",
+  RAPI: "rapi-daemon",
+  MASTERD: "master-daemon",
   }
 
+DAEMONS_LOGFILES = \
+    dict((daemon, pathutils.GetLogFilename(DAEMONS_LOGBASE[daemon]))
+         for daemon in DAEMONS_LOGBASE)
+
 DEV_CONSOLE = "/dev/console"
 
 PROC_MOUNTS = "/proc/mounts"
index 2ebef2e..33f114c 100644 (file)
@@ -4,7 +4,7 @@
 
 {-
 
-Copyright (C) 2011, 2012 Google Inc.
+Copyright (C) 2011, 2012, 2013 Google Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -75,6 +75,13 @@ daemonName GanetiNoded   = C.noded
 daemonName GanetiRapi    = C.rapi
 daemonName GanetiConfd   = C.confd
 
+-- | Returns the log file base for a daemon.
+daemonLogBase :: GanetiDaemon -> String
+daemonLogBase GanetiMasterd = C.daemonsLogbaseGanetiMasterd
+daemonLogBase GanetiNoded   = C.daemonsLogbaseGanetiNoded
+daemonLogBase GanetiRapi    = C.daemonsLogbaseGanetiRapi
+daemonLogBase GanetiConfd   = C.daemonsLogbaseGanetiConfd
+
 -- | Returns the configured user name for a daemon.
 daemonUser :: GanetiDaemon -> String
 daemonUser GanetiMasterd = C.masterdUser
@@ -95,7 +102,7 @@ daemonGroup (ExtraGroup  AdminGroup)    = C.adminGroup
 daemonLogFile :: GanetiDaemon -> IO FilePath
 daemonLogFile daemon = do
   logDir <- Path.logDir
-  return $ logDir </> daemonName daemon <.> "log"
+  return $ logDir </> daemonLogBase daemon <.> "log"
 
 -- | Returns the pid file name for a daemon.
 daemonPidFile :: GanetiDaemon -> IO FilePath