Antoni Segura Puimedon has uploaded a new change for review.

Change subject: netconf: Add limit to rollback for recursive configurator
......................................................................

netconf: Add limit to rollback for recursive configurator

If a configurator implemented the rollback operation via calling
setupNetworks, we would potentially end up recursing until it
succeeded (and we have no guarantee for success).

This patch adds a parameter to the configurator constructor and
the setupNetworks options that allows the configurator to pass
to setupNetworks inRollback=True when it uses it for rollback
purposes.

Change-Id: Ibd24cfb15f37695d999c66deada9c6dcd6bef574
Signed-off-by: Antoni S. Puimedon <[email protected]>
---
M vdsm/configNetwork.py
M vdsm/netconf/__init__.py
M vdsm/netconf/ifcfg.py
3 files changed, 15 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/15/21615/1

diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py
index 2e29443..3afcb4e 100755
--- a/vdsm/configNetwork.py
+++ b/vdsm/configNetwork.py
@@ -537,6 +537,7 @@
                         force=0|1
                         connectivityCheck=0|1
                         connectivityTimeout=<int>
+                        inRollback=True|False
 
     Notes:
         When you edit a network that is attached to a bonding, it's not
@@ -560,7 +561,7 @@
     hooks.before_network_setup()
 
     logger.debug("Applying...")
-    with Ifcfg() as configurator:
+    with Ifcfg(options.get('inRollback', False)) as configurator:
         libvirt_nets = netinfo.networks()
         # Remove edited networks and networks with 'remove' attribute
         for network, networkAttrs in networks.items():
diff --git a/vdsm/netconf/__init__.py b/vdsm/netconf/__init__.py
index 24cb929..50934a5 100644
--- a/vdsm/netconf/__init__.py
+++ b/vdsm/netconf/__init__.py
@@ -24,12 +24,15 @@
 from sourceRoute import StaticSourceRoute
 from vdsm import netinfo
 from vdsm.config import config
+from vdsm.constants import EXT_VDSM_RESTORE_NET_CONFIG
 from vdsm.netconfpersistence import RunningConfig
+from vdsm.utils import execCmd
 
 
 class Configurator(object):
-    def __init__(self, configApplier):
+    def __init__(self, configApplier, inRollback=False):
         self.configApplier = configApplier
+        self._inRollback = inRollback
         self._libvirtAdded = set()
         self.unifiedPersistence = \
             config.get('vars', 'persistence') == 'unified'
@@ -43,6 +46,13 @@
     def __exit__(self, type, value, traceback):
         if type is None:
             self.commit()
+        elif self._inRollback:
+            # If we failed the rollback transaction, we try to apply the last
+            # known good network configuration, i.e., last persistent.
+            rc, _, err = execCmd(EXT_VDSM_RESTORE_NET_CONFIG, raw=True)
+            if not rc:
+                logging.error('Failed rollback transaction and restoration to '
+                              'last known good network. ERR=%s', err)
         else:
             self.rollback()
 
diff --git a/vdsm/netconf/ifcfg.py b/vdsm/netconf/ifcfg.py
index 1ebd1f4..ac36786 100644
--- a/vdsm/netconf/ifcfg.py
+++ b/vdsm/netconf/ifcfg.py
@@ -44,8 +44,8 @@
 
 class Ifcfg(Configurator):
     # TODO: Do all the configApplier interaction from here.
-    def __init__(self):
-        super(Ifcfg, self).__init__(ConfigWriter())
+    def __init__(self, inRollback=False):
+        super(Ifcfg, self).__init__(ConfigWriter(), inRollback)
 
     def begin(self):
         if self.configApplier is None:


-- 
To view, visit http://gerrit.ovirt.org/21615
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibd24cfb15f37695d999c66deada9c6dcd6bef574
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to