-
Notifications
You must be signed in to change notification settings - Fork 667
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 multi-asic behaviour for dropstat #3059
Fix multi-asic behaviour for dropstat #3059
Conversation
8ea458b
to
913220a
Compare
scripts/dropstat
Outdated
if namespace and namespace not in namespaces: | ||
raise Exception("Input arguments error. Namespaces must be one of", *namespaces) | ||
|
||
if multi_asic.is_multi_asic() and not namespace: |
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 can be replaced with a more consistent way at line 411:
@click.option('-n', '--namespace', help='Namespace name',
required=True if multi_asic.is_multi_asic() else False, type=click.Choice(multi_asic.get_namespace_list()))
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.
@wenyiz2021 are you sure we should be using the @click
decorators within the scripts/
folder?
This dropstat
file doesn't hold any CLI commands just the implementation code for querying the redis DBs
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.
See latest change. I took your suggestion to use the click library. Thanks!
tests/multi_asic_dropstat_test.py
Outdated
os.environ["UTILITIES_UNIT_TESTING"] = "1" | ||
os.environ["UTILITIES_UNIT_TESTING_TOPOLOGY"] = "multi_asic" | ||
print("SETUP") | ||
|
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.
can you add edge cases like:
- when no namespace is given for multi-asic
- when namespace is given on single-asic
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.
See latest change. Above two edges have been covered in new UTs.
@bktsim-arista Few things -
|
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 check comment
For questions 1 & 2: This PR only adds multi-asic support to |
and ensuring that dropstat iterates through correct namespaces when 'show' command is run.
This reverts commit 4116cc0.
- Use click library as suggested by Wenyi to simplify argument parsing - Support --namespace argument conditionally. If not passed, the default behavior is to display all namespaces. - Utilize `run_on_multi_asic` decorator to abstract iterating over namespaces - Added and updating UTs
d750f06
to
030f466
Compare
Multi-asic counter clear is supported by unconditionally caching counters from all namespaces. Also add new UTs to cover changes.
030f466
to
b963c4e
Compare
@arlakshm please review |
counter_type = args.type | ||
|
||
dcstat = DropStat() | ||
@click.command(help='Display drop counters') |
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.
why do we need to add this change here?
dropstat
is standalone python script. the click options need to present in show/dropcounter.py
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.
The original script also supported argument parsing. Using the click
simplified that logic significantly. It was suggested earlier by Wenyi and I agree this is an improvement over what was originally implemented. Furthermore, the UTs directly call this script.
@@ -1,5 +1,6 @@ | |||
import click | |||
import utilities_common.cli as clicommon | |||
import utilities_common.multi_asic as multi_asic_util |
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.
Can you add some test to cover the single asic as well?
Also fixed test_show_pg_drop_masic_invalid_ns
To avoid interference of cached counters between UTs.
The latest changes support this. |
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.
LGTM
@arlakshm @vmittal-msft please check if your review comments are resolved |
For example,
|
25a7293
to
76ce6c4
Compare
Also some minor test renaming and cleanup for clarity
76ce6c4
to
b2df7ae
Compare
@arlakshm has a concern on using |
Thanks @wenyiz2021 . The @click library usage in the script significantly improves the readability and maintainability of the standalone script. Thanks Wenyi for suggesting it. I think this is a good change. @arlakshm please let me know how you would like to proceed. I recommend keeping the change 😄 |
@wenyiz2021 can you help merge this change? |
* Fixes dropstat multi-asic behaviour by using multi-asic helpers and ensuring that dropstat iterates through correct namespaces when 'show' command is run. Co-authored-by: rdjeric <rdjeric@arista.com> Co-authored-by: Kenneth Cheung <kennethcheung@arista.com>
Cherry-pick PR to 202405: #3637 |
* Fixes dropstat multi-asic behaviour by using multi-asic helpers and ensuring that dropstat iterates through correct namespaces when 'show' command is run. Co-authored-by: rdjeric <rdjeric@arista.com> Co-authored-by: Kenneth Cheung <kennethcheung@arista.com>
What I did
Previously, dropstat was not behaving correctly on multi-asic devices as the correct namespaces were not being traversed and namespace option
-n
was not available. This change fixes the multi-asic behaviour of this command and adds the-n
option, with relevant unit tests to ensure correct functionality.This is a part of the set of changes being pushed for sonic-net/sonic-buildimage#15148
How I did it
Added
-n
argument for multi-asic devices and relevant unit tests.How to verify it
Use
dropstat -c show
with-n
.