diff options
author | Christian Breunig <christian@breunig.cc> | 2024-03-24 17:48:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-24 17:48:09 +0100 |
commit | 810ad5c718d685e0835b91eea17b5cf90b96fb5f (patch) | |
tree | 285db875571a7fc1776130d0a3a7698b7da646a8 | |
parent | 8ca9e5930cd1154309036ef0ebd40821bab91991 (diff) | |
parent | 25252cdbfcef43980c2586a16f676e94f29a64bf (diff) | |
download | vyos-1x-810ad5c718d685e0835b91eea17b5cf90b96fb5f.tar.gz vyos-1x-810ad5c718d685e0835b91eea17b5cf90b96fb5f.zip |
Merge pull request #3175 from vyos/mergify/bp/sagitta/pr-3151
bgp: T6106: Show complete FRR output on internal errors (backport #3151)
-rw-r--r-- | python/vyos/frr.py | 16 | ||||
-rwxr-xr-x | smoketest/scripts/cli/test_protocols_bgp.py | 7 |
2 files changed, 18 insertions, 5 deletions
diff --git a/python/vyos/frr.py b/python/vyos/frr.py index a01d967e4..c3703cbb4 100644 --- a/python/vyos/frr.py +++ b/python/vyos/frr.py @@ -68,6 +68,7 @@ Apply the new configuration: import tempfile import re +from vyos import ConfigError from vyos.utils.permission import chown from vyos.utils.process import cmd from vyos.utils.process import popen @@ -95,6 +96,7 @@ path_config = '/run/frr' default_add_before = r'(ip prefix-list .*|route-map .*|line vty|end)' + class FrrError(Exception): pass @@ -210,13 +212,12 @@ def reload_configuration(config, daemon=None): LOG.debug(f'reload_configuration: Executing command against frr-reload: "{cmd}"') output, code = popen(cmd, stderr=STDOUT) f.close() + for i, e in enumerate(output.split('\n')): LOG.debug(f'frr-reload output: {i:3} {e}') + if code == 1: - raise CommitError('FRR configuration failed while running commit. Please ' \ - 'enable debugging to examine logs.\n\n\n' \ - 'To enable debugging run: "touch /tmp/vyos.frr.debug" ' \ - 'and "sudo systemctl stop vyos-configd"') + raise ConfigError(output) elif code: raise OSError(code, output) @@ -469,17 +470,22 @@ class FRRConfig: # https://github.com/FRRouting/frr/issues/10133 count = 0 count_max = 5 + emsg = '' while count < count_max: count += 1 try: reload_configuration('\n'.join(self.config), daemon=daemon) break + except ConfigError as e: + emsg = str(e) except: # we just need to re-try the commit of the configuration # for the listed FRR issues above pass if count >= count_max: - raise ConfigurationNotValid(f'Config commit retry counter ({count_max}) exceeded for {daemon} dameon!') + if emsg: + raise ConfigError(emsg) + raise ConfigurationNotValid(f'Config commit retry counter ({count_max}) exceeded for {daemon} daemon!') # Save configuration to /run/frr/config/frr.conf save_configuration() diff --git a/smoketest/scripts/cli/test_protocols_bgp.py b/smoketest/scripts/cli/test_protocols_bgp.py index 1d68ae08b..1dc865977 100755 --- a/smoketest/scripts/cli/test_protocols_bgp.py +++ b/smoketest/scripts/cli/test_protocols_bgp.py @@ -1236,6 +1236,13 @@ class TestProtocolsBGP(VyOSUnitTestSHIM.TestCase): self.assertIn(f' neighbor {pg_ipv6} activate', afiv6_config) self.assertIn(f' neighbor {pg_ipv6} maximum-prefix {ipv6_max_prefix}', afiv6_config) + def test_bgp_26_commit_error(self): + self.cli_set(base_path + ['peer-group', 'peer1', 'address-family', 'l2vpn-evpn', 'route-reflector-client']) + with self.assertRaises(ConfigSessionError) as e: + self.cli_commit() + + self.assertTrue("% Invalid command. Not an internal neighbor" in str(e.exception)) + def test_bgp_99_bmp(self): target_name = 'instance-bmp' target_address = '127.0.0.1' |