Merge branch 'packaging'
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 15 May 2014 11:39:29 +0000 (13:39 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Thu, 15 May 2014 11:39:29 +0000 (13:39 +0200)
nodemanager.spec
plugins/interfaces.py
plugins/vsys.py
sliver_lxc.py
tools.py

index ac6a08c..22c79b1 100644 (file)
@@ -2,7 +2,7 @@
 
 %define name nodemanager-lib
 %define version 5.2
-%define taglevel 12
+%define taglevel 13
 
 %define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}}
 
@@ -245,6 +245,10 @@ nodemanager-vs provides the vserver code for the PlanetLab Node Manager.
 
 ##############################
 %changelog
+* Mon Apr 28 2014 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - nodemanager-5.2-13
+- improve network management in slices
+- _has_systemctl was not declared as global - vsys was failing to restart
+
 * Fri Apr 04 2014 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - nodemanager-5.2-12
 - this tag for the first time passes the full range of tests on fedora20
 - robustified slice teardown wrt vsys
index fb7c6e3..6927b23 100644 (file)
@@ -31,6 +31,14 @@ def GetSlivers(data, config=None, plc=None):
 
     for sliver in data['slivers']:
         slicename = sliver['name']
+
+        if not os.path.exists("/vservers/%s" % slicename):
+            # Avoid creating slice directory if slice does not exist, as it
+            # breaks slice creation when sliver_lxc eventually gets around
+            # to creating the sliver.
+            logger.log("vserver %s does not exist yet. Skipping interfaces." % slicename)
+            continue
+
         for tag in sliver['attributes']:
             if tag['tagname'] == 'interface':
                 interfaces = eval(tag['value'])
@@ -81,7 +89,7 @@ def GetSlivers(data, config=None, plc=None):
                         logger.log('interfaces (%s): error writing file %s' % (slicename, dest))
                         continue
 
-                    result = logger.log_call(['/usr/sbin/lxcsu', slicename, '/sbin/service network restart'])
+                    result = logger.log_call(['/usr/sbin/lxcsu', slicename, '/sbin/service', 'network', 'restart'])
                     if not result:
                         logger.log('interfaces (%s): error restarting network service' % slicename)
 #                    try:
index 96582a7..f631d95 100644 (file)
@@ -1,7 +1,9 @@
 """vsys configurator.  Maintains ACLs and script pipes inside vservers based on slice attributes."""
 
-import logger
 import os
+import subprocess
+
+import logger
 import tools
 
 VSYSCONF="/etc/vsys.conf"
@@ -174,5 +176,5 @@ def trashVsysHandleInSliver (sliver):
     if not os.path.exists(slice_vsys_area):
         logger.log("vsys.trashVsysHandleInSliver: no action needed, %s not found"%slice_vsys_area)
         return
-    ret=subprocess.call([ 'rm', '-rf' , slice_vsys_area])
+    retcod=subprocess.call([ 'rm', '-rf' , slice_vsys_area])
     logger.log ("vsys.trashVsysHandleInSliver: Removed %s (retcod=%s)"%(slice_vsys_area,retcod))
index 7db1a78..a08b0ce 100644 (file)
@@ -282,38 +282,51 @@ unset pathmunge
 
         containerDir = Sliver_LXC.CON_BASE_DIR + '/%s'%(name)
 
+        # Slivers with vsys running will fail the subvolume delete
+        # A more permanent solution may be to ensure that the vsys module
+        # is called before the sliver is destroyed.
+        removeSliverFromVsys (name)
+
         try:
             # Destroy libvirt domain
             dom = conn.lookupByName(name)
         except:
-            logger.verbose('sliver_lxc: Domain %s does not exist!' % name)
+            logger.verbose('sliver_lxc.destroy: Domain %s does not exist!' % name)
+            return
 
         try:
+            logger.log("sliver_lxc.destroy: destroying domain %s"%name)
             dom.destroy()
         except:
-            logger.verbose('sliver_lxc: Domain %s not running... continuing.' % name)
+            logger.verbose('sliver_lxc.destroy: Domain %s not running... continuing.' % name)
 
         try:
+            logger.log("sliver_lxc.destroy: undefining domain %s"%name)
             dom.undefine()
         except:
-            logger.verbose('sliver_lxc: Domain %s is not defined... continuing.' % name)
+            logger.verbose('sliver_lxc.destroy: Domain %s is not defined... continuing.' % name)
 
         # Remove user after destroy domain to force logout
         command = ['/usr/sbin/userdel', '-f', '-r', name]
         logger.log_call(command, timeout=15*60)
 
-        # Slivers with vsys running will fail the subvolume delete.
-        # A more permanent solution may be to ensure that the vsys module
-        # is called before the sliver is destroyed.
-        removeSliverFromVsys (name)
-
         # Remove rootfs of destroyed domain
         command = ['btrfs', 'subvolume', 'delete', containerDir]
         logger.log_call(command, timeout=60)
 
-        if os.path.exists(containerDir):
-           # oh no, it's still here...
-           logger.log("WARNING: failed to destroy container %s" % containerDir)
+        if not os.path.exists(containerDir):
+            logger.log('sliver_lxc.destroy: %s cleanly destroyed.'%name)
+        else:
+            # oh no, it's still here...
+            logger.log("sliver_lxc.destroy: 1st warning: could not delete %s" % containerDir)
+            # this is for debugging but does not seem to be of much use
+            logger.log_call (['lsof'])
+            # what I can see on running nodes is that a second subvolume delete seems to do the trick here
+            # so let's check if that could be a workaround
+            logger.log("sliver_lxc.destroy: 2nd attempt at btrfs subvolume delete %s" % containerDir)
+            command = ['btrfs', 'subvolume', 'delete', containerDir]
+            logger.log_call(command, timeout=60)
+            if not os.path.exists(containerDir):
+                logger.log("sliver_lxc.destroy: WARNING: failed to delete %s after 2 attempts"%containerDir)
 
-        logger.verbose('sliver_libvirt: %s destroyed.'%name)
 
index 334f33f..02e2ab9 100644 (file)
--- a/tools.py
+++ b/tools.py
@@ -314,6 +314,7 @@ def get_node_virt ():
 # cache result in memory as _has_systemctl
 _has_systemctl=None
 def has_systemctl ():
+    global _has_systemctl
     if _has_systemctl is None:
         _has_systemctl = (subprocess.call([ 'systemctl', '--help' ]) == 0)
     return _has_systemctl