-
Notifications
You must be signed in to change notification settings - Fork 46
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
FOGL-7959 Improve error handling for plugin load failure #1142
Conversation
Signed-off-by: Mark Riddoch <[email protected]>
Signed-off-by: Mark Riddoch <[email protected]>
Signed-off-by: Mark Riddoch <[email protected]>
C based unit tests are failing
|
@@ -27,6 +27,9 @@ def get_plugin_info(name, dir): | |||
out, err = p.communicate() | |||
res = out.decode("utf-8") | |||
jdoc = json.loads(res) | |||
except json.decoder.JSONDecodeError as err: | |||
_logger.error("Failed to parse JSON data returned from the plugin information of {}, {} line {} column {}".format(name, err.msg, err.lineno, err.colno)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No harm to keep specific exception type catch block here. But as we already have multi line stack trace support available at python side; So these type of errors will catch in general exception block and definitely it points to exact problem cause error.
Use multi line stack trace logger style.
_logger.error(err, "Failed to parse JSON data returned from the plugin information of {}.".format(name))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The concept here is to give the user a very clear error message they can pick up on rather than expect them to look at something more general and work out what went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Previously, if we have some invalid JSON for a plugin it raises below
ERROR: logger: fledge.services.core.api.utils: json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 2870 (char 2869)
And with the given change
ERROR: logger: fledge.services.core.api.utils: Failed to parse JSON data returned from the plugin information of PLUGIN_NAME, Expecting ',' delimiter line 1 column 2870
So the trailing message still seems to be more developer related logger.
if (access(argv[1], F_OK|R_OK) != 0) | ||
{ | ||
fprintf(stderr, "Unable to access library file '%s', exiting...\n", argv[1]); | ||
syslog(LOG_ERR, "Unable to access library file '%s', exiting...\n", argv[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be retain fprintf to stderr also (in addition to syslog) so that errors can be seen on console also.
Signed-off-by: Mark Riddoch <[email protected]>
Signed-off-by: Mark Riddoch <[email protected]>
Signed-off-by: Mark Riddoch <[email protected]>
Signed-off-by: Mark Riddoch <[email protected]>
Signed-off-by: Mark Riddoch <[email protected]>
Signed-off-by: Mark Riddoch <[email protected]>
Signed-off-by: Mark Riddoch <[email protected]>
Signed-off-by: Mark Riddoch <[email protected]>
Signed-off-by: Mark Riddoch <[email protected]>
Signed-off-by: Mark Riddoch <[email protected]>
Signed-off-by: Mark Riddoch <[email protected]>
Signed-off-by: Mark Riddoch <[email protected]>
Signed-off-by: Mark Riddoch <[email protected]>
Capture some of the reason plugins fail to load and give the user a better indication of the problem
Make the get_plugin_info utility log errors to the error log. This allows users to see missing dependecies when dynamically linking in C++ plugins