Merge "Set metering iptables chain not found LOG level to WARNING"
This commit is contained in:
commit
144c70f896
|
@ -775,7 +775,15 @@ class IptablesManager(object):
|
||||||
args.append('-Z')
|
args.append('-Z')
|
||||||
if self.namespace:
|
if self.namespace:
|
||||||
args = ['ip', 'netns', 'exec', self.namespace] + args
|
args = ['ip', 'netns', 'exec', self.namespace] + args
|
||||||
current_table = self.execute(args, run_as_root=True)
|
|
||||||
|
# Execute iptables command in the linux host.
|
||||||
|
# When routers migrate from a host,an exception might happen here,
|
||||||
|
# and we do not care about it. Therefore, we do not need to log
|
||||||
|
# this error in production environments. Only when debug mode is
|
||||||
|
# enabled is that we need to log the error. This is used to avoid
|
||||||
|
# generating alarms that will be ignored by operators.
|
||||||
|
current_table = self.execute(
|
||||||
|
args, run_as_root=True, log_fail_as_error=cfg.CONF.debug)
|
||||||
current_lines = current_table.split('\n')
|
current_lines = current_table.split('\n')
|
||||||
|
|
||||||
for line in current_lines[2:]:
|
for line in current_lines[2:]:
|
||||||
|
|
|
@ -506,9 +506,12 @@ class IptablesMeteringDriver(abstract_driver.MeteringAbstractDriver):
|
||||||
|
|
||||||
chain_acc = rm.iptables_manager.get_traffic_counters(
|
chain_acc = rm.iptables_manager.get_traffic_counters(
|
||||||
chain, wrap=False, zero=True)
|
chain, wrap=False, zero=True)
|
||||||
except RuntimeError:
|
except RuntimeError as e:
|
||||||
LOG.exception('Failed to get traffic counters, '
|
LOG.warning('Failed to get traffic counters for router [%s] due '
|
||||||
'router: %s', router)
|
'to [%s]. This error message can happen when routers '
|
||||||
|
'are migrated; therefore, most of the times they can '
|
||||||
|
'be ignored.', router, e)
|
||||||
|
|
||||||
routers_to_reconfigure.add(router['id'])
|
routers_to_reconfigure.add(router['id'])
|
||||||
return {}
|
return {}
|
||||||
return chain_acc
|
return chain_acc
|
||||||
|
|
|
@ -1020,34 +1020,36 @@ class IptablesManagerStateFulTestCase(IptablesManagerBaseTestCase):
|
||||||
expected_calls_and_values = [
|
expected_calls_and_values = [
|
||||||
(mock.call(['iptables', '-t', 'filter', '-L', 'OUTPUT',
|
(mock.call(['iptables', '-t', 'filter', '-L', 'OUTPUT',
|
||||||
'-n', '-v', '-x', '-w', '10'],
|
'-n', '-v', '-x', '-w', '10'],
|
||||||
run_as_root=True),
|
run_as_root=True, log_fail_as_error=False),
|
||||||
TRAFFIC_COUNTERS_DUMP),
|
TRAFFIC_COUNTERS_DUMP),
|
||||||
(mock.call(['iptables', '-t', 'raw', '-L', 'OUTPUT', '-n',
|
(mock.call(['iptables', '-t', 'raw', '-L', 'OUTPUT', '-n',
|
||||||
'-v', '-x', '-w', '10'],
|
'-v', '-x', '-w', '10'],
|
||||||
run_as_root=True),
|
run_as_root=True, log_fail_as_error=False),
|
||||||
''),
|
''),
|
||||||
(mock.call(['iptables', '-t', 'mangle', '-L', 'OUTPUT', '-n',
|
(mock.call(['iptables', '-t', 'mangle', '-L', 'OUTPUT', '-n',
|
||||||
'-v', '-x', '-w', '10'],
|
'-v', '-x', '-w', '10'],
|
||||||
run_as_root=True),
|
run_as_root=True, log_fail_as_error=False),
|
||||||
''),
|
''),
|
||||||
(mock.call(['iptables', '-t', 'nat', '-L', 'OUTPUT', '-n',
|
(mock.call(['iptables', '-t', 'nat', '-L', 'OUTPUT', '-n',
|
||||||
'-v', '-x', '-w', '10'],
|
'-v', '-x', '-w', '10'],
|
||||||
run_as_root=True),
|
run_as_root=True, log_fail_as_error=False),
|
||||||
''),
|
''),
|
||||||
]
|
]
|
||||||
if self.use_ipv6:
|
if self.use_ipv6:
|
||||||
expected_calls_and_values.append(
|
expected_calls_and_values.append(
|
||||||
(mock.call(['ip6tables', '-t', 'raw', '-L', 'OUTPUT',
|
(mock.call(['ip6tables', '-t', 'raw', '-L', 'OUTPUT',
|
||||||
'-n', '-v', '-x', '-w', '10'], run_as_root=True),
|
'-n', '-v', '-x', '-w', '10'], run_as_root=True,
|
||||||
|
log_fail_as_error=False),
|
||||||
''))
|
''))
|
||||||
expected_calls_and_values.append(
|
expected_calls_and_values.append(
|
||||||
(mock.call(['ip6tables', '-t', 'filter', '-L', 'OUTPUT',
|
(mock.call(['ip6tables', '-t', 'filter', '-L', 'OUTPUT',
|
||||||
'-n', '-v', '-x', '-w', '10'],
|
'-n', '-v', '-x', '-w', '10'],
|
||||||
run_as_root=True),
|
run_as_root=True, log_fail_as_error=False),
|
||||||
TRAFFIC_COUNTERS_DUMP))
|
TRAFFIC_COUNTERS_DUMP))
|
||||||
expected_calls_and_values.append(
|
expected_calls_and_values.append(
|
||||||
(mock.call(['ip6tables', '-t', 'mangle', '-L', 'OUTPUT',
|
(mock.call(['ip6tables', '-t', 'mangle', '-L', 'OUTPUT',
|
||||||
'-n', '-v', '-x', '-w', '10'], run_as_root=True),
|
'-n', '-v', '-x', '-w', '10'], run_as_root=True,
|
||||||
|
log_fail_as_error=False),
|
||||||
''))
|
''))
|
||||||
exp_packets *= 2
|
exp_packets *= 2
|
||||||
exp_bytes *= 2
|
exp_bytes *= 2
|
||||||
|
@ -1068,36 +1070,36 @@ class IptablesManagerStateFulTestCase(IptablesManagerBaseTestCase):
|
||||||
expected_calls_and_values = [
|
expected_calls_and_values = [
|
||||||
(mock.call(['iptables', '-t', 'filter', '-L', 'OUTPUT',
|
(mock.call(['iptables', '-t', 'filter', '-L', 'OUTPUT',
|
||||||
'-n', '-v', '-x', '-w', '10', '-Z'],
|
'-n', '-v', '-x', '-w', '10', '-Z'],
|
||||||
run_as_root=True),
|
run_as_root=True, log_fail_as_error=False),
|
||||||
TRAFFIC_COUNTERS_DUMP),
|
TRAFFIC_COUNTERS_DUMP),
|
||||||
(mock.call(['iptables', '-t', 'raw', '-L', 'OUTPUT', '-n',
|
(mock.call(['iptables', '-t', 'raw', '-L', 'OUTPUT', '-n',
|
||||||
'-v', '-x', '-w', '10', '-Z'],
|
'-v', '-x', '-w', '10', '-Z'],
|
||||||
run_as_root=True),
|
run_as_root=True, log_fail_as_error=False),
|
||||||
''),
|
''),
|
||||||
(mock.call(['iptables', '-t', 'mangle', '-L', 'OUTPUT', '-n',
|
(mock.call(['iptables', '-t', 'mangle', '-L', 'OUTPUT', '-n',
|
||||||
'-v', '-x', '-w', '10', '-Z'],
|
'-v', '-x', '-w', '10', '-Z'],
|
||||||
run_as_root=True),
|
run_as_root=True, log_fail_as_error=False),
|
||||||
''),
|
''),
|
||||||
(mock.call(['iptables', '-t', 'nat', '-L', 'OUTPUT', '-n',
|
(mock.call(['iptables', '-t', 'nat', '-L', 'OUTPUT', '-n',
|
||||||
'-v', '-x', '-w', '10', '-Z'],
|
'-v', '-x', '-w', '10', '-Z'],
|
||||||
run_as_root=True),
|
run_as_root=True, log_fail_as_error=False),
|
||||||
'')
|
'')
|
||||||
]
|
]
|
||||||
if self.use_ipv6:
|
if self.use_ipv6:
|
||||||
expected_calls_and_values.append(
|
expected_calls_and_values.append(
|
||||||
(mock.call(['ip6tables', '-t', 'raw', '-L', 'OUTPUT',
|
(mock.call(['ip6tables', '-t', 'raw', '-L', 'OUTPUT',
|
||||||
'-n', '-v', '-x', '-w', '10', '-Z'],
|
'-n', '-v', '-x', '-w', '10', '-Z'],
|
||||||
run_as_root=True),
|
run_as_root=True, log_fail_as_error=False),
|
||||||
''))
|
''))
|
||||||
expected_calls_and_values.append(
|
expected_calls_and_values.append(
|
||||||
(mock.call(['ip6tables', '-t', 'filter', '-L', 'OUTPUT',
|
(mock.call(['ip6tables', '-t', 'filter', '-L', 'OUTPUT',
|
||||||
'-n', '-v', '-x', '-w', '10', '-Z'],
|
'-n', '-v', '-x', '-w', '10', '-Z'],
|
||||||
run_as_root=True),
|
run_as_root=True, log_fail_as_error=False),
|
||||||
TRAFFIC_COUNTERS_DUMP))
|
TRAFFIC_COUNTERS_DUMP))
|
||||||
expected_calls_and_values.append(
|
expected_calls_and_values.append(
|
||||||
(mock.call(['ip6tables', '-t', 'mangle', '-L', 'OUTPUT',
|
(mock.call(['ip6tables', '-t', 'mangle', '-L', 'OUTPUT',
|
||||||
'-n', '-v', '-x', '-w', '10', '-Z'],
|
'-n', '-v', '-x', '-w', '10', '-Z'],
|
||||||
run_as_root=True),
|
run_as_root=True, log_fail_as_error=False),
|
||||||
''))
|
''))
|
||||||
exp_packets *= 2
|
exp_packets *= 2
|
||||||
exp_bytes *= 2
|
exp_bytes *= 2
|
||||||
|
|
Loading…
Reference in New Issue