-
Notifications
You must be signed in to change notification settings - Fork 19
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
Refs #32968 - Add management of Pulpcore log level #12
Conversation
Thanks, @wbclark! Can it be connected/solving this issue as well https://projects.theforeman.org/issues/32954 ? |
HI @ofedoren , thanks for your response. It looks like we have partially overlapping issues here:
A few things to consider about how we could handle this (imo, rather interesting) situation:
So therefore my proposal is:
|
Opened #13 |
:debug: | ||
- | ||
:action: ensure_line_is_present | ||
:line: [" 'level'", ": ", "'DEBUG',"] |
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.
How does the code make sure that this line ends up in the right spot in the file without a declared anchor or descriptor of where it should exist?
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 tested this on a live instance with the real configuration generated by the installer (hacked a bit to get latest changes in pulpcore module, given that katello nightlies were broken until this morning)
I changed it back and forth multiple times between debug mode and production, validating by restarting services and observing appropriate verbosity in logs, as well as manually inspecting the config file each time
so I can state confidently that as the config file is currently structured, it works as expected. I am sure some corner case config file could be constructed to break it (given my intention to put https://github.com/theforeman/puppet-pulpcore/pull/210/files into the settings.py header I think I am OK with that though).
In particular, I copied the basic structure of this feature from the pulp2 equivalent, where in testing I noticed that it actually changes a commented line describing log levels into the actual configuration (and also makes the change a few lines below where the setting already existed). This is admittedly janky but otherwise has no production impact... a commented line is destroyed and some helpful text is lost, replaced with a doubled config line. Once that change from the initial config file is made on the first run, both versions of the line continue to exist and both get updated on each subsequent log level change via hammer admin.
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.
One alternative that I considered is that the logging configuration could be a single line in settings.py :
LOGGING = {"dynaconf_merge": True, "loggers": {'': {'handlers': ['console'], 'level': 'DEBUG'}}}
I would argue that it's OK to sacrifice ease of human readability in settings.py for this purpose. The only thing they should read in that file anyway is the warning that says to immediately close your editor without saving changes and manage the config through the proper tooling only.
I think there are other methods present here in hammer cli foreman admin to ensure the operation is more robust towards different things you may find in a hand edited config file, but I didn't explore it further as I was able to get it working reliably with the config file format we planned to ship.
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.
P.S. I did author a "fix" for the destroyed comment / duplicate log level config issue in pulp2: #13
:^)
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.
Thank you, let's get this in.
No description provided.