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

[load_minigraph]: Add support to load default_config.json file #1228

Closed
wants to merge 1 commit into from

Conversation

mlorrillere
Copy link
Contributor

@mlorrillere mlorrillere commented Nov 11, 2020

This change add support for a per-device/per-npu default_config.json
file that contains platform-specific or hwsku-specific configuration to
be used when generating config_db*.json

An example of such file in a VoQ chassis could be:

{
    "DEVICE_METADATA": {
        "localhost": {
            "asic_id": "06:00.0"
        }
    }
}

- What I did

Added support for a default_config.json file present in platform directory for each NPU and for the host. This file will be loaded when config load_minigraph is called.

- Why I did it

Some VoQ devices require per-platform/per-NPU configurations to be present in CONFIG_DB. default_config.json provides a way for a vendor to give the required initial configuration of a device.

- How to verify it

Verified manually on a single and multi-NPU platform with and without a default_config.json present in the platform directory.

@anshuv-mfst
Copy link

Veda (Nokia) , @arlakshm - could you please review, thanks.

Copy link
Contributor

@arlakshm arlakshm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add unit test for this

@@ -294,6 +294,22 @@ def _get_device_type():

return device_type

def _get_hwsku(config_db):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this function here. Same function available in sonic_py_common get_hwsku

Copy link
Contributor Author

@mlorrillere mlorrillere Feb 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_hwsku in sonic_py_common does not support namespaces, it will always connect to the host redis instance.

Also, get_hwsku in sonic_py_common will be stuck because it will try to open a new connection to CONFIG_DB.

This can be revisited when sonic_py_common provides support for namespaces and existing connection.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hwsku is for the whole device, wouldn't getting the hwsku form the host redis work will it change for each namespace/asic ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be the same hwsku for all namespace/asic. However we can't get it before minigraph.xml is parsed and CONFIG_DB is populated, so calling get_hwsku from sonic_py_common beforehand is not possible since CONFIG_DB will be empty.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if config_db is empty then _get_hwsku won't return the correct hwsku also. I am trying to understand what the difference between _get_hwsku define here and get_hwsku in sonic_py_common

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_get_hwsku is called after minigraph.xml is parsed and CONFIG_DB is populated for the corresponding namespace CONFIG_DB initialized at line 1274, _get_hwsku is called at line 1287).

The difference with get_hwsku from sonic_py_common is that _get_hwsku here reuse the existing connection to CONFIG_DB. If we cann get_hwsku from sonic_py_common instead it will get stuck because we can't open multiple connections the same time.

npu_id = device_info.get_npu_id_from_name(namespace)

# load default_config.json file from platform directory
default_config_file = os.path.join('/usr/share/sonic/device/', platform, npu_id, 'default_config.json')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you give an example what is present in 'default_config.json'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the following example in the description:

{
    "DEVICE_METADATA": {
        "localhost": {
            "instance_name": "ASIC0",
            "chassis_db_address" : "240.127.1.1",
            "start_chassis_db" : "1",
            "asic_id": "06:00.0"
        }
    }
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per PR sonic-net/sonic-buildimage#5991, for VOQ chassis systems the "asic_id" and "instance_name" are configured via minigraph.xml. Will these values from default_config.json be preferred over what is configured through minigraph?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For VOQ chassis systems, we get "start_chassis_db" and "chassis_db_address" from chassisdb.conf from device specific directory (for example: https://github.com/Azure/sonic-buildimage/blob/master/device/arista/x86_64-arista_7800_sup/chassisdb.conf). These are needed before the database service is started in supervisor card. Having these in config_db is of no use. Also, if these are not used in multi-asic we should not have these in default_config.json.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per PR Azure/sonic-buildimage#5991, for VOQ chassis systems the "asic_id" and "instance_name" are configured via minigraph.xml. Will these values from default_config.json be preferred over what is configured through minigraph?

Both are still valid. If the platform has configuration in default_config.json it has to be static. If it is present in both files then default_config.json will override the value configured via minigraph.xml, which is fine.

The example above is probably incorrect once VoQ config using minigraph.xml is complete (PR5991), however asic_id is still required in this file as it is platform-dependent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For VOQ chassis systems, we get "start_chassis_db" and "chassis_db_address" from chassisdb.conf from device specific directory (for example: https://github.com/Azure/sonic-buildimage/blob/master/device/arista/x86_64-arista_7800_sup/chassisdb.conf). These are needed before the database service is started in supervisor card. Having these in config_db is of no use. Also, if these are not used in multi-asic we should not have these in default_config.json.

Right. Actually in the above example only asic_id is required as it is tied to each asic physically on the hardware. Other configurations can easily be set using minigraph.xml

@mlorrillere
Copy link
Contributor Author

Please add unit test for this

I've updated config_test.py to get coverage for default_config.json. I also added similar test for init_cfg.json since coverage was missing.

@mlorrillere mlorrillere force-pushed the pr-default-config branch 2 times, most recently from 42fdb03 to 65d9313 Compare March 1, 2021 18:20
@sanmalho-git
Copy link

@vganesan-nokia - please review.

npu_id = device_info.get_npu_id_from_name(namespace)

# load default_config.json file from platform directory
default_config_file = os.path.join('/usr/share/sonic/device/', platform, npu_id, 'default_config.json')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per PR sonic-net/sonic-buildimage#5991, for VOQ chassis systems the "asic_id" and "instance_name" are configured via minigraph.xml. Will these values from default_config.json be preferred over what is configured through minigraph?

npu_id = device_info.get_npu_id_from_name(namespace)

# load default_config.json file from platform directory
default_config_file = os.path.join('/usr/share/sonic/device/', platform, npu_id, 'default_config.json')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For VOQ chassis systems, we get "start_chassis_db" and "chassis_db_address" from chassisdb.conf from device specific directory (for example: https://github.com/Azure/sonic-buildimage/blob/master/device/arista/x86_64-arista_7800_sup/chassisdb.conf). These are needed before the database service is started in supervisor card. Having these in config_db is of no use. Also, if these are not used in multi-asic we should not have these in default_config.json.

@mlorrillere
Copy link
Contributor Author

Hi @arlakshm and @vganesan-nokia ,

Can you approve this review if there is no further comments?

vganesan-nokia
vganesan-nokia previously approved these changes Mar 24, 2021
This change add support for a per-device/per-npu default_config.json
file that contains platform-specific or hwsku-specific configuration to
be used when generating config_db*.json.
@arlakshm
Copy link
Contributor

@mlorrillere, @vganesan-nokia This PR sonic-net/sonic-buildimage#7513 adds support to populate the DEVICE_METADATA.asic_id from the Pci_id present in asic.conf. Do we still need default_config.json

@mlorrillere
Copy link
Contributor Author

@mlorrillere, @vganesan-nokia This PR Azure/sonic-buildimage#7513 adds support to populate the DEVICE_METADATA.asic_id from the Pci_id present in asic.conf. Do we still need default_config.json

I found out about this PR yesterday. We might not need default_config.json after all if asic.conf includes the PCI addresses of the ASICs.

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

Successfully merging this pull request may close these issues.

5 participants