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

[yang] DPB fails when BUFFER_PORT_EGRESS_PROFILE is configured #9801

Open
alexrallen opened this issue Jan 19, 2022 · 11 comments
Open

[yang] DPB fails when BUFFER_PORT_EGRESS_PROFILE is configured #9801

alexrallen opened this issue Jan 19, 2022 · 11 comments
Assignees
Labels
BRCM Issue for 202111 Triaged this issue has been triaged YANG YANG model related changes

Comments

@alexrallen
Copy link
Contributor

alexrallen commented Jan 19, 2022

When we configure the following buffer profiles....

    "BUFFER_PORT_EGRESS_PROFILE_LIST": {
        "Ethernet0": {
            "profile_list": "egress_lossless_profile,egress_lossy_profile"
        }
    }

Dynamic port breakout fails with...

libyang[0]: Duplicated instance of "profile_list" leaf-list ("e"). (path: /sonic-buffer-port-egress-profile-list:sonic-buffer-port-egress-profile-list/BUFFER_PORT_EGRESS_PROFILE_LIST/BUFFER_PORT_EGRESS_PROFILE_LIST_LIST[port='Ethernet0']/profile_list[.='e'])

sonic_yang(3):Data Loading Failed:Duplicated instance of "profile_list" leaf-list ("e").
Data Loading Failed
Duplicated instance of "profile_list" leaf-list ("e").

ConfigMgmt Class creation failed

Failed to break out Port. Error: Failed to load the config. Error: ConfigMgmtDPB Class creation failed

This is likely due to the fact that the Yang model is configured with the following expectation for profile_list (a JSON list) which does not match what is the appropriate configuration (a comma separated string).

"sonic-buffer-port-egress-profile-list:sonic-buffer-port-egress-profile-list": {
    "sonic-buffer-port-egress-profile-list:BUFFER_PORT_EGRESS_PROFILE_LIST": {
        "BUFFER_PORT_EGRESS_PROFILE_LIST_LIST": [
            {
                "port": "Ethernet4",
                "profile_list": ["lossless_buffer_profile", "lossless_buffer_profile2"]
            }
        ]    
    }
}

This needs to be reconciled in some manner.

@alexrallen alexrallen changed the title [yang] DPB fails when Dynamic Buffer is configured [yang] DPB fails when BUFFER_PORT_EGRESS_PROFILE is configured Jan 20, 2022
@dgsudharsan dgsudharsan added the YANG YANG model related changes label Jan 20, 2022
@zhangyanzhao
Copy link
Collaborator

Need BUFFER_PORT_EGRESS_PROFILE YANG model owner to take a look. Viswanath will follow up.

@zhangyanzhao zhangyanzhao added the Triaged this issue has been triaged label Jan 20, 2022
@Junchao-Mellanox
Copy link
Collaborator

Junchao-Mellanox commented Feb 11, 2022

Hi @zhangyanzhao, I suppose this issue is related to function _findYangTypedValue: https://github.com/Azure/sonic-buildimage/blob/b621dafff77642db541553f5a2f8ec85e70ea695/src/sonic-yang-mgmt/sonic_yang_ext.py#L410

The issue is that when a CONFIG DB field is defined as "leaf-list", it is usually a comma separated string in CONFIG DB. In this case, the value is "egress_lossless_profile,egress_lossy_profile". Function _findYangTypedValue will iterate this string and put it to vValue. Hence, the vValue is "e,g,r,e,s,s...". Apparently, "e" is not a valid value of field "profile_list". I suppose a possible fix is to fix function _findYangTypedValue line 410 to something like:

        if leafDict[key]['__isleafList']:
            vValue = list()
            if isinstance(value, str):
                value = (x.strip() for x in value.split(','))
            for v in value:
                vValue.append(_yangConvert(v))

I did a simple test based on the fix, it works, but I suppose we still need sonic-yang-mgmt owner to confirm that this is a valid fix.

@dgsudharsan
Copy link
Collaborator

@praveen-li @zhangyanzhao @zhenggen-xu Can you please prioritize this?

@praveen-li
Copy link
Collaborator

Not sure, How the tests for PR #7838 passed in this case ?

@AmitKaushik7, @dgsudharsan @zhangyanzhao

Seems by using a HACK in test config. I guess, SOT for config is important, because either config used in test or used in this issue is wrong.

    "BUFFER_PORT_EGRESS_PROFILE_LIST": {
        "Ethernet9": {
            "profile_list": ["egress_lossless_profile", "egress_lossy_profile"] <<<< List is not correct config?
        }
    },

Ideal fix maybe to convert String to List in Back-end i.e. in orchagent code. OR
have a must condition or custom-validator here.

@zhangyanzhao
Copy link
Collaborator

@bandaru-viswanath will work with @dgsudharsan and @praveen-li on this issue.

@liat-grozovik
Copy link
Collaborator

@bandaru-viswanath any update? as this issue for 202111 can you please provide ETA?

@bandaru-viswanath
Copy link

bandaru-viswanath commented Mar 8, 2022

@bandaru-viswanath any update? as this issue for 202111 can you please provide ETA?

@liat-grozovik We checked and asked the concerned person to work on this. Will get back to you on the ETA.

@Junchao-Mellanox
Copy link
Collaborator

Hi @liat-grozovik , I have a proposal for this issue, will include you to the loop.

@qiluo-msft
Copy link
Collaborator

qiluo-msft commented Mar 10, 2022

@alexrallen Could you help me understand the problem statement?

what is the appropriate configuration (a comma separated string)

I checked code in src/sonic-yang-models/tests/files/sample_config_db.json, and the appropriate configuration should be a list of strings.

@alexrallen
Copy link
Contributor Author

This is what is used in the test for this Yang model (this is working)

"sonic-buffer-port-egress-profile-list:sonic-buffer-port-egress-profile-list": {
    "sonic-buffer-port-egress-profile-list:BUFFER_PORT_EGRESS_PROFILE_LIST": {
        "BUFFER_PORT_EGRESS_PROFILE_LIST_LIST": [
            {
                "port": "Ethernet4",
                "profile_list": ["lossless_buffer_profile", "lossless_buffer_profile2"]
            }
        ]    
    }
}

This is what we are giving in CONFIG_DB

    "BUFFER_PORT_EGRESS_PROFILE_LIST": {
        "Ethernet0": {
            "profile_list": "egress_lossless_profile,egress_lossy_profile"
        }
    }

You can see the former is a JSON list and the latter is a comma separated list. This is a discrepancy.

@AmitKaushik7
Copy link
Contributor

As alexrallen pointed that BUFFER_PORT_EGRESS_PROFILE_LIST and BUFFER_PORT_INGRESS_PROFILE_LIST yang files are incorrectly having the profile_list
as Lists ("profile_list": ["lossless_buffer_profile", "lossless_buffer_profile2"]).
Rather these leaves should have been a comma separated string ("profile_list": "lossless_buffer_profile, lossless_buffer_profile2".).

qiluo-msft pushed a commit that referenced this issue May 5, 2022
#### Why I did it

Fix issue: Non compliant leaf list in config_db schema: #9801

#### How I did it

The basic flow of DPB is like:
1.	Transfer config db json value to YANG json value, name it “yangIn”
2.	Validate “yangIn” by libyang
3.	Generate a YANG json value to represent the target configuration, name it “yangTarget”
4.	Do diff between “yangIn” and “yangTarget”
5.	Apply the diff to CONFIG DB json and save it back to DB
 
The fix:
•	For step #1, If value of a leaf-list field string type, transfer it to a list by splitting it with “,” the purpose here is to make step#2 happy. We also need to save <table_name>.<key>.<field_name> to a set named “leaf_list_with_string_value_set”.
•	For step#5, loop “leaf_list_with_string_value_set” and change those fields back to a string.


#### How to verify it

1. Manual test
2. Changed sample config DB and unit test passed
Junchao-Mellanox added a commit to Junchao-Mellanox/sonic-buildimage that referenced this issue May 6, 2022
…net#10291)

Fix issue: Non compliant leaf list in config_db schema: sonic-net#9801

The basic flow of DPB is like:
1.	Transfer config db json value to YANG json value, name it “yangIn”
2.	Validate “yangIn” by libyang
3.	Generate a YANG json value to represent the target configuration, name it “yangTarget”
4.	Do diff between “yangIn” and “yangTarget”
5.	Apply the diff to CONFIG DB json and save it back to DB

The fix:
•	For step #1, If value of a leaf-list field string type, transfer it to a list by splitting it with “,” the purpose here is to make step#2 happy. We also need to save <table_name>.<key>.<field_name> to a set named “leaf_list_with_string_value_set”.
•	For step#5, loop “leaf_list_with_string_value_set” and change those fields back to a string.

1. Manual test
2. Changed sample config DB and unit test passed

Conflicts:
	src/sonic-yang-mgmt/sonic_yang_ext.py
judyjoseph pushed a commit that referenced this issue May 9, 2022
#10768)

Fix issue: Non compliant leaf list in config_db schema: #9801

The basic flow of DPB is like:
1.	Transfer config db json value to YANG json value, name it “yangIn”
2.	Validate “yangIn” by libyang
3.	Generate a YANG json value to represent the target configuration, name it “yangTarget”
4.	Do diff between “yangIn” and “yangTarget”
5.	Apply the diff to CONFIG DB json and save it back to DB

The fix:
•	For step #1, If value of a leaf-list field string type, transfer it to a list by splitting it with “,” the purpose here is to make step#2 happy. We also need to save <table_name>.<key>.<field_name> to a set named “leaf_list_with_string_value_set”.
•	For step#5, loop “leaf_list_with_string_value_set” and change those fields back to a string.

1. Manual test
2. Changed sample config DB and unit test passed

Conflicts:
	src/sonic-yang-mgmt/sonic_yang_ext.py
liushilongbuaa pushed a commit to liushilongbuaa/sonic-buildimage that referenced this issue Jun 20, 2022
…net#10291)

#### Why I did it

Fix issue: Non compliant leaf list in config_db schema: sonic-net#9801

#### How I did it

The basic flow of DPB is like:
1.	Transfer config db json value to YANG json value, name it “yangIn”
2.	Validate “yangIn” by libyang
3.	Generate a YANG json value to represent the target configuration, name it “yangTarget”
4.	Do diff between “yangIn” and “yangTarget”
5.	Apply the diff to CONFIG DB json and save it back to DB

The fix:
•	For step #1, If value of a leaf-list field string type, transfer it to a list by splitting it with “,” the purpose here is to make step#2 happy. We also need to save <table_name>.<key>.<field_name> to a set named “leaf_list_with_string_value_set”.
•	For step#5, loop “leaf_list_with_string_value_set” and change those fields back to a string.

#### How to verify it

1. Manual test
2. Changed sample config DB and unit test passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BRCM Issue for 202111 Triaged this issue has been triaged YANG YANG model related changes
Projects
None yet
Development

No branches or pull requests

9 participants