Change in vdsm[master]: net: Clean running config on unified restoration failure

edwardh at redhat.com edwardh at redhat.com
Sun Apr 17 16:06:32 UTC 2016


Edward Haas has uploaded a new change for review.

Change subject: net: Clean running config on unified restoration failure
......................................................................

net: Clean running config on unified restoration failure

When the unified restoration process fails, running config (file) may
contain networks/bonds that are not in kernel.
When an attempt is made to re-run the unified restoration (without a
boot), the process will fail to remove the mentioned networks/bonds.

In this patch, the running config will be cleared if the restoration
fails, allowing the following attempts to try and setup the network
again.

Change-Id: Ie43da8ca26ef0b0e92ec66e1a481a843aea0487f
Bug-Url: https://bugzilla.redhat.com/1323782
Signed-off-by: Edward Haas <edwardh at redhat.com>
---
M vdsm/vdsm-restore-net-config
1 file changed, 25 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/57/56257/1

diff --git a/vdsm/vdsm-restore-net-config b/vdsm/vdsm-restore-net-config
index 62a7122..85c9a34 100755
--- a/vdsm/vdsm-restore-net-config
+++ b/vdsm/vdsm-restore-net-config
@@ -19,6 +19,7 @@
 # Refer to the README and COPYING files for full details of the license
 #
 import argparse
+from contextlib import contextmanager
 import glob
 import logging
 import logging.config
@@ -124,21 +125,21 @@
 
     _verify_all_devices_are_up(list(_owned_ifcfg_files()))
 
-    _update_running_config(persistent_config)
+    with _update_running_config(persistent_config):
 
-    _wait_for_for_all_devices_up(
-        available_config.networks.keys() + available_config.bonds.keys())
-    if ipv6_supported():
-        _restore_disable_ipv6()
-    changed_config = _filter_changed_nets_bonds(available_config)
-    nets = changed_config.networks
-    bonds = changed_config.bonds
-    if nets or bonds:
-        _convert_to_blocking_dhcp(nets)
-        logging.debug('Calling setupNetworks with networks (%s) '
-                      'and bond (%s).', nets, bonds)
-        setupNetworks(nets, bonds, {'connectivityCheck': False,
-                                    '_inRollback': True})
+        _wait_for_for_all_devices_up(
+            available_config.networks.keys() + available_config.bonds.keys())
+        if ipv6_supported():
+            _restore_disable_ipv6()
+        changed_config = _filter_changed_nets_bonds(available_config)
+        nets = changed_config.networks
+        bonds = changed_config.bonds
+        if nets or bonds:
+            _convert_to_blocking_dhcp(nets)
+            logging.debug('Calling setupNetworks with networks (%s) '
+                          'and bond (%s).', nets, bonds)
+            setupNetworks(nets, bonds, {'connectivityCheck': False,
+                                        '_inRollback': True})
 
 
 def _verify_all_devices_are_up(owned_ifcfg_files):
@@ -165,9 +166,12 @@
             f.write(new_content)
 
 
+ at contextmanager
 def _update_running_config(persistent_config):
     """We must recreate RunningConfig so that following setSafeNetworkConfig
     will persist a valid configuration.
+
+    If the setup fails for any reason, cleanup running config.
     """
     running_config = RunningConfig()
     for net, net_attr in persistent_config.networks.iteritems():
@@ -176,6 +180,13 @@
         running_config.setBonding(bonding, bonding_attr)
     running_config.save()
 
+    try:
+        yield
+    except:
+        # Cleanup running config.
+        running_config.delete()
+        raise
+
 
 def _owned_ifcfg_files():
     for fpath in glob.iglob(misc.NET_CONF_DIR + '/*'):


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie43da8ca26ef0b0e92ec66e1a481a843aea0487f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Edward Haas <edwardh at redhat.com>


More information about the vdsm-patches mailing list