Change in vdsm[master]: netconf: differentiate between MEMORY and PERSISTENT rollback

asegurap at redhat.com asegurap at redhat.com
Thu Nov 28 14:44:38 UTC 2013


Antoni Segura Puimedon has uploaded a new change for review.

Change subject: netconf: differentiate between MEMORY and PERSISTENT rollback
......................................................................

netconf: differentiate between MEMORY and PERSISTENT rollback

The change:
    "netconf: Add limit to rollback for recursive configurator"
Added a last resort to the rollback that consists on rolling back to
the last persisted configuration. That however meant that an eventual
failure in the setupNetworks commands issued in
vdsm-restore-net-config would be attempted to rollback, probably
going also for the last restort, effectively making this a probably
infinite loop.

This patch addresses the issue by marking vdsm-restore-net-config
setupNetworks commands as PERSISTENT_ROLLBACK and qualifying thusly
marked rollback operations as final.

Change-Id: Ib841d5c431bb64574398d41ad34aed32c734e03c
Signed-off-by: Antoni S. Puimedon <asegurap at redhat.com>
---
M vdsm/configNetwork.py
M vdsm/netconf/__init__.py
M vdsm/vdsm-restore-net-config
3 files changed, 25 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/41/21841/1

diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py
index 3afcb4e..21a49c7 100755
--- a/vdsm/configNetwork.py
+++ b/vdsm/configNetwork.py
@@ -537,7 +537,8 @@
                         force=0|1
                         connectivityCheck=0|1
                         connectivityTimeout=<int>
-                        inRollback=True|False
+                        inRollback=None|netconf.MEMORY_ROLLBACK|
+                                   netconf.PERSISTENT_ROLLBACK
 
     Notes:
         When you edit a network that is attached to a bonding, it's not
@@ -561,7 +562,7 @@
     hooks.before_network_setup()
 
     logger.debug("Applying...")
-    with Ifcfg(options.get('inRollback', False)) as configurator:
+    with Ifcfg(options.get('inRollback')) 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 50934a5..233bd13 100644
--- a/vdsm/netconf/__init__.py
+++ b/vdsm/netconf/__init__.py
@@ -24,13 +24,19 @@
 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
+from vdsm.tools import restore_nets
+
+PERSISTENT_ROLLBACK = 1
+MEMORY_ROLLBACK = 2
+
+
+class RollbackIncomplete(Exception):
+    pass
 
 
 class Configurator(object):
-    def __init__(self, configApplier, inRollback=False):
+    def __init__(self, configApplier, inRollback=None):
         self.configApplier = configApplier
         self._inRollback = inRollback
         self._libvirtAdded = set()
@@ -46,13 +52,18 @@
     def __exit__(self, type, value, traceback):
         if type is None:
             self.commit()
-        elif self._inRollback:
+        elif self._inRollback == MEMORY_ROLLBACK:
             # 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:
+            try:
+                restore_nets.restore()
+            except Exception as err:
                 logging.error('Failed rollback transaction and restoration to '
                               'last known good network. ERR=%s', err)
+        elif self._inRollback == PERSISTENT_ROLLBACK:
+            # If we are trying to rollback from a persistent rollback
+            # transaction we should just give up and fail.
+            logging.error('Failed persistent rollback transaction.')
         else:
             self.rollback()
 
diff --git a/vdsm/vdsm-restore-net-config b/vdsm/vdsm-restore-net-config
index 29b2a8d..46c1d62 100755
--- a/vdsm/vdsm-restore-net-config
+++ b/vdsm/vdsm-restore-net-config
@@ -22,7 +22,7 @@
 import logging
 import logging.config
 
-from netconf import ifcfg
+from netconf import ifcfg, PERSISTENT_ROLLBACK
 from vdsm.config import config
 from vdsm.netconfpersistence import RunningConfig, PersistentConfig
 from configNetwork import setupNetworks
@@ -48,7 +48,8 @@
         removeBonds[bond] = {'remove': True}
     logging.debug('Removing all networks (%s) and bonds (%s) in running '
                   'config.', removeNetworks, removeBonds)
-    setupNetworks(removeNetworks, removeBonds, connectivityCheck=False)
+    setupNetworks(removeNetworks, removeBonds, connectivityCheck=False,
+                  inRollback=PERSISTENT_ROLLBACK)
 
     configurator.flush()
     persistentConfig = PersistentConfig()
@@ -56,7 +57,8 @@
     bonds = persistentConfig.bonds
     logging.debug('Calling setupNetworks with networks (%s) and bond (%s).',
                   nets, bonds)
-    setupNetworks(nets, bonds, connectivityCheck=False)
+    setupNetworks(nets, bonds, connectivityCheck=False,
+                  inRollback=PERSISTENT_ROLLBACK)
 
 
 def restore():


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib841d5c431bb64574398d41ad34aed32c734e03c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap at redhat.com>


More information about the vdsm-patches mailing list