Change in vdsm[ovirt-3.6]: net: Clean running config on unified restoration failure
edwardh at redhat.com
edwardh at redhat.com
Tue Apr 19 09:06:15 UTC 2016
Hello Dan Kenigsberg,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/56322
to review the following change.
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>
Reviewed-on: https://gerrit.ovirt.org/56257
Continuous-Integration: Jenkins CI
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
---
M vdsm/vdsm-restore-net-config
1 file changed, 25 insertions(+), 13 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/22/56322/1
diff --git a/vdsm/vdsm-restore-net-config b/vdsm/vdsm-restore-net-config
index 0673179..cc98cc4 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
@@ -121,20 +122,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 netinfo.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 netinfo.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):
@@ -161,9 +163,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():
@@ -172,6 +177,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(netinfo.NET_CONF_DIR + '/*'):
--
To view, visit https://gerrit.ovirt.org/56322
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie43da8ca26ef0b0e92ec66e1a481a843aea0487f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Edward Haas <edwardh at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
More information about the vdsm-patches
mailing list