-
-
Notifications
You must be signed in to change notification settings - Fork 751
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
Log non-fatal errors during service bootstrap phase under DEBUG instead of ERROR #4630
Conversation
registration) as debug since they are non-fatal. Previously they were logged under error which caused a lot of confusion.
@@ -245,7 +245,7 @@ def create_trigger_db(trigger_api): | |||
return trigger_db | |||
|
|||
|
|||
def create_or_update_trigger_db(trigger): | |||
def create_or_update_trigger_db(trigger, log_not_unique_error_as_debug=False): | |||
""" |
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.
Note: We want to default this to False
everywhere because in other context, this error would indeed be fatal.
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.
LGTM, thanks for catching this!
|
||
extra = {'trigger_db': trigger_db} | ||
LOG.audit('Trigger created for parameter-less internal TriggerType. Trigger.id=%s' % | ||
(trigger_db.id), extra=extra) | ||
except StackStormDBObjectConflictError: | ||
except (NotUniqueError, StackStormDBObjectConflictError): |
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.
👍
Overall, I would be much more happy if we could add a consistent test for it, but as mentioned above - this would be hard and there are a lot of edge cases. |
This pull request updates the code to log non-fatal errors under
DEBUG
log level instead ofERROR
.Previously we logged those under
ERROR
which caused a lot of unnecessary confusion.Background, Context
During service bootstrap phase and when running register content script we register internal trigger types (among other things).
This operation is idempotent and as such, some of the possible errors (not unique and object already exists error) are non-fatal. An error represents a non-fatal race which just means that a particular trigger has already been registered by a different service / process.
NOTE: Adding tests for that would be hard. We would need to replicate the race which means spawning multiple processes (using multiple eventlets won't work here, we need real parallelism to replicate it) and ensure tests run on multi core / CPU server...
Resolves #3933.
Output
Before:
After (as you can see, the error is only logged under debug when
--verbose
flag is used):TODO