Check if len in headers to avoid KeyError in supervisor-proc-exit-listener#23419
Merged
qiluo-msft merged 3 commits intosonic-net:masterfrom Jul 25, 2025
Merged
Conversation
…-exit-listerner Signed-off-by: Zhaohui Sun <[email protected]>
Collaborator
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Zhaohui Sun <[email protected]>
Collaborator
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
liuh-80
approved these changes
Jul 22, 2025
liuh-80
reviewed
Jul 22, 2025
Contributor
Author
|
@qiluo-msft could you please help review? |
qiluo-msft
reviewed
Jul 24, 2025
| headers = childutils.get_headers(line) | ||
| # Check if 'len' exists before using it | ||
| if 'len' not in headers: | ||
| syslog.syslog(syslog.LOG_ERR, "WARNING: Missing 'len' header in: {}".format(headers)) |
Collaborator
Contributor
Author
There was a problem hiding this comment.
Good suggestion, update code, please review it again, thanks.
qiluo-msft
reviewed
Jul 24, 2025
| headers = childutils.get_headers(line) | ||
| # Check if 'len' exists before using it | ||
| if 'len' not in headers: | ||
| syslog.syslog(syslog.LOG_ERR, "WARNING: Missing 'len' header in: {}".format(headers)) |
Collaborator
Contributor
Author
There was a problem hiding this comment.
Good suggestion, update code, please review it again, thanks.
Signed-off-by: Zhaohui Sun <[email protected]>
Collaborator
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
qiluo-msft
approved these changes
Jul 25, 2025
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.
Why I did it
It found the following KeyError in syslog, not only for lldp, but also for snmp and bgp.
The context syslog is:
During shutdown, supervisor is sending termination events to the event listener, but the shutdown process is interrupting the event stream.
The container is being forcibly killed (
Container failed to exit within 10s of signal 15 - using the force), which can interrupt the supervisor event protocol mid-stream.Supervisor starts sending an event header
Before it can complete sending the full header (including len: field), the process gets interrupted
The listener receives a partial/malformed header without the len field
Work item tracking
How I did it
Check if 'len' exists before using it, if there is no len, it can't process the further steps.
How to verify it
Which release branch to backport (provide reason below if selected)
Tested branch (Please provide the tested image version)
Master image
Description for the changelog
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)