Disable forking in the master daemon
authorIustin Pop <iustin@google.com>
Tue, 29 Apr 2008 07:37:10 +0000 (07:37 +0000)
committerIustin Pop <iustin@google.com>
Tue, 29 Apr 2008 07:37:10 +0000 (07:37 +0000)
This patch adds a mechanism to disable utils.RunCmd in selected
programs. This is needed in the master daemon unless we confirm
threading doesn't pose any problems.

This makes cluster init fail, but creating new trunk clusters is anyway
broken at the moment.

Reviewed-by: ultrotter

daemons/ganeti-masterd
lib/utils.py

index 24f5ccd..8b8dc1a 100644 (file)
@@ -332,6 +332,7 @@ def main():
 
   options, args = ParseOptions()
   utils.debug = options.debug
+  utils.no_fork = True
 
   CheckMaster(options.debug)
 
index 733ac26..72a2622 100644 (file)
@@ -51,6 +51,7 @@ _locksheld = []
 _re_shell_unquoted = re.compile('^[-.,=:/_+@A-Za-z0-9]+$')
 
 debug = False
+no_fork = False
 
 
 class RunResult(object):
@@ -219,6 +220,9 @@ def RunCmd(cmd):
   Returns: `RunResult` instance
 
   """
+  if no_fork:
+    raise errors.ProgrammerError("utils.RunCmd() called with fork() disabled")
+
   if isinstance(cmd, list):
     cmd = [str(val) for val in cmd]
     strcmd = " ".join(cmd)