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

Fix for Switch Port Modes and VLAN CLI Enhancement #3108

Merged
merged 19 commits into from
Mar 1, 2024

Conversation

sabakram
Copy link
Contributor

@sabakram sabakram commented Jan 1, 2024

What I did

This PR is Fixture for PR#2419. The original code PR was reverted due to nonavailability of YANG Model. The code provided by this PR is exactly same as reviewed & approved by reveiwers.
To Fix issues we break the code in three PR as per suggestions:
1. yang models without must condition
2. sonic-config-engine
3. sonic-utilities-fix

How I did it

Code logic added in original PR is added again with new PR to resolve issue

How to verify it

New commands have been added in Command-Reference.md All the syntax and examples have been added there and they can be verified by running the specific command

@sabakram sabakram marked this pull request as ready for review January 10, 2024 10:30
@sabakram sabakram changed the title Fix for switchport mode PR Fix for Switch Port Modes and VLAN CLI Enhancement Jan 10, 2024
@ridahanif96
Copy link
Contributor

@qiluo-msft can you please help review this PR!

@qiluo-msft
Copy link
Contributor

Could you provide which PR fixed "nonavailability of YANG Model"?

@ridahanif96
Copy link
Contributor

Could you provide which PR fixed "nonavailability of YANG Model"?

Please see YANG PR

@ridahanif96
Copy link
Contributor

@gechiang & @theasianpianist Can you please help review this PR. Thanks!

@ridahanif96
Copy link
Contributor

@gechiang @venkatmahalingam @theasianpianist can you all pls help review this PR. Thanks

@click.argument('port', metavar='<port>', required=True)
@click.option('-m', '--multiple', is_flag=True, help="Add Multiple Vlan(s) in Range or in Comma separated list")
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

Copy link
Contributor

Choose a reason for hiding this comment

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

Please note that --multiple flag is required as we did not add our new functionality to the existing command to keep intact the existing VLAN behavior/command.

@@ -74,57 +99,74 @@ def delete_db_entry(entry_name, db_connector, db_name):


@vlan.command('del')
@click.argument('vid', metavar='<vid>', required=True, type=int)
@click.argument('vid', metavar='<vid>', required=True)
@click.option('-m', '--multiple', is_flag=True, help="Add Multiple Vlan(s) in Range or in Comma separated list")
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

Copy link
Contributor

Choose a reason for hiding this comment

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

Please note mutliple_vlan_parser will handle vlan(single, comma separated, range) on that list. This vid is exisiting behavior of VLANs. We don't modify existing behavior and added our proposed changes

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need the --multiple flag if the parser can already handle all possible inputs?

Copy link
Contributor

Choose a reason for hiding this comment

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

Please note that --multiple flag is required as we did not add our new functionality to the existing command to keep intact the existing VLAN behavior/command.

@prsunny
Copy link
Contributor

prsunny commented Feb 7, 2024

@theasianpianist , could you check the reply and signoff if looks good?

@ridahanif96
Copy link
Contributor

@theasianpianist can you please check responses and sign off this PR if you agree.
All code changes provided by this PR is same as being reviewed and approved earlier.

@ridahanif96
Copy link
Contributor

@qiluo-msft can you pls help merge this PR, it's approved by reviewers.

@ridahanif96
Copy link
Contributor

@qiluo-msft Can you please help merge this PR! Thanks

@prsunny prsunny self-requested a review February 24, 2024 01:56
@prsunny
Copy link
Contributor

prsunny commented Feb 24, 2024

@sabakram , could you please confirm if all the previous CLI commands works exactly as expected and no compatibility issue? We have external scripts using these commands and a new image with this change should not break those old commands. Can you confirm?

@sabakram
Copy link
Contributor Author

@sabakram , could you please confirm if all the previous CLI commands works exactly as expected and no compatibility issue? We have external scripts using these commands and a new image with this change should not break those old commands. Can you confirm?

Yes, it is confirmed that all previous CLI commands works as expected and no compatibility issue. We only provide these new commands and switchport modes. The utilities PR was reverted earlier due to issues in rollback. Now since YANG model has been merged. We have tested with latest master and GCU rollbacked successfully. Please see below running behavior of these commands
Screenshot from 2024-02-25 00-56-02
Screenshot from 2024-02-25 00-57-40
Screenshot from 2024-02-25 00-58-08

@ridahanif96
Copy link
Contributor

@qiluo-msft can you pls help merge this PR, thanks.

@zhangyanzhao zhangyanzhao merged commit 92220dc into sonic-net:master Mar 1, 2024
5 checks passed
elif not is_port:
port_data = config_db.get_entry('PORTCHANNEL',port)

if "mode" not in port_data:
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @sabakram , I suspect this line break backward compatibility.
It will wrongly treat a port as routed when 'mode' is not present even though it pass the check in
Line 297:

if (is_port and clicommon.is_port_router_interface(db.cfgdb, port)) or \
                (not is_port and clicommon.is_pc_router_interface(db.cfgdb, port)): # TODO: MISSING CONSTRAINT IN YANG MODEL
                ctx.fail("{} is in routed mode!\nUse switchport mode command to change port mode".format(port))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @wen587 ,
We are already looking into backward compatibility issues for that we have removed all changes in db_migrator where we remove this default mode routed behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @sabakram , I think not only in db_migrator. But also in vlan config commands.
In sonic-mgmt, the test tests/generic_config_updater/test_dhcp_relay.py fail with new vlan config commands.
The Ethernet4 was treated as routed mode whereas it was not before.
Please check below error message.

"results": [{"cmd": "config vlan add 108", "cmd_with_timeout": "", "err_msg": "", "rc": 0, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": [], "timeout": 0}, {"cmd": "config interface ip add Vlan108 192.168.8.1/24", "cmd_with_timeout": "", "err_msg": "", "rc": 0, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": [], "timeout": 0}, {"cmd": "config vlan add 109", "cmd_with_timeout": "", "err_msg": "", "rc": 0, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": [], "timeout": 0}, {"cmd": "config interface ip add Vlan109 192.168.9.1/24", "cmd_with_timeout": "", "err_msg": "", "rc": 0, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": [], "timeout": 0}, {"cmd": "config vlan member add 108 Ethernet4", "cmd_with_timeout": "", "err_msg": "", "rc": 2, "stderr": "Usage: config vlan member add [OPTIONS] port\nTry "config vlan member add -h" for help.\n\nError: Ethernet4 is in routed mode!\nUse switchport mode command to change port mode\n", "stderr_lines": ["Usage: config vlan member add [OPTIONS] port", "Try "config vlan member add -h" for help.", "", "Error: Ethernet4 is in routed mode!", "Use switchport mode command to change port mode"], "stdout": "", "stdout_lines": [], "timeout": 0}, {"cmd": "config vlan member add 109 Ethernet4", "cmd_with_timeout": "", "err_msg": "", "rc": 2, "stderr": "Usage: config vlan member add [OPTIONS] port\nTry "config vlan member add -h" for help.\n\nError: Ethernet4 is in routed mode!\nUse switchport mode command to change port mode\n", "stderr_lines": ["Usage: config vlan member add [OPTIONS] port", "Try "config vlan member add -h" for help.", "", "Error: Ethernet4 is in routed mode!", "Use switchport mode command to change port mode"]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wen587 Hi,

Okay we also remove this check from vlan config to avoid this failure in GCU

wen587 added a commit that referenced this pull request Mar 27, 2024
wen587 added a commit that referenced this pull request Mar 28, 2024
arfeigin pushed a commit to arfeigin/sonic-utilities that referenced this pull request Apr 2, 2024
qiluo-msft pushed a commit that referenced this pull request May 10, 2024
#### What I did
This PR is Fixture for #3108 The PR was reverted due to backward compatibility issues. As per new suggestions, removed db migrator changes from this new change along with vlan.py & switchport.py changes

To Fix issues as per suggestions removed default mode from YANG model and removed minigraph changes:

#### How I did it
       1. Removed Db migrator changes from code. 
       2. Modified Vlan.py & Switchport.py changes 

#### How to verify it
New commands have been added in Command-Reference.md  All the syntax and examples have been added there and they can be verified by running the specific command
arfeigin pushed a commit to arfeigin/sonic-utilities that referenced this pull request Jun 16, 2024
This PR is Fixture for sonic-net#3108 The PR was reverted due to backward compatibility issues. As per new suggestions, removed db migrator changes from this new change along with vlan.py & switchport.py changes

To Fix issues as per suggestions removed default mode from YANG model and removed minigraph changes:

       1. Removed Db migrator changes from code.
       2. Modified Vlan.py & Switchport.py changes

New commands have been added in Command-Reference.md  All the syntax and examples have been added there and they can be verified by running the specific command
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.

8 participants