Skip to content
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

Hide internal logging exceptions #5848

Merged
merged 1 commit into from
Feb 24, 2020

Conversation

FlorianVeaux
Copy link
Member

What does this PR do?

If an internal logging exception is raised while using the datadog_checks_downloader, we should not display it to the end user.

Motivation

Additional Notes

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have changelog/ and integration/ labels attached

@ofek ofek changed the title Hide internan logging exceptions Hide internal logging exceptions Feb 24, 2020
Copy link
Contributor

@ofek ofek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FlorianVeaux
Copy link
Member Author

No, the logic has to happen before: https://github.com/DataDog/integrations-core/blob/master/datadog_checks_downloader/datadog_checks/downloader/__main__.py#L7

And having it in __main__ requires styling tricks, as you need to run code between imports and all the styling tools we use complain about that.

Copy link
Member

@trishankatdatadog trishankatdatadog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @FlorianVeaux !

So, hold on, I'm a little confused. What is the effect of this? Would this swallow logging.exception() calls?

@FlorianVeaux
Copy link
Member Author

FlorianVeaux commented Feb 24, 2020

No this only swallows "internal" errors from the logging module.

For example on Python2 this would display an error if you don't set raiseExceptions = False:

import logging
logger = logging.getLogger('foo')

logger.warn("bar")

Python will show the error "No handler could be found for logger 'foo'"

@trishankatdatadog
Copy link
Member

No this only swallows "internal" errors from the logging module.

So, sorry, why do we need this in relation to this issue?

@FlorianVeaux
Copy link
Member Author

FlorianVeaux commented Feb 24, 2020

There are two issues in the securesystemslib library.

The first one is that it shows a warning when colorama is not installed. This issue is fixed with the pull request you mentioned.

The second issue is that the logger is not initialized correctly in that library. It would need to add a "handler" to correctly log messages to stdout/a file/something else...
The result of that is that when the library will try to log something, it won't work and Python will show an error saying that there "No handler could be found..."

This is not an issue on Python3 though as it has a default handler to log on stdout

@trishankatdatadog
Copy link
Member

Oh, I see, thanks for the explanation! Hmm, then we need to file another issue for the second bug in securesystemslib, no?

@trishankatdatadog
Copy link
Member

Also, would be great if you add a short note to add context around this LoC, if you don't mind terribly much, please...

@FlorianVeaux
Copy link
Member Author

FlorianVeaux commented Feb 24, 2020

Yes, the issue I opened mentions both problems: secure-systems-lab/securesystemslib#210

But my PR doesn't fix that second part as it requires more knowledge about the library.

Also, would be great if you add a short note to add context around this LoC, if you don't mind terribly much, please...

I think I've given all the details in both the issue and the PR on the securesystemlib repo.
For this PR only, I don't think we should relate the change to the securesystemlib issue. It's a good practice to have raiseExceptions = False in any case for a tool like the downloader which output will be read by humans.

@FlorianVeaux FlorianVeaux merged commit e294441 into master Feb 24, 2020
@FlorianVeaux FlorianVeaux deleted the florian/hide_internal_logging_exceptions branch February 24, 2020 22:23
ofek pushed a commit that referenced this pull request Feb 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants