Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgp/test_traffic_shift.py::test_TSA_TSB_with_config_reload is creating a BGP monitor with an invalid name #10876

Closed
saiarcot895 opened this issue Nov 29, 2023 · 1 comment
Assignees

Comments

@saiarcot895
Copy link
Contributor

Description

Following sonic-net/sonic-utilities#3025, db_migrator.py will check config DB for YANG validation issues. It appears that bgp/test_traffic_shift.py::test_TSA_TSB_with_config_reload (or some fixture) is creating a BGP monitor named bgp_monitor. However, as per the YANG model for this, the BGP monitor must be named BGPMonitor. Because of this, config reload fails.

See also sonic-net/sonic-buildimage#17069 and sonic-net/sonic-buildimage#17297.

Steps to reproduce the issue:

  1. Set up a T1 KVM topology running a SONiC image with the latest sonic-utilities commit.
  2. Run the bgp/test_traffic_shift.py::test_TSA_TSB_with_config_reload test case.

Describe the results you received:

Test case fails on config reload -y -f.

Syslog error lines:

Nov 29 07:36:34.624371 vlab-03 ERR sonic_yang: Data Loading Failed:Invalid BGP monitor name
Nov 29 07:36:34.624426 vlab-03 CRIT db_migrator.py: Yang validation failed: Data Loading Failed#012Invalid BGP monitor name
Nov 29 07:36:34.624452 vlab-03 ERR db_migrator.py: Caught exception: 'UTILITIES_UNIT_TESTING'

Added bgpmon config:

$ cat /tmp/bgpmon.json
{
    "BGP_MONITORS": {
        "20.0.0.1": {
            "admin_status": "up",
                "asn": "65100",
                "holdtime": "10",
                "keepalive": "3",
                "local_addr": "10.1.0.32",
                "name": "bgp_monitor",
                "nhopself": "0",
                "rrclient": "0"
        }
    }
}

Manual config reload with this config added:

admin@vlab-03:~$ sudo config reload -y
Disabling container monitoring ...
Stopping SONiC target ...
Running command: /usr/local/bin/sonic-cfggen -j /etc/sonic/init_cfg.json -j /etc/sonic/config_db.json --write-to-db
Running command: /usr/local/bin/db_migrator.py -o migrate
libyang[0]: Must condition "current() = 'BGPMonitor'" not satisfied. (path: /sonic-bgp-monitor:sonic-bgp-monitor/BGP_MONITORS/BGP_MONITORS_LIST[addr='20.0.0.1']/name)
libyang[0]: Invalid BGP monitor name (path: /sonic-bgp-monitor:sonic-bgp-monitor/BGP_MONITORS/BGP_MONITORS_LIST[addr='20.0.0.1']/name)
Traceback (most recent call last):
  File "/usr/local/bin/db_migrator.py", line 1195, in main
    result = getattr(dbmgtr, operation)()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/bin/db_migrator.py", line 1150, in migrate
    if os.environ["UTILITIES_UNIT_TESTING"] == "2":
       ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen os>", line 679, in __getitem__
KeyError: 'UTILITIES_UNIT_TESTING'
sonic_yang(3):Data Loading Failed:Invalid BGP monitor name
'UTILITIES_UNIT_TESTING'
usage: db_migrator.py [-h] [-o operation migrate, set_version, get_version] [-s unix socket] [-n asic namespace]

options:
  -h, --help            show this help message and exit
  -o operation (migrate, set_version, get_version)
                        operation to perform [default: get_version]
  -s unix socket        the unix socket that the desired database listens on
  -n asic namespace     The asic namespace whose DB instance we need to connect

Describe the results you expected:

Test case should pass.

Additional information you deem important:

@saiarcot895
Copy link
Contributor Author

This also breaks vms-kvm-four-asic-t1-lag topology with the default config that gets deployed:

admin@vlab-08:~$ sudo config reload
Clear current config and reload config in config_db format from the default config file(s) ? [y/N]: y
Disabling container monitoring ...
Stopping SONiC target ...
Running command: /usr/local/bin/sonic-cfggen -j /etc/sonic/init_cfg.json -j /etc/sonic/config_db.json --write-to-db
Running command: /usr/local/bin/db_migrator.py -o migrate
libyang[0]: Missing required element "lanes" in "PORT_LIST". (path: /sonic-port:sonic-port/PORT/PORT_LIST[name='Ethernet1/1'])
Traceback (most recent call last):
  File "/usr/local/bin/db_migrator.py", line 1195, in main
    result = getattr(dbmgtr, operation)()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/bin/db_migrator.py", line 1150, in migrate
    if os.environ["UTILITIES_UNIT_TESTING"] == "2":
       ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen os>", line 679, in __getitem__
KeyError: 'UTILITIES_UNIT_TESTING'
sonic_yang(3):Data Loading Failed:Missing required element "lanes" in "PORT_LIST".
'UTILITIES_UNIT_TESTING'
usage: db_migrator.py [-h] [-o operation migrate, set_version, get_version] [-s unix socket] [-n asic namespace]

options:
  -h, --help            show this help message and exit
  -o operation (migrate, set_version, get_version)
                        operation to perform [default: get_version]
  -s unix socket        the unix socket that the desired database listens on
  -n asic namespace     The asic namespace whose DB instance we need to connect

@ganglyu ganglyu closed this as completed Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants