[show][config][plugin] add processing of ModuleNotFoundError with log_warning#3832
Merged
qiluo-msft merged 2 commits intosonic-net:masterfrom Jul 21, 2025
Conversation
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
stepanblyschak
approved these changes
Apr 7, 2025
6b5b3a3 to
a401ddc
Compare
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
a401ddc to
726b3f7
Compare
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
726b3f7 to
b341e11
Compare
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
b341e11 to
99d5e4b
Compare
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
99d5e4b to
da71522
Compare
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
da71522 to
cedd723
Compare
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
cedd723 to
4e1db14
Compare
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
4e1db14 to
05b8ffe
Compare
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…ning log message instead of default error message Avoid excess error messages for cases of race conditions when plugin was removed right before the stage of its loading Signed-off-by: Maksym Kovalchuk <[email protected]>
Signed-off-by: Maksym Kovalchuk <[email protected]>
05b8ffe to
1793c04
Compare
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
stepanblyschak
approved these changes
Apr 11, 2025
Contributor
|
/Semgrep |
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
qiluo-msft
approved these changes
Jul 21, 2025
Collaborator
|
Cherry-pick PR to 202505: #3992 |
YairRaviv
pushed a commit
to YairRaviv/sonic-utilities
that referenced
this pull request
Jan 12, 2026
…_warning (sonic-net#3832) There is the case of rare situation of race condition when plugin script file is removed right before the stage of its load via cli (e.g. in case of dynamic removing with app extensions). This situation has no impact but generate additional error messages to syslog What I did Add separate processing ModuleNotFoundError with log_warning messages to avoid excess ERR printing How to verify it It happens very rarely in nature but you can just try to remove plugin script manually right before its loading stage. I used this changes on top of my commit for testing: diff --git a/utilities_common/util_base.py b/utilities_common/util_base.py index 95098b7..c808b0a 100644 --- a/utilities_common/util_base.py +++ b/utilities_common/util_base.py @@ -2,6 +2,8 @@ import os import pkgutil import importlib +import subprocess + from sonic_py_common import logger # Constants ==================================================================== @@ -11,6 +13,7 @@ PDDF_SUPPORT_FILE = '/usr/share/sonic/platform/pddf_support' log = logger.Logger() +plugin_path = "/usr/local/lib/python3.11/dist-packages/show/plugins/dhcp-relay.py" class UtilHelper(object): def __init__(self): @@ -28,11 +31,15 @@ class UtilHelper(object): continue log.log_debug('importing plugin: {}'.format(module_name)) try: + if module_name == "show.plugins.dhcp-relay": + subprocess.run(['mv', plugin_path, '/root/' ]) module = importlib.import_module(module_name) except ModuleNotFoundError as err: log.log_warning('failed to import plugin {}: {}'.format(module_name, err), also_print_to_console=True) + if module_name == "show.plugins.dhcp-relay": + subprocess.run(['mv', '/root/dhcp-relay.py', plugin_path ]) continue except Exception as err:
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.
There is the case of rare situation of race condition when plugin script file is removed right before the stage of its load via cli (e.g. in case of dynamic removing with app extensions). This situation has no impact but generate additional error messages to syslog
What I did
Add separate processing ModuleNotFoundError with log_warning messages to avoid excess ERR printing
How to verify it
It happens very rarely in nature but you can just try to remove plugin script manually right before its loading stage. I used this changes on top of my commit for testing: