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

[CLI][techsupport] Add NOOP option for commands that did not have that option #1445

Merged
merged 5 commits into from
Feb 25, 2021

Conversation

smaheshm
Copy link
Contributor

@smaheshm smaheshm commented Feb 18, 2021

What I did

Add NOOP option for 'save_proc' and 'docker cp' commands.
(this option can be used in pytest to check against all commands that will be executed for techsupport collection)

How I did it

Added "NOOP" option to print the command without executing it.

How to verify it

admin@str-s6000-acs-8:~$ generate_dump -n
mkdir -p /var/dump/sonic_dump_str-s6000-acs-8_20210218_230943
ln -s /usr/local/bin/generate_dump /var/dump/sonic_dump_str-s6000-acs-8_20210218_230943
tar -chf /var/dump/sonic_dump_str-s6000-acs-8_20210218_230943.tar -C /var/dump sonic_dump_str-s6000-acs-8_20210218_230943
rm -f /var/dump/sonic_dump_str-s6000-acs-8_20210218_230943/sonic_dump
mkdir -p /var/dump/sonic_dump_str-s6000-acs-8_20210218_230943/proc
echo cp  -r /proc/buddyinfo /var/dump/sonic_dump_str-s6000-acs-8_20210218_230943/proc
echo cp  -r /proc/cmdline /var/dump/sonic_dump_str-s6000-acs-8_20210218_230943/proc
echo cp  -r /proc/consoles /var/dump/sonic_dump_str-s6000-acs-8_20210218_230943/proc
echo cp  -r /proc/cpuinfo /var/dump/sonic_dump_str-s6000-acs-8_20210218_230943/proc
.
.
.

admin@str-s6000-acs-8:~$ generate_dump -n
mkdir -p /var/dump/sonic_dump_str-s6000-acs-8_20210218_231041
ln -s /usr/local/bin/generate_dump /var/dump/sonic_dump_str-s6000-acs-8_20210218_231041
tar -chf /var/dump/sonic_dump_str-s6000-acs-8_20210218_231041.tar -C /var/dump sonic_dump_str-s6000-acs-8_20210218_231041
rm -f /var/dump/sonic_dump_str-s6000-acs-8_20210218_231041/sonic_dump
timeout --foreground 5m sudo docker exec -i syncd touch /var/log/diagrun.log
timeout --foreground 5m sudo docker cp syncd:/var/log/diagrun.log /var/log/diagrun.log
timeout --foreground 5m sudo docker exec -i syncd touch /var/log/bcm_diag_post
timeout --foreground 5m sudo docker cp syncd:/var/log/bcm_diag_post /var/log/bcm_diag_post

Platform INFO:

admin@svcstr-nmasic-acs-1:/var/dump$ sudo generate_dump -n | grep timeout 
timeout --foreground 5m show platform syseeprom &> '/var/dump/sonic_dump_svcstr-nmasic-acs-1_20210219_194632/dump/syseeprom'
timeout --foreground 5m show platform psustatus &> '/var/dump/sonic_dump_svcstr-nmasic-acs-1_20210219_194632/dump/psustatus'
timeout --foreground 5m show platform ssdhealth &> '/var/dump/sonic_dump_svcstr-nmasic-acs-1_20210219_194632/dump/ssdhealth'
timeout --foreground 5m show platform temperature &> '/var/dump/sonic_dump_svcstr-nmasic-acs-1_20210219_194632/dump/temperature'
timeout --foreground 5m show platform fan &> '/var/dump/sonic_dump_svcstr-nmasic-acs-1_20210219_194632/dump/fan'


admin@svcstr-nmasic-acs-1:~$ sudo generate_dump 
tar: sonic_dump_svcstr-nmasic-acs-1_20210219_194041/generate_dump: File removed before we read it
Command: show platform syseeprom timedout after 5 minutes.
admin@svcstr-nmasic-acs-1:~$ cd /var/dump/
admin@svcstr-nmasic-acs-1:/var/dump$ sudo tar -xvf sonic_dump_svcstr-nmasic-acs-1_20210219_194041.tar 
sonic_dump_svcstr-nmasic-acs-1_20210219_194041/
sonic_dump_svcstr-nmasic-acs-1_20210219_194041/dump/syseeprom
sonic_dump_svcstr-nmasic-acs-1_20210219_194041/dump/psustatus
sonic_dump_svcstr-nmasic-acs-1_20210219_194041/dump/ssdhealth
sonic_dump_svcstr-nmasic-acs-1_20210219_194041/dump/temperature
sonic_dump_svcstr-nmasic-acs-1_20210219_194041/dump/fan

PSU    Status
-----  --------
PSU 1  OK
PSU 2  OK
Device Model : Micron_M600_MTFDDAT064MBF
Health       : N/A
Temperature  : N/A
Fan Not detected

admin@svcstr-masic-acs-1:/var/dump$ cat sonic_dump_svcstr-nmasic-acs-1_20210219_194041/dump/fan
Fan Not detected

admin@svcstr-masic-acs-1:/var/dump$ cat sonic_dump_svcstr-nmasic-acs-1_20210219_194041/dump/temperature
Thermal Not detected

admin@svcstr-masic-acs-1:/var/dump$ cat sonic_dump_svcstr-nmasic-acs-1_20210219_194041/dump/ssdhealth
Device Model : Micron_M600_MTFDDAT064MBF
Health       : N/A
Temperature  : N/A


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)

scripts/generate_dump Outdated Show resolved Hide resolved
sujinmkang
sujinmkang previously approved these changes Feb 19, 2021
jleveque
jleveque previously approved these changes Feb 19, 2021
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.

Approving. However, it would be nice if we could add some kind of run_cmd() wrapper function which we can pass every command, and that function would check the NOOP variable and either echo the command or run it. However, this might require some refactoring because some commands are currently strung together.

@smaheshm
Copy link
Contributor Author

retest this please

1 similar comment
@smaheshm
Copy link
Contributor Author

retest this please

@smaheshm smaheshm dismissed stale reviews from jleveque and sujinmkang via 4a67fb7 February 19, 2021 19:44
@smaheshm smaheshm requested a review from sujinmkang February 19, 2021 19:49
@smaheshm
Copy link
Contributor Author

retest this please

scripts/generate_dump Outdated Show resolved Hide resolved
mkdir -p $TARDIR
$CP $V -rf /host/warmboot $TARDIR

start_t=$(date +%s%3N)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line needs to be out of the condition to be used for calculating the time.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Another question is if we need to log the time of the output generation for noop case. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not needed, adding it to be consistent with other commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line needs to be out of the condition to be used for calculating the time.

😬

@smaheshm smaheshm requested a review from sujinmkang February 24, 2021 01:56
@smaheshm smaheshm merged commit 2f6e36e into sonic-net:master Feb 25, 2021
anand-kumar-subramanian pushed a commit to anand-kumar-subramanian/sonic-utilities that referenced this pull request Mar 2, 2021
@keboliu
Copy link
Collaborator

keboliu commented Mar 16, 2021

This PR needs to be cherry-picked to 202012 otherwise the latest community show_techsupport/tech_support_cmds.py will fail on 202012 image

daall pushed a commit that referenced this pull request Mar 19, 2021
@smaheshm smaheshm deleted the stech branch April 14, 2021 15:52
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 28, 2022
d03c6ccc90b92d9319c500a8adcf727a9fa5609b (HEAD -> 201911, origin/201911) [intfsorch] Init proxy_arp variable while adding router interface. (sonic-net#1473)
9e7c0bc8e3f2c7c5422f2f8a2c6498f659dcdf84 [drop counters] Clarify log messages for initial counter setup (sonic-net#1445)
da8ac754fa1c36f9bb7ba1210017f915f339cfe0 Create vnet tunnel map only if it doesn't exist (sonic-net#1482)

Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 28, 2022
Including the following changes:
[bitmap_vnet] Remove BMTOR implementation (sonic-net#1496)
[intfsorch] Init proxy_arp variable while adding router interface. (sonic-net#1473)
[drop counters] Clarify log messages for initial counter setup (sonic-net#1445)

Signed-off-by: Liat Grozovik <liatg@nvidia.com>
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.

5 participants