-
Notifications
You must be signed in to change notification settings - Fork 664
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
[config] Add support of PortChannels to portconfig #1375
base: master
Are you sure you want to change the base?
Conversation
Diff looks good, works fine with Ethernet and PortChannel ports, will need this for 201911. Thanks |
@maksymbelei95 |
I have tested the case. Here is my output:
Another case(the port channel has a member):
Both cases look good.
Sure. But, as I mentioned before in the related ticket, I found out that there are no unit tests, related to |
@maksymbelei95 Please follow the above PR and add the necessary test cases. |
scripts/portconfig
Outdated
@@ -22,15 +22,20 @@ import argparse | |||
import swsssdk | |||
|
|||
PORT_TABLE_NAME = "PORT" | |||
PORTCHANNEL_TABLE_NAME = "PORTCHANNEL" | |||
PORT_PREFIX_ETHERNET = "Ethernet" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the API's defined in https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-py-common/sonic_py_common/interface.py. This prevents duplicate definitions of table names and prefixes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
scripts/portconfig
Outdated
if args.port.startswith(PORT_PREFIX_ETHERNET): | ||
port_table_name = PORT_TABLE_NAME | ||
elif args.port.startswith(PORT_PREFIX_PORTCHANNEL): | ||
port_table_name = PORTCHANNEL_TABLE_NAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic can also be replaced with https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-py-common/sonic_py_common/interface.py#L69
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cc1c90a
to
9e50825
Compare
retest this please |
@gechiang, @judyjoseph, I have added a related unit test cases to the PR. Could I ask you to review them? |
@gechiang, @judyjoseph, could you review the PR? |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
9e50825
to
3f07964
Compare
@gechiang, @judyjoseph, I have rebased the PR, unit tests done successfully. Could your check the PR? |
@maksymbelei95, Could you please resolve this conflict before we merge it in - thanks. |
@maksymbelei95 It appears that if a port is already a member of portchannel, user can still configure its MTU on its own? If there is a conflict between portchannel configured MTU and that of its member I believe the portchannel will force its value to its member. but after that if another MTU configured to one of its member with conflicting value, I believe it will again becomes a conflict. I think if we decide to support MTU configured on port-channel, we must add check to disallow user from configuring MTU onto the individual LAG members. Also, when the port is being converted to LAG, we should check that if its MTU is at default value and if it is not, we should disallow the user from adding it to portchannel until that is corrected and then let it inherit what is already configured for the LAG itself. We also need to consider what if a member is deleted from port-channel, what would its MTU be? Retain what it inherited from the port-channel? or go back to default MTU? I think all these requires some answer before we should allow MTU configuration for portchannel. Can you work on these so that we have a solid coverage of all these scenarios? Thanks! |
* Adding support of PortChannels to portconfig script to be able to configure PortChannels by CLI commands, like 'config interface mtu' Signed-off-by: Maksym Belei <[email protected]>
* Reformat the script according to Python code style, fix typos. Signed-off-by: Maksym Belei <[email protected]>
…Minor refactoring. * Adding mocking of redis DB into portconfig script for unit testing purpose. * Using of commom API from sonic_py_common.interface instead of defining of own constants and conditions. * Refactoring "mtu" function to be more consistant and efficient. Signed-off-by: Maksym Belei <[email protected]>
* Adding unit tests for subcommand 'config intf mtu' including testing of portconfig script. Signed-off-by: Maksym Belei <[email protected]>
3f07964
to
f353275
Compare
@gechiang I have checked all cases you mentioned above. |
This pull request fixes 1 alert when merging f35327586450378678f7633fd2aae05112b299bd into 9017d99 - view on LGTM.com fixed alerts:
|
f353275
to
f696658
Compare
Signed-off-by: Mykola Horb <[email protected]>
f696658
to
cfb23f6
Compare
This pull request fixes 1 alert when merging cfb23f6 into 9017d99 - view on LGTM.com fixed alerts:
|
@judyjoseph Please run this PR again for testing |
This pull request fixes 1 alert when merging e063eca into 63a5257 - view on LGTM.com fixed alerts:
|
fixed alert about unused import found by bot is not an error. It is designed for unit tests. |
@judyjoseph Could you please review the changes |
[sonic-swsss] Fix the issue of field "next_hop_ip" not getting updated in state DB in ERSPAN Mirror (sonic-net#1375) [vlanmgr] Support Jumbo Frame By Default (sonic-net#1393) [fec] added logic that put port down before applying fec onfiguration (sonic-net#1399) [fec] Get FEC mode when port is already admin down (sonic-net#1403) Refine getDbId() calling to fix build after swss-common change (sonic-net#1245)
# The checks are only for Ethernet interfaces and their aliases | ||
if clicommon.get_interface_naming_mode() == "alias": | ||
name_from_alias = interface_alias_to_name(config_db, interface_name) | ||
if interface_name is None or name_from_alias == interface_name: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this added check you are requiring that once the device is configured with naming_mode alias it must use the alias name and not the SONiC interface name and it will cause this to fail? Can we preserve the original design/check and not treat the case where the look up resulted to the same name as a failure scenario?
@@ -258,26 +263,30 @@ def main(): | |||
# Load database config files | |||
load_db_config() | |||
try: | |||
port_table_name = interface.get_port_table_name(args.port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tested this with device set to naming_mode as "alias" and if you passed the alias name instead would this still work? I think we should move the naming mode check to here instead of handled at set_mtu only so that it should be handling the alias case in case naming_mode is set to alias?
Why is this not yet merged???
|
- What I did
Resolves sonic-net/sonic-buildimage#6430
Added support of PortChannels to portconfig script.
Added mocking of redis into
portconfig
script.Added unit tests for subcommand
config interface mtu
.- How I did it
Added checking of prefix in name of port, passed to the script. If it is
EthernetXX
, the script uses table namePORT
to operate with DB, if it isPortChannelXX
, then the script will use table namePORTCHANNEL
, otherwise it will throw an exception to notify that port type is wrong.- How to verify it
ip link show PortChannel0001
Test result in case the portchannel has no members:
Test result in case the portchannel has a member:
- Previous command output (if the output of a command-line utility has changed)
- New command output (if the output of a command-line utility has changed)
if to try to pass some trash as port argument, like this
sudo config interface mtu Unknown0002 9100
, you will receive error in console output:Invalid port type specified