From 74734baca628134119457c2ba2865f53cd6c9772 Mon Sep 17 00:00:00 2001 From: Sergii Golovatiuk Date: Tue, 12 Dec 2017 17:14:35 +0100 Subject: [PATCH] Restore OVSIntPort interfaces after OVS restarts There are 2 cases when OVS is restarted 1. Package Upgrade 2. OVS restart invoked by Puppet Closes-Bug: 1737182 Change-Id: I69f5f80d1e359be72773e2622e1d3e90922d8b3b (cherry picked from commit a0a1984cd3b3d8dea65ee7b88c1d026dae60077a) --- instack_undercloud/undercloud.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/instack_undercloud/undercloud.py b/instack_undercloud/undercloud.py index 25fd374d4..01ef5e6de 100644 --- a/instack_undercloud/undercloud.py +++ b/instack_undercloud/undercloud.py @@ -23,6 +23,7 @@ import json import logging import os import platform +import re import socket import subprocess import sys @@ -1337,6 +1338,27 @@ def _run_yum_update(instack_env): LOG.info('yum-update completed successfully') +def _get_ovs_interfaces(): + interfaces = glob.glob('/etc/sysconfig/network-scripts/ifcfg-*') + pattern = "OVSIntPort" + ovs_interfaces = [] + for interface in interfaces: + with open(interface, "r") as text: + for line in text: + if re.findall(pattern, line): + # FIXME (holser). It might be better to get interface from + # DEVICE rather than name of file. + ovs_interfaces.append(interface.split('-')[-1]) + return ovs_interfaces + + +def _run_restore_ovs_interfaces(interfaces): + for interface in interfaces: + LOG.info('Running restart OVS interface %s', interface) + _run_command(['sudo', 'ifup', interface]) + LOG.info('Restart OVS interface %s completed successfully', interface) + + def _run_orc(instack_env): args = ['sudo', 'os-refresh-config'] LOG.info('Running os-refresh-config') @@ -1776,6 +1798,7 @@ def install(instack_root, upgrade=False): _validate_configuration() instack_env = _generate_environment(instack_root) _generate_init_data(instack_env) + ovs_interfaces = _get_ovs_interfaces() if upgrade: # We didn't complete the M->N upgrades correctly with a # `nova-manage db online_data_migrations` command before. This @@ -1794,10 +1817,17 @@ def install(instack_root, upgrade=False): _die_tuskar_die() if CONF.undercloud_update_packages: _run_yum_clean_all(instack_env) + if ovs_interfaces: + _run_restore_ovs_interfaces(ovs_interfaces) _run_yum_update(instack_env) _handle_upgrade_fact(upgrade) _run_instack(instack_env) _run_orc(instack_env) + # FIXME (holser). The RC of issue is in OVS flow restore. Once + # 'systemctl reload openvswitch' is fixed ovs port restoration can be + # removed. + if ovs_interfaces: + _run_restore_ovs_interfaces(ovs_interfaces) _post_config(instack_env) _run_command(['sudo', 'rm', '-f', '/tmp/svc-map-services'], None, 'rm') if upgrade and CONF.enable_validations: # Run post-upgrade validations