-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Better handle errors in entry points #50632
Better handle errors in entry points #50632
Conversation
0a4367f
to
fb05bd5
Compare
Is there a bug filed against this issue? I have never heard of this failing before and I am curious as to why it would do so. I'd love to see the exact stacktrace here. |
I found problems where if you have a bad entry point declared (in my case, because of copy/paste errors and then the code wasn't being packaged), then salt won't start. There's also weird things that happen if there's a problem in the called function. You probably hadn't heard of anyone encountering this problem because this feature is completely undocumented (see #50633) and nobody has used it as far as I know. (Except now, because this is super helpful for my own projects.) |
salt/loader.py
Outdated
for path in loaded_entry_point(): | ||
ext_type_types.append(path) | ||
except Exception: | ||
log.exception("Error running entry point %r", entry_point) |
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.
This error message needs to be rephrased for a regular DevOp, who has no idea what means "entry point" here and why it should run.
Also I believe it should be at error level. We want traceback only in debug mode.
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.
I'll see what I can do. I'm not sure the names that the salt administrator would be familiar are readily available. I'll have to dig into the data types.
You know that exception is error level?
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.
You know that exception is error level?
At error. And it gives you a traceback. Do we actually need it? Your error is only informative that failed to run an entry point 😉 (please clarify what means those running entry points!). So I'd rather give a traceback here only when one is really looking at it:
try:
...
except MySpecificException as exc:
log.error('An entry point just ran away from you!')
except Exception:
log.error('Oh, this neatly crashed.')
log.debug('This is how it crashed. Enjoy your day.', exc_info=True)
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 developer would certainly strongly appreciate the traceback, and I would consider any time this code is triggered to be a bug in some third-party code.
@astronouth7303 Thanks for the explanation. This is a reasonably safe change for us so we're happy to get this in but I do think you should make the changes that @isbm recommends before we merge it. |
Ok, logging is improved. |
salt/loader.py
Outdated
@@ -138,6 +138,18 @@ def static_loader( | |||
return ret | |||
|
|||
|
|||
def _format_entrypoint_target(ep): | |||
""" |
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 Salt style guide indicates that these should be three single-quotes.
What does this PR do?
Fixes entry point loading, so that if it fails, the exception is logged instead of propagated to the larger system.
What issues does this PR fix or reference?
None.
Previous Behavior
The minion would fail to start if there was any kind of problem with entry point loading.
New Behavior
The exception is logged instead.
Tests written?
No, and I'm not sure how or where.
Commits signed with GPG?
Yes.
Please review Salt's Contributing Guide for best practices.
See GitHub's page on GPG signing for more information about signing commits with GPG.