Initscript fix.
authorFaiyaz Ahmed <faiyaza@cs.princeton.edu>
Thu, 2 Aug 2007 20:30:05 +0000 (20:30 +0000)
committerFaiyaz Ahmed <faiyaza@cs.princeton.edu>
Thu, 2 Aug 2007 20:30:05 +0000 (20:30 +0000)
Initscripts were failing because vserver config was being updated after chcontext + chroot.  The chroot never had the config file.  Added simple check to avoid config file write after NM fork and after chroot.

python/vserver.py
util-vserver.spec

index 6bddee1..247d66f 100644 (file)
@@ -63,6 +63,7 @@ class VServer:
 
         self.name = name
         self.rlimits_changed = False
+        self.cache = None
         self.config_file = "/etc/vservers/%s.conf" % name
         self.dir = "%s/%s" % (vserverimpl.VSERVER_BASEDIR, name)
         if not (os.path.isdir(self.dir) and
@@ -184,7 +185,7 @@ class VServer:
         os.rename(newfile, filename)
 
     def __do_chroot(self):
-
+        self.cache = True
         os.chroot(self.dir)
         os.chdir("/")
 
@@ -387,17 +388,18 @@ class VServer:
                 # execute each init script in turn
                 # XXX - we don't support all scripts that vserver script does
                 self.__do_chcontext(state_file)
-               for cmd in self.INITSCRIPTS + [None]:
-                       try:
-                           # enter vserver context
-                           arg_subst = { 'runlevel': runlevel }
-                           cmd_args = [cmd[0]] + map(lambda x: x % arg_subst,
-                                           cmd[1:])
-                           print >>log, "executing '%s'" % " ".join(cmd_args)
-                           os.spawnvp(os.P_WAIT,cmd[0],*cmd_args)
-                       except:
-                               traceback.print_exc()
-                               os._exit(1)
+                for cmd in self.INITSCRIPTS + [None]:
+                    try:
+                        print >>log, cmd
+                        # enter vserver context
+                        arg_subst = { 'runlevel': runlevel }
+                        cmd_args = [cmd[0]] + map(lambda x: x % arg_subst,
+                            cmd[1:])
+                        print >>log, "executing '%s'" % " ".join(cmd_args)
+                        os.spawnvp(os.P_WAIT,cmd[0],cmd_args)
+                    except:
+                        traceback.print_exc()
+                        os._exit(1)
 
             # we get here due to an exception in the top-level child process
             except Exception, ex:
@@ -415,11 +417,10 @@ class VServer:
         pass
 
     def update_resources(self, resources):
-
         self.config.update(resources)
-
-        # write new values to configuration file
-        self.__update_config_file(self.config_file, resources)
+        if not self.cache:
+            # write new values to configuration file
+            self.__update_config_file(self.config_file, resources)
 
     def init_disk_info(self):
 
index 11c95ff..915baa0 100644 (file)
@@ -16,8 +16,8 @@
 %{!?release_func:%global release_func() %1%{?dist}}
 
 %define name util-vserver
-%define version 0.30.208
-%define release 20%{?pldistro:.%{pldistro}}%{?date:.%{date}}
+%define version 0.30.209
+%define release 1%{?pldistro:.%{pldistro}}%{?date:.%{date}}
 
 %define _without_dietlibc 1
 %define _without_xalan 1