-
Notifications
You must be signed in to change notification settings - Fork 666
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
Add range check on portchannel min-links #1630
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Raphael Tryster <raphaelt@nvidia.com>
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Other PRs have failed automatic tests in the same way on dpb_arp tests, which clearly have nothing to do with the PR content. For example, #1635. |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Raphael Tryster <raphaelt@nvidia.com>
joyas-joseph
approved these changes
Jun 14, 2021
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
lguohan
approved these changes
Jun 21, 2021
raphaelt-nvidia
added a commit
to raphaelt-nvidia/sonic-utilities
that referenced
this pull request
Aug 10, 2021
Restrict the min-links parameter in "config portchannel" to the range 0-1024. Signed-off-by: Raphael Tryster <raphaelt@nvidia.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Raphael Tryster raphaelt@nvidia.com
What I did
Restrict the min-links parameter in "config portchannel" to the range 0-1024.
Fixes sonic-net/sonic-buildimage#6781 in conjunction with https://github.com/Azure/sonic-buildimage/pull/7265/files.
How I did it
Changed
@click.option('--min-links', default=0, type=int)
to
@click.option('--min-links', default=0, type=click.IntRange(0,1024))
Note that all these need to be aligned:
the default value
the range enforced here
the limits in libteam
the limits in the yang model
The first two of these are in this PR; the last two are in the other one referred to above. The alignment was performed as follows:
the default value - remained 0
the range enforced here - previously absent, now 0-1024
the limits in libteam - maximum was 255, now 1024
the limits in the yang model - was 1-128, now 0-1024
How to verify it
config portchannel add PortChannel0004 --min-links 1024
Command should be accepted.
show interfaces portchannel
Output should show PortChannel0004, no errors on CLI.
config portchannel add PortChannel0005 --min-links 1025
Command should be rejected
show interfaces portchannel
Output should not show PortChannel0005 , no errors on CLI.
Previous command output (if the output of a command-line utility has changed)
config portchannel add PortChannel0004 --min-links 1024
show interfaces portchannel
Traceback (most recent call last):
File "/usr/local/bin/show", line 8, in
sys.exit(cli())
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 764, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/show/interfaces/portchannel.py", line 165, in portchannel
team.get_teams_info()
File "/usr/local/lib/python3.7/dist-packages/utilities_common/multi_asic.py", line 137, in wrapped_run_on_all_asics
func(self, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/show/interfaces/portchannel.py", line 49, in get_teams_info
self.get_teamshow_result()
File "/usr/local/lib/python3.7/dist-packages/show/interfaces/portchannel.py", line 111, in get_teamshow_result
info['protocol'] += "(A)" if state['runner.active'] == "true" else '(I)'
KeyError: 'runner.active'
config portchannel add PortChannel0005 --min-links 1025
show interfaces portchannel
Traceback (most recent call last):
File "/usr/local/bin/show", line 8, in
sys.exit(cli())
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 764, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/show/interfaces/portchannel.py", line 165, in portchannel
team.get_teams_info()
File "/usr/local/lib/python3.7/dist-packages/utilities_common/multi_asic.py", line 137, in wrapped_run_on_all_asics
func(self, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/show/interfaces/portchannel.py", line 49, in get_teams_info
self.get_teamshow_result()
File "/usr/local/lib/python3.7/dist-packages/show/interfaces/portchannel.py", line 111, in get_teamshow_result
info['protocol'] += "(A)" if state['runner.active'] == "true" else '(I)'
KeyError: 'runner.active'
New command output (if the output of a command-line utility has changed)
config portchannel add PortChannel0004 --min-links 1024
show interfaces portchannel
No. Team Dev Protocol Ports
0004 PortChannel0004 LACP(A)(Dw) N/A
config portchannel add PortChannel0005 --min-links 1025
Error: Invalid value for "--min-links": 1025 is not in the valid range of 0 to 1024.
show interfaces portchannel
No. Team Dev Protocol Ports
0004 PortChannel0004 LACP(A)(Dw) N/A