Skip to content

multi-asic: sonic-cfggen fails to get right port_config file when -n option is provided #7161

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

Closed
anamehra opened this issue Mar 26, 2021 · 8 comments
Assignees

Comments

@anamehra
Copy link
Contributor

Description

On 202012, multi-asic system, when I run sonic-cfggen to genretae config_dbX.json for am asic_id X, the right port config file is not picked. sonic-cfggen calls device_info.get_path_to_port_config_file method with hwsku but no asic_id. The method returns none. Sonic-cfggen fails to get the right port_config.ini path.

    if args.port_config is None:
        args.port_config = device_info.get_path_to_port_config_file(hwsku)

def get_path_to_port_config_file(hwsku=None, asic=None):
"""
Retrieves the path to the device's port configuration file
.
.
asic: a string , asic argument should be passed on multi-ASIC devices only,
it should be omitted on single-ASIC platforms.

Moreover device_info.py use swsssdk for ConfigDBConnector, SonicDBConfig, SonicV2Connector while sonic-cfggen is moved to libswsscommon, which may cause other db issue as seen in #7155

Steps to reproduce the issue:

Describe the results you received:

Describe the results you expected:

Output of show version:

(paste your output here)

Additional information you deem important (e.g. issue happens only occasionally):

@abdosi
Copy link
Contributor

abdosi commented Mar 31, 2021

Please provide exact sonic-cfggen command being used

@anshuv-mfst
Copy link

Issue seen only on 202012 and not seen in 201911.
@anamehra - please provide more info

  1. provide complete command
  2. Is the issue seen in master? please re-create with master branch

@anamehra
Copy link
Contributor Author

For a 3 asic system, here is the HWSKU directory structure:
ls /usr/share/sonic/device/platform-x/hwsku/*/
0/port_config.ini
1/port_config.ini
2/port_config.ini

command run:
export HWSKU=/usr/share/sonic/device/platform-x/hwsku/
sonic-cfggen -n asic0 -H -k $HWSKU --preset t1

The command doe snot pick the right port_config.ini file which should be /usr/share/sonic/device/platform-x/hwsku/0/port_config.ini

when sonic-cfggen makes a call to device_info.get_path_to_port_config_file(hwsku), the return value is 'None'
changing this call to device_info.get_path_to_port_config_file(hwsku, asic_id) helped return the correct path
and sonic-cfggen generated right data.

As a workaround, I passed -p <port_config.ini> option and that worked fine as it bypass the get_path_to_port_config_file () call.

@anshuv-mfst
Copy link

Hi @SuvarnaMeenakshi could you please provide input, thanks.

@SuvarnaMeenakshi
Copy link
Contributor

I will raise a PR to fix sonic-cfggen to take namespace parameter.
A PR for swsscommon which was required is merged in: sonic-net/sonic-swss-common#470
Will update with sonic-cfggen fix PR here.

@anamehra
Copy link
Contributor Author

anamehra commented May 19, 2021

@SuvarnaMeenakshi looks like sonic-net/sonic-swss-common#470 handles the swsscommon issue reported in #7155
Is there a different commit PR for sonic-cfggen port_config.ini path as reported in this issue?

Update: missed the update for #7632, will pick this change and verify. Thanks

@SuvarnaMeenakshi
Copy link
Contributor

@SuvarnaMeenakshi looks like Azure/sonic-swss-common#470 handles the swsscommon issue reported in #7155
Is there a different commit PR for sonic-cfggen port_config.ini path as reported in this issue?

yes; it is here: #7632

SuvarnaMeenakshi added a commit that referenced this issue Jun 7, 2021
…ig db (#7632)

Why I did it
portconfig.py gets PORT table from config_db if it is present. If not, port_config.ini files are parsed.
For multi-asic platform, if namespace is passed to get_port_config(), config_db connection was done to host namespace always and not to asic specific namespace.
Provides fix for: #7161

How I did it
Modify db connection function to connect to namespace config_db.
carl-nokia pushed a commit to carl-nokia/sonic-buildimage that referenced this issue Aug 7, 2021
…ig db (sonic-net#7632)

Why I did it
portconfig.py gets PORT table from config_db if it is present. If not, port_config.ini files are parsed.
For multi-asic platform, if namespace is passed to get_port_config(), config_db connection was done to host namespace always and not to asic specific namespace.
Provides fix for: sonic-net#7161

How I did it
Modify db connection function to connect to namespace config_db.
@SuvarnaMeenakshi
Copy link
Contributor

Fixed in #7632

SuvarnaMeenakshi added a commit to SuvarnaMeenakshi/sonic-buildimage that referenced this issue Apr 6, 2022
…ig db (sonic-net#7632)

Why I did it
portconfig.py gets PORT table from config_db if it is present. If not, port_config.ini files are parsed.
For multi-asic platform, if namespace is passed to get_port_config(), config_db connection was done to host namespace always and not to asic specific namespace.
Provides fix for: sonic-net#7161

How I did it
Modify db connection function to connect to namespace config_db.

(cherry picked from commit 2e305c9)
SuvarnaMeenakshi added a commit that referenced this issue May 27, 2022
…ace config db (#10475)

Why I did it
Cherry-pick of: #7632
portconfig.py gets PORT table from config_db if it is present. If not, port_config.ini files are parsed.
For multi-asic platform, if namespace is passed to get_port_config(), config_db connection was done to host namespace always and not to asic specific namespace.
Provides fix for: #7161

How I did it
Modify db connection function to connect to namespace config_db.

How to verify it
Unit-test passed.
Verified on multi-asic VS platform.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants