Skip to content
New issue

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

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

Already on GitHub? # to your account

Load the database global_db #1752

Merged
merged 1 commit into from
Aug 17, 2021

Conversation

SuvarnaMeenakshi
Copy link
Contributor

Signed-off-by: Suvarna Meenakshi sumeenak@microsoft.com

What I did

Recent change was done to remove call to load database global_db which expects the clients to load global_db.
[https://github.com/sonic-net/sonic-buildimage/pull/8173]
The load global_db was missing in multi_asic.py which was causing "show interfaces cli" to fail.
While testing on multi-asic VS image:

admin@vlab-08:~$ show interfaces status
Traceback (most recent call last):
  File "/usr/local/bin/intfutil", line 701, in <module>
    main()
  File "/usr/local/bin/intfutil", line 687, in main
    interface_stat.display_intf_status()
  File "/usr/local/bin/intfutil", line 376, in display_intf_status
    self.get_intf_status()
  File "/usr/local/lib/python3.7/dist-packages/utilities_common/multi_asic.py", line 133, in wrapped_run_on_all_asics
    ns_list = self.multi_asic.get_ns_list_based_on_options()
  File "/usr/local/lib/python3.7/dist-packages/utilities_common/multi_asic.py", line 59, in get_ns_list_based_on_options
    namespaces = multi_asic.get_all_namespaces()
  File "/usr/local/lib/python3.7/dist-packages/sonic_py_common/multi_asic.py", line 226, in get_all_namespaces
    config_db = connect_config_db_for_ns(namespace)
  File "/usr/local/lib/python3.7/dist-packages/sonic_py_common/multi_asic.py", line 40, in connect_config_db_for_ns
    config_db = swsscommon.ConfigDBConnector(namespace=namespace)
  File "/usr/lib/python3/dist-packages/swsscommon/swsscommon.py", line 2076, in __init__
    super(ConfigDBConnector, self).__init__(use_unix_socket_path = use_unix_socket_path, namespace = namespace)
  File "/usr/lib/python3/dist-packages/swsscommon/swsscommon.py", line 1698, in __init__
    for db_name in self.get_db_list():
  File "/usr/lib/python3/dist-packages/swsscommon/swsscommon.py", line 1634, in get_db_list
    return _swsscommon.SonicV2Connector_Native_get_db_list(self)
RuntimeError: :- validateNamespace: Initialize global DB config using API SonicDBConfig::initializeGlobalConfig

How I did it

load global_db config in multi_asic.py.

How to verify it

Load multi-asic VS image with the fix.

admin@vlab-08:~$ show interfaces status
      Interface        Lanes    Speed    MTU    FEC        Alias             Vlan    Oper    Admin    Type    Asym PFC
---------------  -----------  -------  -----  -----  -----------  ---------------  ------  -------  ------  ----------
      Ethernet0      1,2,3,4      40G   9100    N/A  Ethernet1/1  PortChannel0002      up       up     N/A         off
      Ethernet4      5,6,7,8      40G   9100    N/A  Ethernet1/2  PortChannel0002      up       up     N/A         off
      Ethernet8   9,10,11,12      40G   9100    N/A  Ethernet1/3  PortChannel0005      up       up     N/A         off
     Ethernet12  13,14,15,16      40G   9100    N/A  Ethernet1/4  PortChannel0005      up       up     N/A         off
     Ethernet16      1,2,3,4      40G   9100    N/A  Ethernet1/5  PortChannel0001      up       up     N/A         off
     Ethernet20      5,6,7,8      40G   9100    N/A  Ethernet1/6  PortChannel0003      up       up     N/A         off
     Ethernet24   9,10,11,12      40G   9100    N/A  Ethernet1/7  PortChannel0004      up       up     N/A         off
     Ethernet28  13,14,15,16      40G   9100    N/A  Ethernet1/8  PortChannel0006      up       up     N/A         off
PortChannel0001          N/A      40G   9100    N/A          N/A           routed      up       up     N/A         N/A
PortChannel0002          N/A      80G   9100    N/A          N/A           routed      up       up     N/A         N/A
PortChannel0003          N/A      40G   9100    N/A          N/A           routed      up       up     N/A         N/A
PortChannel0004          N/A      40G   9100    N/A          N/A           routed      up       up     N/A         N/A
PortChannel0005          N/A      80G   9100    N/A          N/A           routed      up       up     N/A         N/A
PortChannel0006          N/A      40G   9100    N/A          N/A           routed      up       up     N/A         N/A

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
@arlakshm
Copy link
Contributor

Hi @SuvarnaMeenakshi. Thanks for the fix.
As part of the PR #1712, the global_db is loaded for every show command.
Curious why that didn't work

@smaheshm
Copy link
Contributor

Curious why didn't the unit tests catch this. Was it because of mock APIs.

@SuvarnaMeenakshi
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@SuvarnaMeenakshi
Copy link
Contributor Author

Hi @SuvarnaMeenakshi. Thanks for the fix.
As part of the PR #1712, the global_db is loaded for every show command.
Curious why that didn't work

Thank you for the pointer , as discussed seems like though the top level show cli does a load for global_db, which only works when the command is directly executed. In case of show interfaces or show pfc counters, which in turn invokes a script, the script also would require the global_db to be loaded as it is executed as a stand alone script with a different SonicV2connector/ConfigDBConnector class.

@SuvarnaMeenakshi
Copy link
Contributor Author

Curious why didn't the unit tests catch this. Was it because of mock APIs.

Yes , that is right. The unit-test uses mock class which uses sonic-py-swsssdk to mock.
So this issue will not be seen in unit-testing.

@SuvarnaMeenakshi SuvarnaMeenakshi merged commit 5002745 into sonic-net:master Aug 17, 2021
@SuvarnaMeenakshi SuvarnaMeenakshi deleted the load_db branch August 17, 2021 18:02
judyjoseph pushed a commit that referenced this pull request Aug 26, 2021
What I did
Recent change was done to remove call to load database global_db which expects the clients to load global_db.
[sonic-net/sonic-buildimage#8173]
The load global_db was missing in multi_asic.py which was causing "show interfaces cli" to fail.
While testing on multi-asic VS image:
How I did it
load global_db config in multi_asic.py.

How to verify it
Load multi-asic VS image with the fix.
Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants