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

Confirm portchannel and member ports exist before attempting delete operations #454

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

madhupalu
Copy link
Contributor

@madhupalu madhupalu commented Feb 3, 2019

commit 70c12ed41138a25ce486581354ba7139bfecd14c (HEAD -> azure277)
Author: madhu Pal madhupa@aviznetworks.com
Date: Sun Feb 3 00:00:21 2019 +0000

Added validations to portchannel & members deletes only it is configured (#277)

Signed-off-by: madhu Pal <madhupa@aviznetworks.com>

- What I did
Added validations to portchannel & port channel members delete operations only it is configured
- How I did it
Checked Portchannel and PortChannel member configDB to validate the port channel/members exists before delete them.
- How to verify it
1. delete a portchannel which is not configured, CLI should throws an error
image

2. delete a portchannel member which is not configured, CLI should throws an error
image

3. Add a portchannel member where portchannel didn't configured, CLI throws an error
I Found this bug while doing unit testing.
image

Additional cases with vendor interfaces
image
image
image
Test 4: delete port channel without deleting port channel members
image

…members add/delete

                     only when it is configured (sonic-net#277)

Signed-off-by: madhu Pal <madhupa@aviznetworks.com>
@msftclas
Copy link

msftclas commented Feb 3, 2019

CLA assistant check
All CLA requirements met.

…red (sonic-net#277)

Signed-off-by: madhu Pal <madhupa@aviznetworks.com>
@madhupalu madhupalu changed the title [config/main.py] Fixed - added validations such that portchannel and … Added validations to portchannel & members deletes only it is configured (#277) Feb 3, 2019
@madhupalu
Copy link
Contributor Author

madhupalu commented Feb 3, 2019

Issue Link- sonic-net/SONiC#277

Copy link
Contributor

@jleveque jleveque left a comment

Choose a reason for hiding this comment

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

These functions need to work under both interface naming modes (default and alias). Please refer to add_vlan_member() and del_vlan_member() for examples. You can test by switching modes using config interface_naming_mode [default | alias].

@madhupalu
Copy link
Contributor Author

thanks for the comments, I'll add interface alias test cases to the code changes.
-Madhu

…erations, covered vendor interfaces as well. (sonic-net#277)

Signed-off-by: madhu Pal <madhupa@aviznetworks.com>
… into azure277

wq
Signed-off-by: madhu Pal <madhupa@aviznetworks.com>
Signed-off-by: madhu Pal <madhupa@aviznetworks.com>
@madhupalu
Copy link
Contributor Author

I've updated the PR with all switching modes [default | alias] cases for your review.
Thanks,
-Madhu

@madhupalu
Copy link
Contributor Author

jleveque, Can you review and provide your comments.
thanks,

@jleveque jleveque changed the title Added validations to portchannel & members deletes only it is configured (#277) Confirm portchannel and member ports exist before attempting delete operations Feb 15, 2019
@jleveque
Copy link
Contributor

@madhupalu: I updated the title of this PR for clarity.

@jleveque
Copy link
Contributor

Retest this please

…tempting delete operations (sonic-net#277)

Signed-off-by: madhu Pal <madhupa@aviznetworks.com>
@madhupalu
Copy link
Contributor Author

Joe, Shuotian,
thanks for review comments and approved my changes. I've covered few more corner cases, updated it.
Thanks,
-Madhu

jleveque
jleveque previously approved these changes Feb 19, 2019
config/main.py Outdated
members = port_channel.get('members', [])
if port_name in members:
if get_interface_naming_mode() == "alias":
port_name = interface_name_to_alias(port_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

will this line duplicate with line 475?
if it is 'alias' mode and the port_name is already in members, it will try to convert the name again?

Copy link
Contributor Author

@madhupalu madhupalu Mar 7, 2019

Choose a reason for hiding this comment

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

Thanks for review comments, I'll fix and run the test cases, will update the PR shortly

if len(members) == 0:
del port_channel['members']
else:
port_channel['members'] = members
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 Author

Choose a reason for hiding this comment

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

we need the **members** variable to delete the port channel when there are no members in it. AFAIK, we delete port channels when there are no members in it, not sure the SONiC use case. please advise.

Thanks
Madhu

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed the review comments and updated the PR. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

there're alternative ways of checking if the port-channel has members or not. please do not use this approach. we are trying to make the code DRY by not having duplicated information on two places; this attribute won't be supported in the future release

…h remove_portchannel

Signed-off-by: madhu Pal <madhupa@aviznetworks.com>
@jleveque
Copy link
Contributor

@stcheng: Can you please re-review?

if len(members) == 0:
del port_channel['members']
else:
port_channel['members'] = members
Copy link
Contributor

Choose a reason for hiding this comment

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

there're alternative ways of checking if the port-channel has members or not. please do not use this approach. we are trying to make the code DRY by not having duplicated information on two places; this attribute won't be supported in the future release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants