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

Fix stack overflow triggered by casefolding script #405

Merged
merged 10 commits into from Sep 28, 2021

Conversation

Azrenbeth
Copy link
Contributor

Fix stack overflow triggered by casefolding script (added in commit 5f90f62)

Logging was setup too many times. This adds option to ignore logging config options when parsing config files (so you can do that seperately)

@Azrenbeth Azrenbeth requested a review from a team September 20, 2021 10:48
Azrenbeth pushed a commit that referenced this pull request Sep 20, 2021
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

I've said this elsewhere, but I'm super dubious about having parse_config_file set up logging anyway. Can we just leave logging unconfigured (or better, configured to a hardcoded default which just writes the logs to stderr) until parse_config_file completes, and then call setup_logging from sydent.py ?

sydent/config/__init__.py Outdated Show resolved Hide resolved
@Azrenbeth
Copy link
Contributor Author

Azrenbeth commented Sep 27, 2021

I've said this elsewhere, but I'm super dubious about having parse_config_file set up logging anyway. Can we just leave logging unconfigured (or better, configured to a hardcoded default which just writes the logs to stderr) until parse_config_file completes, and then call setup_logging from sydent.py ?

I agree that this wasn't a great setup.. I've now added a setup_logging_from_file function, that you can call before parse_config_file (so that you can use logging while parseing the config file)

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

Parsing the config file twice seems a bit grim. I'm not really following why it's so important to fully configure the logging before we parse the config file for real?

changelog.d/405.bugfix Outdated Show resolved Hide resolved
sydent/config/__init__.py Outdated Show resolved Hide resolved
@Azrenbeth
Copy link
Contributor Author

Azrenbeth commented Sep 27, 2021

Parsing the config file twice seems a bit grim. I'm not really following why it's so important to fully configure the logging before we parse the config file for real?

My thought was: it's a bad thing for output to not all go to the same place.

Say someone had configured Sydent (running in a docker container for example) and had setup something to follow the logs, wouldn't it be confusing if some output was missing? E.g. the warning telling the user to setup their server name to something more sensible.

A better way to do what I'm trying to do might be to have logging configured in a seperate file.

@richvdh
Copy link
Member

richvdh commented Sep 27, 2021

Would it not be a bad thing for not-all output to go to the same place? So say you'd configured Sydent to run (e.g. in a docker container) and had setup something to follow the logs, wouldn't it be confusing if some output went somewhere else?

A docker container is probably a bad example: in that case, it's normal to have your application send everything to stdout/stderr, and let the docker runtime deal with it.

If you're not running in a docker container, then I think it's reasonable for errors that happen during startup (and thus prevent proper startup) to go to the console, while later errors go to a logfile. That's what most server processes do. Indeed, if errors during startup only go to a logfile, then it's pretty confusing when you start the process, since you can't tell if it started successfully or not.

@Azrenbeth
Copy link
Contributor Author

If you're not running in a docker container, then I think it's reasonable for errors that happen during startup (and thus prevent proper startup) to go to the console, while later errors go to a logfile. That's what most server processes do. Indeed, if errors during startup only go to a logfile, then it's pretty confusing when you start the process, since you can't tell if it started successfully or not.

Thank you for explaining! That makes a lot of sense. I've moved all the logging output from the config parsing to using print() and moved the setup_logging function into sydent.py

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

lgtm!

sydent/sydent.py Outdated
)
handler.setFormatter(formatter)

def sighup(signum, stack):
Copy link
Member

Choose a reason for hiding this comment

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

this isn't your fault, but this doesn't seem to be used anywhere 🤦

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I removed that at some point in a seperate PR but might as well do it here instead!

Copy link
Member

Choose a reason for hiding this comment

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

it might have been better to leave it, and wire it up correctly, but never mind :)

@Azrenbeth Azrenbeth merged commit bf83fe1 into main Sep 28, 2021
@Azrenbeth Azrenbeth deleted the azren/fix_casefolding_logger_overflow branch September 28, 2021 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants