Change in vdsm[master]: net: add documentation for setupNetworks rollback mechanism.

ibarkan at redhat.com ibarkan at redhat.com
Thu Dec 10 14:43:20 UTC 2015


Ido Barkan has uploaded a new change for review.

Change subject: net: add documentation for setupNetworks rollback mechanism.
......................................................................

net: add documentation for setupNetworks rollback mechanism.

Since Ifcfg is both the default implementation and the exception of
this mechanism, a few comments might make this situation less confusing.

Change-Id: I4f7d66f9612ed6762fa80e7aa9e57d914dd65f34
Signed-off-by: Ido Barkan <ibarkan at redhat.com>
---
M lib/vdsm/network/api.py
M lib/vdsm/network/configurators/__init__.py
M lib/vdsm/network/configurators/ifcfg.py
M vdsm/API.py
4 files changed, 17 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/61/50261/1

diff --git a/lib/vdsm/network/api.py b/lib/vdsm/network/api.py
index 4ba04c3..53d3dc2 100755
--- a/lib/vdsm/network/api.py
+++ b/lib/vdsm/network/api.py
@@ -911,6 +911,9 @@
     normalized_config = kernelconfig.normalize(
         netconfpersistence.BaseConfig(networks, bondings))
     with ConfiguratorClass(in_rollback) as configurator:
+        # from this point forward, any exception thrown will be excepted by
+        # Configurator.__exit__.
+
         # Remove edited networks and networks with 'remove' attribute
         for network, attrs in networks.items():
             if network in _netinfo.networks:
diff --git a/lib/vdsm/network/configurators/__init__.py b/lib/vdsm/network/configurators/__init__.py
index f49bdab..a2db924 100644
--- a/lib/vdsm/network/configurators/__init__.py
+++ b/lib/vdsm/network/configurators/__init__.py
@@ -35,6 +35,10 @@
 
 
 class RollbackIncomplete(Exception):
+    """This exception is raised in order to signal API.Global that a call to
+    setupNetworks has failed and there are leftovers that need to be cleaned
+    up.
+    """
     pass
 
 
diff --git a/lib/vdsm/network/configurators/ifcfg.py b/lib/vdsm/network/configurators/ifcfg.py
index 691c22a..550d344 100644
--- a/lib/vdsm/network/configurators/ifcfg.py
+++ b/lib/vdsm/network/configurators/ifcfg.py
@@ -83,6 +83,9 @@
             self.runningConfig = RunningConfig()
 
     def rollback(self):
+        """This reimplementation always returns None since Ifcfg can rollback
+        on its own via restoreBackups(). This makes the general mechanism of
+        API.Global._rollback redundant in this case."""
         self.configApplier.restoreBackups()
         self.configApplier = None
         if self.unifiedPersistence:
diff --git a/vdsm/API.py b/vdsm/API.py
index 99a368b..6bbedbe 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1507,12 +1507,19 @@
         try:
             yield rollbackCtx
         except ConfigNetworkError as e:
+            # Only a configuration error in setupNetworks before any damage
+            # done. No need for cleanup.
             self.log.error(e.message, exc_info=True)
             rollbackCtx['status'] = {'code': e.errCode, 'message': e.message}
         except RollbackIncomplete as roi:
+            # a previous call to setupNetworks (with 'inRollback': False)
+            # failed and we need to try and cleanup.
             config, excType, value = roi
             tb = sys.exc_info()[2]
             try:
+                # config holds the difference between RunningConfig on disk and
+                # the one in memory with the addition of {'remove': True} hence
+                # cleanup is done.
                 supervdsm.getProxy().setupNetworks(
                     config.networks, config.bonds, {'inRollback': True,
                                                     'connectivityCheck': 0})


-- 
To view, visit https://gerrit.ovirt.org/50261
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4f7d66f9612ed6762fa80e7aa9e57d914dd65f34
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ido Barkan <ibarkan at redhat.com>


More information about the vdsm-patches mailing list