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

[DPB][YANG] Fix cases when boolean is used in different literal cases #9418

Merged

Conversation

mykolaxgerasymenko
Copy link
Contributor

@mykolaxgerasymenko mykolaxgerasymenko commented Dec 1, 2021

  • Add boolean as typedef to sonic-types
  • Fix boolean in sonic-feature yang model
  • Fix boolean in sonic-flex_counter yang model

Signed-off-by: Mykola Gerasymenko [email protected]

Fixes #9326

Why I did it

When we try execute DPB from CLI we have error:
libyang[0]: Invalid value "False" in "has_global_scope" element. (path: /sonic-feature:sonic-feature/FEATURE/FEATURE_LIST[name='bgp']/has_global_scope)
The reason for this issue is that has_global_scope and other have been stored in redis database with value False or True form capital letter:

   "FEATURE":{
      "bgp":{
         "auto_restart":"enabled",
         "has_global_scope":"False",
         "has_per_asic_scope":"True",
         "has_timer":"False",
         "high_mem_alert":"disabled",
         "state":"enabled"
      }

But yang model support boolean just in lowercase letters (https://datatracker.ietf.org/doc/html/rfc6020#section-9.5.1).

How I did it

Added boolean to sonic-types as typedef with different literal cases.

How to verify it

Run the command config interface breakout <breakout_mode>

NOTE:
To verify this fix, the following PRs that fix other problems in SONiC must be merged into master:

  1. [yang] add set_owner to feature yang #9075
  2. [DPB][YANG] Add POLL_INTERVAL in flex_counter yang model #9276

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106

Description for the changelog

A picture of a cute animal (not mandatory but encouraged)

* Add boolean as typedef to sonic-types
* Fix boolean in sonic-feature yang model
* Fix boolean in sonic-flex_counter yang model

Signed-off-by: Mykola Gerasymenko <[email protected]>
akokhan
akokhan previously approved these changes Dec 1, 2021
@mykolaxgerasymenko
Copy link
Contributor Author

@qiluo-msft Please review.

qiluo-msft
qiluo-msft previously approved these changes Dec 4, 2021
@tw0byt3
Copy link

tw0byt3 commented Dec 7, 2021

@mykolaxgerasymenko After the fix of this is done, the breakout fails due to the CRM yang model. I tried to accommodate the changes required. Post that, this is the error I am facing.

root@localhost:~# config interface breakout Ethernet0 4x10G[25G]
Do you want to Breakout the port, continue? [y/N]: y

Running Breakout Mode : 1x100G[50G,40G,25G,10G]
Target Breakout Mode : 4x10G[25G]

Ports to be deleted :
{
"Ethernet0": "100000"
}
Ports to be added :
{
"Ethernet0": "10000",
"Ethernet1": "10000",
"Ethernet2": "10000",
"Ethernet3": "10000"
}

After running Logic to limit the impact

Final list of ports to be deleted :
{
"Ethernet0": "100000"
}
Final list of ports to be added :
{
"Ethernet0": "10000",
"Ethernet1": "10000",
"Ethernet2": "10000",
"Ethernet3": "10000"
}
Note: Below table(s) have no YANG models:
KDUMP, SNMP, SNMP_COMMUNITY, XCVRD_LOG,
Below Config can not be verified, It may cause harm to the system
{}
Do you wish to Continue? [y/N]: y
Create Config to load in DB, Failed
'str' object has no attribute 'append'
Config Diff Generation failed
'str' object has no attribute 'append'
'str' object has no attribute 'append'
Port Deletion Failed
[ERROR] Port breakout Failed!!! Opting Out
Failed to break out Port. Error:

Can someone help me identity there is this str object?

@mykolaxgerasymenko
Copy link
Contributor Author

mykolaxgerasymenko commented Dec 7, 2021

@mykolaxgerasymenko After the fix of this is done, the breakout fails due to the CRM yang model. I tried to accommodate the changes required. Post that, this is the error I am facing.

root@localhost:~# config interface breakout Ethernet0 4x10G[25G] Do you want to Breakout the port, continue? [y/N]: y

Running Breakout Mode : 1x100G[50G,40G,25G,10G] Target Breakout Mode : 4x10G[25G]

Ports to be deleted : { "Ethernet0": "100000" } Ports to be added : { "Ethernet0": "10000", "Ethernet1": "10000", "Ethernet2": "10000", "Ethernet3": "10000" }

After running Logic to limit the impact

Final list of ports to be deleted : { "Ethernet0": "100000" } Final list of ports to be added : { "Ethernet0": "10000", "Ethernet1": "10000", "Ethernet2": "10000", "Ethernet3": "10000" } Note: Below table(s) have no YANG models: KDUMP, SNMP, SNMP_COMMUNITY, XCVRD_LOG, Below Config can not be verified, It may cause harm to the system {} Do you wish to Continue? [y/N]: y Create Config to load in DB, Failed 'str' object has no attribute 'append' Config Diff Generation failed 'str' object has no attribute 'append' 'str' object has no attribute 'append' Port Deletion Failed [ERROR] Port breakout Failed!!! Opting Out Failed to break out Port. Error:

Can someone help me identity there is this str object?

@tw0byt3
Did you fix the boolean type for src/sonic-yang-models/yang-models/sonic-flex_counter.yang file as I fixed in this PR?
Why do you think that the breakout fails due to the CRM yang model?

@tw0byt3
Copy link

tw0byt3 commented Dec 7, 2021

@mykolaxgerasymenko Yes, I fixed the boolean issue similar to what you have fixed in this PR. The CRM yang model is missing srv6_my_sid_entry_high_threshold, srv6_my_sid_entry_low_threshold, srv6_my_sid_entry_threshold_type, srv6_nexthop_high_threshold, srv6_nexthop_low_threshold, srv6_nexthop_threshold_type.

akokhan
akokhan previously approved these changes Dec 8, 2021
"has_timer": "false",
"has_global_scope": "False",
"has_per_asic_scope": "True",
"has_timer": "False",
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 have added these changes with "False" and "True" with a capital letter to make it clear that this option can also be used and it is valid.

@tw0byt3
Copy link

tw0byt3 commented Dec 9, 2021

@mykolaxgerasymenko Any idea where can I find the 'str' object causing the above issue mentioned.

@mykolaxgerasymenko
Copy link
Contributor Author

@tw0byt3 I faced a similar issue log when was problem with comparing boolean type in sonic-flex_counter.yang. But I fixed it in this PR. After this fix the DPB feature worked correctly.
I haven't tried using DPB after that, so it's possible that some new commits are causing the problem you mentioned.
Hopefully I'll try to reproduce this issue, but I have more priority task for now.
And it will be better if this PR will merge. In this case, the issues resolved in this PR will be excluded.

@mykolaxgerasymenko
Copy link
Contributor Author

@qiluo-msft please merge

@qiluo-msft
Copy link
Collaborator

Could you solve the conflict?

@mykolaxgerasymenko mykolaxgerasymenko dismissed stale reviews from akokhan and qiluo-msft via ba3613f December 9, 2021 20:02
@mykolaxgerasymenko
Copy link
Contributor Author

Could you solve the conflict?

Conflict has been resolved.

qiluo-msft
qiluo-msft previously approved these changes Dec 9, 2021
@mykolaxgerasymenko
Copy link
Contributor Author

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 9418 in repo Azure/sonic-buildimage

@mykolaxgerasymenko
Copy link
Contributor Author

mykolaxgerasymenko commented Dec 10, 2021

@qiluo-msft Could you please restart build CI? I do not have permissions.

@qiluo-msft
Copy link
Collaborator

I triggered the build. As a PR owner, you can try /azpw run Azure.sonic-buildimage on this page.

@mykolaxgerasymenko
Copy link
Contributor Author

I triggered the build. As a PR owner, you can try /azpw run Azure.sonic-buildimage on this page.

Thank you.

@qiluo-msft qiluo-msft merged commit afd4098 into sonic-net:master Dec 10, 2021
@qiluo-msft qiluo-msft added the Request for 202111 Branch For PRs being requested for 202111 branch label Dec 10, 2021
@judyjoseph
Copy link
Contributor

Please raise a new PR for 202111 branch, as this patch cannot be cleanly cherry-picked.

@judyjoseph judyjoseph removed the Request for 202111 Branch For PRs being requested for 202111 branch label Jan 5, 2022
qiluo-msft pushed a commit that referenced this pull request Jan 10, 2022
…#9654)

* Add boolean as typedef to sonic-types
* Fix boolean in sonic-feature yang model
* Fix boolean in sonic-flex_counter yang model

#### Why I did it
It was request to cherry-pick fix from master (#9418) to 202111 branch to fix issue when boolean is used in different literal cases.

#### How I did it
Added boolean to sonic-types as typedef with different literal cases.

#### How to verify it
Run the command config interface breakout <interface_name> <breakout_mode>
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.

[DPB] DPB falls cause of invalid value in "has_global_scope" element
5 participants