[host_modules]: Fix crash loop in procdockerstatsd and Python 3.13 SyntaxWarnings - #425
Open
karthikbabu-CLS wants to merge 1 commit into
Conversation
1. showtech.py: Use raw string for regex pattern to fix invalid escape sequence '\/' SyntaxWarning on Python 3.12+. 2. hostcfgd: Use raw string for sed replacement patterns to fix invalid escape sequence '\P' SyntaxWarning on Python 3.12+ (lines 951, 958). 3. procdockerstatsd: Wrap main polling loop body in try/except to catch transient errors (FileNotFoundError, psutil.Error) at INFO level and unexpected exceptions at WARNING with full traceback. Prevents daemon crash loop when a monitored process exits mid-poll. Verified on community SONiC VS image: Before: 3 SyntaxWarning messages on boot (showtech.py, hostcfgd x2) After: 0 SyntaxWarning messages
|
/azp run |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks! ---Powered by SONiC BuildBot
|
This file contains hidden or 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
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.
What I did
\/inshowtech.pyregex by using raw string prefix (r'...').\Pinhostcfgdsed replacement patterns (lines 951, 958) by using raw string prefix (r"...").procdockerstatsdmain polling loop body in try/except to catch transient errors at INFO and unexpected exceptions at WARNING with traceback, preventing daemon crash loop.Why I did it
SyntaxWarning: invalid escape sequencefor\/and\Pin non-raw strings. These warnings appear in syslog on every boot.procdockerstatsdcrashes when a monitored Docker process exits mid-poll (raisesFileNotFoundErrororpsutil.Error). The crash causes supervisor to restart the daemon, which then crashes again on the next poll cycle — creating a crash loop. The try/except lets the daemon log the transient error at INFO and continue the next cycle instead of crashing.How I verified it
Verified on community SONiC VS image (x86_64-kvm_x86_64-r0):
BEFORE:
INFO python3[679]: /usr/local/lib/python3.13/dist-packages/host_modules/showtech.py:43: SyntaxWarning: invalid escape sequence '/'
INFO hostcfgd[4752]: /usr/local/bin/hostcfgd:951: SyntaxWarning: invalid escape sequence '\P'
INFO hostcfgd[4752]: /usr/local/bin/hostcfgd:958: SyntaxWarning: invalid escape sequence '\P'
AFTER:
admin@sonic:
$ show logging | grep "SyntaxWarning"$admin@sonic:
Details
No functional change. Regex patterns, sed replacement patterns, and stats collection logic unchanged. Only string prefixes corrected and exception handling added around the existing polling loop.