Skip to content

[master] [show] Option to add subcommands to show techsupport #2974

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

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

Conversation

gvlaemyn
Copy link
Contributor

@gvlaemyn gvlaemyn commented Sep 8, 2023

What I did

Implement option to add subcommands to "show techsupport", e.g. "show techsupport npu"
to have to possibility of restricting the collected data to a subset of the full techsupport data.

How I did it

* replace techsupport click command in show/main.py with click group to support subcommands
* update show/plugins/cisco-8000.py to support vendor specific commands
* subcommand functionality itself (e.g. npu) is implemented in a vendor specific repository and requires no further changes in sonic-utilities

How to verify it

E.g. for the "show techsupport npu" command on a cisco-8000 platform:

  1. Check if the "npu" subcommand is available:
    root@sonic:~# show techsupport -h
    Usage: show techsupport [OPTIONS] COMMAND [ARGS]...

Gather information for troubleshooting

Options:
--since TEXT Collect logs and core files since given date
-g, --global-timeout INTEGER Global timeout in minutes. WARN: Dump might be
incomplete if enforced
-c, --cmd-timeout INTEGER Individual command timeout in minutes. Default
5 mins
--verbose Enable verbose output
--allow-process-stop Dump additional data which may require system
interruption
--silent Run techsupport in silent mode
--debug-dump Collect Debug Dump Output
-r, --redirect-stderr Redirect an intermediate errors to STDERR
-?, -h, --help Show this message and exit.

Commands:
npu Gather platform npu information

  1. Run "show techsupport npu" and verify an archive with the collected data is created:
    root@sonic:~# show techsupport npu
    . . .
    /var/dump/sonic_npu_dump_hostname_20230828_105958.tar.gz

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)

@gvlaemyn gvlaemyn changed the title [show] Option to add subcommands to show techsupport [202205] [show] Option to add subcommands to show techsupport Sep 8, 2023
* replace techsupport click command with click group to support subcommands

* update plugins/cisco-8000.py to support vendor specific commands

Signed-off-by: Geert Vlaemynck <[email protected]>
@gvlaemyn gvlaemyn changed the base branch from 202205 to master September 12, 2023 10:40
@gvlaemyn gvlaemyn changed the title [202205] [show] Option to add subcommands to show techsupport [master] [show] Option to add subcommands to show techsupport Sep 12, 2023
kevinskwang
kevinskwang previously approved these changes Sep 27, 2023
"""Gather information for troubleshooting"""
if ctx.invoked_subcommand:
return
Copy link
Contributor

Choose a reason for hiding this comment

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

why return here?

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 return here to run only the subcommand, e.g. "show techsupport npu" which can be defined in a vendor platform package, instead of the main "show techsupport".

@anamehra
Copy link
Contributor

Thanks @kevinskwang ! Please help to rerun the build pipeline. Thanks

@gvlaemyn
Copy link
Contributor Author

@kevinskwang Thanks for your previous review and approval. Merging was blocked because of a code coverage issue. This has been addressed in a test case in my latest commit. Could you review and approve if appropriate?

from sonic_platform.cli import VENDOR_CLIS
except ImportError:
VENDOR_CLIS = {}


def register(cli):
version_info = device_info.get_sonic_version_info()
if version_info and version_info.get("asic_type") == "cisco-8000":
for c in PLATFORM_CLIS:
cli.commands["platform"].add_command(c)
Copy link
Contributor

Choose a reason for hiding this comment

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

platform

platform is a special case of command. Please unified two for-block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for the two separate loops is to not break backward compatibility in cisco platform specific code which only uses the PLATFORM_CLIS list. New cisco platform specific code will use the VENDOR_CLIS dict, so until all cisco code has been migrated to using VENDOR_CLIS we really do need both for loops.

Choose a reason for hiding this comment

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

Hi @qiluo-msft , if @gvlaemyn's explanation is acceptable could you help with the approval?

Choose a reason for hiding this comment

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

Hi @qiluo-msft , if Geert's explanation is acceptable, please help with the approval. Otherwise, we could arrange for a quick meeting to discuss. Thank you.

Choose a reason for hiding this comment

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

hi @qiluo-msft and @kevinskwang , could you review and approve.

Copy link
Contributor

Choose a reason for hiding this comment

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

What is the plan and ETA for "all cisco code has been migrated to using VENDOR_CLIS"? If I do not ask, will it happen finally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reading the VENDOR_CLIS dictionary in the cisco-8000 plugin was added in this PR just for being able to add the "show techsupport npu" command. My previous comment "until all cisco code has been migrated to using VENDOR_CLIS" may have given the impression that this PR is depending on a lot of internal cisco code to be modified: this is not the case. I should have commented the PLATFORM_CLIS list may not be required to be read anymore in the cisco-8000 plugin at some future time, but currently we need both PLATFORM_CLIS and VENDOR_CLIS to be read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@qiluo-msft @kevinskwang Does the updated code in plugins/cisco-8000.py address your concerns? Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @qiluo-msft , please let us know if @gvlaemyn's comments addressed your concerns and if we can go ahead with this PR.
cc: @abdosi

@anamehra
Copy link
Contributor

Hi @abdosi , @rlhui , could you please help with this PR?

@jamesan47
Copy link

Hi @abdosi , @rlhui , could you please help with this PR for serviceability improvements?

@jamesan47
Copy link

Hi @abdosi , @kevinskwang Please help with review, approval, and merge if no concerns. We would like to have it included in 202405.

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.

5 participants