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

Enhance logging when inotify beacon is missing pyinotify #60402

Merged
merged 7 commits into from Jan 11, 2022

Conversation

meaksh
Copy link
Contributor

@meaksh meaksh commented Jun 18, 2021

What does this PR do?

This PR simply enhances the logging for "inotify" beacon when __virtual__ function is returning False due missing pyinotify library.

NOTE: I'm not adding a unit test for this since it is simply a cosmetic change. Is the test required in this case?

Previous Behavior

Without this PR, in case pyinotify is not installed on the system, the logs we see in the minions are like the following:

...
2021-06-18 13:41:13,264 [salt.utils.lazy  :109 ][DEBUG   ][29985] Could not LazyLoad inotify.beacon: 'inotify' __virtual__ returned False
2021-06-18 13:41:13,265 [salt.beacons     :130 ][WARNING ][29985] Unable to process beacon inotify
2021-06-18 13:41:14,181 [salt.utils.lazy  :105 ][DEBUG   ][29985] LazyLoaded inotify.beacon
2021-06-18 13:41:14,182 [salt.beacons     :130 ][WARNING ][29985] Unable to process beacon inotify
2021-06-18 13:41:15,181 [salt.utils.lazy  :105 ][DEBUG   ][29985] LazyLoaded inotify.beacon
2021-06-18 13:41:15,182 [salt.beacons     :130 ][WARNING ][29985] Unable to process beacon inotify
2021-06-18 13:41:16,181 [salt.utils.lazy  :105 ][DEBUG   ][29985] LazyLoaded inotify.beacon
2021-06-18 13:41:16,182 [salt.beacons     :130 ][WARNING ][29985] Unable to process beacon inotify

As you can see, there is no hint, even with log_level: debug that indicates why the beacon cannot be loaded or processed.

New Behavior

Now we see an indication about missing pyinotify library, even if not running in debug mode, so the user knows what's happening:

2021-06-18 14:29:01,097 [salt.loaded.int.beacons.inotify:54  ][ERROR   ][512] Unable to load inotify beacon: pyinotify library is missing
2021-06-18 14:29:10,259 [salt.beacons     :130 ][WARNING ][512] Unable to process beacon inotify
2021-06-18 14:29:10,471 [salt.loaded.int.beacons.inotify:54  ][ERROR   ][512] Unable to load inotify beacon: pyinotify library is missing
2021-06-18 14:29:10,531 [salt.beacons     :130 ][WARNING ][512] Unable to process beacon inotify
2021-06-18 14:29:11,470 [salt.beacons     :130 ][WARNING ][512] Unable to process beacon inotify
2021-06-18 14:29:12,470 [salt.beacons     :130 ][WARNING ][512] Unable to process beacon inotify

Merge requirements satisfied?

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.

@meaksh meaksh requested a review from a team as a code owner June 18, 2021 12:31
@meaksh meaksh requested review from waynew and removed request for a team June 18, 2021 12:31
salt/beacons/inotify.py Show resolved Hide resolved
s0undt3ch
s0undt3ch previously approved these changes Oct 5, 2021
salt/beacons/inotify.py Show resolved Hide resolved
@Ch3LL
Copy link
Contributor

Ch3LL commented Oct 7, 2021

This does change the behavior for only this single beacon and not the others. I'm afraid by changing behavior on only one individual beacon, users would expect the same behavior on the other beacons.

also @s0undt3ch can you explain why this would be okay to log since its an engine. I initially shared the same concern as you, that this could be noisy and log an error unintentionally for some users.

@s0undt3ch
Copy link
Member

This does change the behavior for only this single beacon and not the others. I'm afraid by changing behavior on only one individual beacon, users would expect the same behavior on the other beacons.

True. Update all others on this PR?

@s0undt3ch
Copy link
Member

can you explain why this would be okay to log since its an engine. I initially shared the same concern as you, that this could be noisy and log an error unintentionally for some users.

Loaded modules/states get loaded over and over, so, logging on these would cause a lot of log messages.
Engines however are loaded once, so these log messages would be ok.

@Ch3LL
Copy link
Contributor

Ch3LL commented Oct 8, 2021

Yeah, I think we need to update all beacons on this PR to ensure the experience is the same for all beacons. Is this something you are willing to do @meaksh ? The changelog type should also be changed, since we are changing behavior.

@waynew
Copy link
Contributor

waynew commented Dec 15, 2021

@meaksh Just pinging on this - were you still planning to add the log change for the other engines?

@meaksh
Copy link
Contributor Author

meaksh commented Dec 21, 2021

@meaksh Just pinging on this - were you still planning to add the log change for the other engines?

Hey @waynew, sorry for the delay on this - I have just pushed the requested changes for all other beacons.

@waynew
Copy link
Contributor

waynew commented Jan 5, 2022

@meaksh awesome, thanks! I'll take a look probably next week!

salt/beacons/smartos_vmadm.py Outdated Show resolved Hide resolved
@github-actions
Copy link

Hi! I'm your friendly PR bot!

You might be wondering what I'm doing commenting here on your PR.

Yes, as a matter of fact, I am...

I'm just here to help us improve the documentation. I can't respond to
questions or anything, but what I can do, I do well!

Okay... so what do you do?

I detect modules that are missing docstrings or "CLI Example" on existing docstrings!
When I was created we had a lot of these. The documentation for these
modules need some love and attention to make Salt better for our users.

So what does that have to do with my PR?

I noticed that in this PR there are some files changed that have some of these
issues. So I'm leaving this comment to let you know your options.

Okay, what are they?

Well, my favorite, is that since you were making changes here I'm hoping that
you would be the most familiar with this module and be able to add some other
examples or fix any of the reported issues.

If I can, then what?

Well, you can either add them to this PR or add them to another PR. Either way is fine!

Well... what if I can't, or don't want to?

That's also fine! We appreciate all contributions to the Salt Project. If you
can't add those other examples, either because you're too busy, or unfamiliar,
or you just aren't interested, we still appreciate the contributions that
you've made already.

Whatever approach you decide to take, just drop a comment here letting us know!

Detected Issues (click me)
Check Known Missing Docstrings...........................................Failed
- hook id: invoke
- duration: 1.11s
- exit code: 1

The function 'close' on 'salt/beacons/inotify.py' does not have a docstring
The function 'to_salt_event' on 'salt/beacons/watchdog.py' does not have a docstring
The function 'close' on 'salt/beacons/watchdog.py' does not have a docstring
Found 3 errors


Thanks again!

@Ch3LL
Copy link
Contributor

Ch3LL commented Jan 10, 2022

@garethgreenaway can we get your review here since your familiar with beacons.

@Ch3LL Ch3LL added the Phosphorus v3005.0 Release code name and version label Jan 10, 2022
@Ch3LL Ch3LL merged commit 4eda4c0 into saltstack:master Jan 11, 2022
@meaksh meaksh deleted the master-add-logging-to-inotify-beacon branch January 12, 2022 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Phosphorus v3005.0 Release code name and version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants