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

Added code to process-reboot-check that mitigates JSON decoder errors #126

Merged
merged 1 commit into from
May 17, 2024

Conversation

assrinivasan
Copy link
Contributor

@assrinivasan assrinivasan commented May 17, 2024

Why I did it

The current process-reboot-cause script is susceptible to JSONDecodeErrors if the reboot-cause file is not a properly formatted JSON file.

Fixes sonic-net/sonic-buildimage#18898

How I did it

Added a try-except block around the actual JSON parsing bit of the code

Microsoft ADO: 28062468

How I verified it

First I verified that the issue is seen when the reboot-cause file is either an empty file or an improperly formatted JSON file:

image image

I then replaced the existing script with the script from this PR and restarted the service:

image

As is seen, the service exited with SUCCESS exit code and journalctl shows the JSON Decoder exception raised when trying to parse an improper JSON file.

@assrinivasan assrinivasan changed the title Added a try block to prevent JSON decoder errors Added code to process-reboot-check that mitigates JSON decoder errors May 17, 2024
@prgeor prgeor merged commit 246f2d2 into sonic-net:master May 17, 2024
5 checks passed
@gechiang
Copy link

We also need this for 202205 which T2 chassis is still actively using the branch and need this bug fix.

@StormLiangMS
Copy link

hi @yxieca should cherry pick this?

@mssonicbld
Copy link

Cherry-pick PR to 202311: #146

@yxieca
Copy link
Contributor

yxieca commented Aug 15, 2024

hi @yxieca should cherry pick this?

Yes. Let's take it to 202305 as well.

@gechiang
Copy link

hi @yxieca should cherry pick this?

Yes. Let's take it to 202305 as well.

@yxieca
How about 202205? can we have this as Chassis is still based on this...

@mssonicbld
Copy link

Cherry-pick PR to 202205: #147

@mssonicbld
Copy link

Cherry-pick PR to 202305: #148

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