[action] [PR:3832] [show][config][plugin] add processing of ModuleNotFoundError with log_warning#3992
Merged
mssonicbld merged 1 commit intosonic-net:202505from Jul 22, 2025
Conversation
…_warning 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: ```
Collaborator
Author
|
Original PR: #3832 |
Collaborator
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
kktheballer
pushed a commit
to kktheballer/sonic-utilities
that referenced
this pull request
Jan 14, 2026
```<br>* 42b28bb - (HEAD -> 202506, origin/202505) `vnet_route_check.py` should not report VNET routes in APP DB but not in STATE DB and ASIC DB as mismatches (sonic-net#3991) (2025-07-22) [mssonicbld] * f36ac95 - [show][config][plugin] add processing of ModuleNotFoundError with log_warning (sonic-net#3992) (2025-07-22) [mssonicbld] * 6a4a8ff - [sonic-package-manager] Save tag that was used to install the application (sonic-net#3975) (2025-07-16) [mssonicbld] * 54a961f - [SPM] Add support for configuring systemd service Type in package manifests (sonic-net#3974) (2025-07-15) [mssonicbld] * 0b977d1 - [trim]: Add Packet Trimming Asym DSCP CLI (sonic-net#3971) (2025-07-14) [mssonicbld] * b51e117 - Add GCU Support for SKU Mellanox-SN4280-C48/O8C40/O8V40 (sonic-net#3965) (2025-07-10) [mssonicbld] * dbc5be9 - [Arista] Add support for LodogaPrime platform (sonic-net#3966) (2025-07-10) [mssonicbld]<br>```
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: